Skip to content

Commit f973774

Browse files
alacukupoiana
authored andcommitted
update(CI): use goreleaser in integration pipeline when building falcoctl
Signed-off-by: Aldo Lacuku <[email protected]>
1 parent 38e7789 commit f973774

File tree

1 file changed

+58
-36
lines changed

1 file changed

+58
-36
lines changed

.github/workflows/integration.yaml

Lines changed: 58 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,59 +7,81 @@ on:
77

88
jobs:
99
build:
10-
runs-on: ubuntu-latest
11-
strategy:
12-
matrix:
13-
goos: [linux, darwin, windows]
14-
goarch: [arm64, amd64]
15-
exclude:
16-
- goarch: arm64
17-
goos: windows
10+
runs-on: ubuntu-22.04
11+
outputs:
12+
matrix: ${{ steps.configure.outputs.matrix }}
13+
artifacts-dir: ${{ steps.configure.outputs.artifacts-dir }}
14+
cache-key: ${{ steps.configure.outputs.cache-key }}
1815
steps:
1916
- name: Checkout commit
20-
uses: actions/checkout@v3
17+
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b #v3.0.2
18+
with:
19+
fetch-depth: 0
2120

2221
- name: Setup Go
23-
uses: actions/setup-go@v3
22+
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a #v3.2.1
2423
with:
2524
go-version: 1.19
2625

27-
- name: Build Falcoctl
28-
run: >
29-
go build -o falcoctl-${{ matrix.goos }}-${{ matrix.goarch }} .
30-
env:
31-
CGO_ENABLED: 0
32-
GOOS: ${{ matrix.goos }}
33-
GOARCH: ${{ matrix.goarch }}
26+
- name: Run GoReleaser
27+
uses: goreleaser/goreleaser-action@68acf3b1adf004ac9c2f0a4259e85c5f66e99bef #v3.0.0
28+
with:
29+
distribution: goreleaser
30+
version: v1.10.3
31+
args: release --rm-dist --snapshot
3432

35-
- name: Create Archives
33+
- name: Save config variables
34+
id: configure
3635
run: |
37-
cp falcoctl-${{ matrix.goos }}-${{ matrix.goarch }} falcoctl
38-
tar -czvf falcoctl-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz falcoctl LICENSE
36+
# Save artifacts info in matrix variable. Only artifacts of type "Archive".
37+
# The matrix variable is used in a later job to upload the artifacts.
38+
matrix=$(jq 'map(. | select(.type=="Archive"))' dist/artifacts.json)
39+
echo "::set-output name=matrix::{\"include\":$(echo $matrix)}"
40+
41+
# Save the commit hash to be used as unique key for the cached artifacts.
42+
echo "::set-output name=cache-key::${{ github.sha }}"
43+
44+
# Save the artifacts directory in a variable.
45+
echo "::set-output name=artifacts-dir::dist"
3946
40-
- name: Upload falcoctl
41-
uses: actions/upload-artifact@v2
47+
- name: Cache artifacts - upload
48+
id: cache-artifacts
49+
uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77 #v3.0.8
4250
with:
43-
name: falcoctl-${{ matrix.goos }}-${{ matrix.goarch }}
44-
path: ./falcoctl-${{ matrix.goos }}-${{ matrix.goarch }}
45-
retention-days: 1
51+
path: ${{ steps.configure.outputs.artifacts-dir }}
52+
key: ${{ steps.configure.outputs.cache-key }}
53+
54+
upload-artifacts:
55+
runs-on: ubuntu-22.04
56+
needs: build
57+
strategy:
58+
matrix: ${{ fromJson(needs.build.outputs.matrix) }}
59+
steps:
60+
- name: Cache artifacts - download
61+
id: cache-artifacts
62+
uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77 #v3.0.8
63+
with:
64+
path: ${{ needs.build.outputs.artifacts-dir}}
65+
key: ${{ needs.build.outputs.cache-key}}
4666

47-
- name: Upload falcoctl Archive
48-
uses: actions/upload-artifact@v2
67+
- name: Upload ${{ matrix.name }}
68+
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 #v3.1.0
4969
with:
50-
name: falcoctl-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
51-
path: ./falcoctl-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
70+
name: ${{ matrix.name }}
71+
path: ./${{ matrix.path }}
5272
retention-days: 1
5373

5474
test:
5575
needs: build
5676
runs-on: ubuntu-latest
5777
steps:
58-
- name: Checkout commit
59-
uses: actions/checkout@v3
78+
- name: Checkout commit
79+
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b #v3.0.2
6080

61-
- name: Setup Go 1.19
62-
uses: actions/setup-go@v3
63-
with:
64-
go-version: 1.19
65-
- run: go test ./...
81+
- name: Setup Go
82+
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a #v3.2.1
83+
with:
84+
go-version: 1.19
85+
86+
- name: Run tests
87+
run: go test ./...

0 commit comments

Comments
 (0)