@@ -27,6 +27,9 @@ concurrency:
2727 group : ${{ github.ref_name }}-ci
2828 cancel-in-progress : true
2929
30+ env :
31+ platforms : " linux/arm64, linux/amd64"
32+
3033jobs :
3134
3235 vars :
@@ -36,19 +39,22 @@ jobs:
3639 sha : ${{ steps.vars.outputs.sha }}
3740 version : ${{ steps.vars.outputs.version }}
3841 date : ${{ steps.vars.outputs.date }}
42+ go_path : ${{ steps.vars.outputs.go_path }}
3943 steps :
4044 - name : Checkout Repository
4145 uses : actions/checkout@v3
46+ - name : Setup Golang Environment
47+ uses : actions/setup-go@v3
48+ with :
49+ go-version-file : go.mod
50+ cache : true
4251 - name : Output Variables
4352 id : vars
4453 run : |
4554 echo "::set-output name=sha::$(echo ${GITHUB_SHA} | cut -c1-7)"
4655 echo "::set-output name=version::$(grep "VERSION = " Makefile | cut -d " " -f 3)"
4756 echo "::set-output name=date::$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
48- - name : Setup Golang Environment
49- uses : actions/setup-go@v3
50- with :
51- go-version-file : go.mod
57+ echo "::set-output name=go_path::$(go env GOPATH)"
5258 - name : Check if CRDs changed
5359 run : |
5460 make update-crds && git diff --name-only --exit-code deploy/manifests/crds/*
6470 uses : actions/setup-go@v3
6571 with :
6672 go-version-file : go.mod
73+ cache : true
6774 - name : Run Tests
6875 run : make unit-test
6976 - name : Upload Coverage Report
@@ -94,16 +101,33 @@ jobs:
94101 steps :
95102 - name : Checkout Repository
96103 uses : actions/checkout@v3
104+ with :
105+ fetch-depth : 0
97106 - name : Setup Golang Environment
98107 uses : actions/setup-go@v3
99108 with :
100109 go-version-file : go.mod
101- - name : Build Binary
102- run : make build
110+ cache : true
111+
112+ - name : Download Syft
113+ uses :
anchore/sbom-action/[email protected] 114+
115+ - name : Build binary
116+ uses : goreleaser/goreleaser-action@v3
117+ with :
118+ version : latest
119+ args : ${{ startsWith(github.ref, 'refs/tags/') && 'release' || 'build --snapshot' }} --rm-dist
120+ env :
121+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
122+ GOPATH : ${{ needs.vars.outputs.go_path }}
123+ AZURE_STORAGE_ACCOUNT : ${{ secrets.AZURE_STORAGE_ACCOUNT }}
124+ AZURE_STORAGE_KEY : ${{ secrets.AZURE_STORAGE_KEY }}
125+ AZURE_BUCKET_NAME : ${{ secrets.AZURE_BUCKET_NAME }}
126+
103127 - name : Cache Artifacts
104128 uses : actions/cache@v3
105129 with :
106- path : ${{ github.workspace }}/build/.out/gateway
130+ path : ${{ github.workspace }}/dist
107131 key : nginx-kubernetes-gateway-${{ github.run_id }}-${{ github.run_number }}
108132
109133 build :
@@ -116,10 +140,14 @@ jobs:
116140 - name : Fetch Cached Artifacts
117141 uses : actions/cache@v3
118142 with :
119- path : ${{ github.workspace }}/build/.out/gateway
143+ path : ${{ github.workspace }}/dist
120144 key : nginx-kubernetes-gateway-${{ github.run_id }}-${{ github.run_number }}
121145 - name : Docker Buildx
122146 uses : docker/setup-buildx-action@v2
147+ - name : Setup QEMU
148+ uses : docker/setup-qemu-action@v2
149+ with :
150+ platforms : arm64
123151 - name : Login to GitHub Container Registry
124152 uses : docker/login-action@v2
125153 if : ${{ startsWith(github.ref, 'refs/tags') }}
@@ -138,17 +166,16 @@ jobs:
138166 type=edge
139167 type=ref,event=pr
140168 type=ref,event=branch,enable=${{ startsWith(github.ref, 'refs/heads/release') }}
141- flavor : |
142- latest=true
143- - name : Build Image Debian
169+ - name : Build Docker Image
144170 uses : docker/build-push-action@v3
145171 with :
146172 file : build/Dockerfile
147173 context : ' .'
148- target : local
174+ target : goreleaser
149175 tags : ${{ steps.meta.outputs.tags }}
150176 load : ${{ !startsWith(github.ref, 'refs/tags') }}
151177 push : ${{ startsWith(github.ref, 'refs/tags') }}
178+ platforms : ${{ startsWith(github.ref, 'refs/tags') && env.platforms || '' }}
152179 cache-from : type=gha
153180 cache-to : type=gha,mode=max
154181 build-args : |
0 commit comments