@@ -27,6 +27,9 @@ concurrency:
27
27
group : ${{ github.ref_name }}-ci
28
28
cancel-in-progress : true
29
29
30
+ env :
31
+ platforms : " linux/arm64, linux/amd64"
32
+
30
33
jobs :
31
34
32
35
vars :
@@ -36,19 +39,22 @@ jobs:
36
39
sha : ${{ steps.vars.outputs.sha }}
37
40
version : ${{ steps.vars.outputs.version }}
38
41
date : ${{ steps.vars.outputs.date }}
42
+ go_path : ${{ steps.vars.outputs.go_path }}
39
43
steps :
40
44
- name : Checkout Repository
41
45
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
42
51
- name : Output Variables
43
52
id : vars
44
53
run : |
45
54
echo "::set-output name=sha::$(echo ${GITHUB_SHA} | cut -c1-7)"
46
55
echo "::set-output name=version::$(grep "VERSION = " Makefile | cut -d " " -f 3)"
47
56
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)"
52
58
- name : Check if CRDs changed
53
59
run : |
54
60
make update-crds && git diff --name-only --exit-code deploy/manifests/crds/*
64
70
uses : actions/setup-go@v3
65
71
with :
66
72
go-version-file : go.mod
73
+ cache : true
67
74
- name : Run Tests
68
75
run : make unit-test
69
76
- name : Upload Coverage Report
@@ -94,16 +101,33 @@ jobs:
94
101
steps :
95
102
- name : Checkout Repository
96
103
uses : actions/checkout@v3
104
+ with :
105
+ fetch-depth : 0
97
106
- name : Setup Golang Environment
98
107
uses : actions/setup-go@v3
99
108
with :
100
109
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/download-syft@v0.11.0
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
+
103
127
- name : Cache Artifacts
104
128
uses : actions/cache@v3
105
129
with :
106
- path : ${{ github.workspace }}/build/.out/gateway
130
+ path : ${{ github.workspace }}/dist
107
131
key : nginx-kubernetes-gateway-${{ github.run_id }}-${{ github.run_number }}
108
132
109
133
build :
@@ -116,10 +140,14 @@ jobs:
116
140
- name : Fetch Cached Artifacts
117
141
uses : actions/cache@v3
118
142
with :
119
- path : ${{ github.workspace }}/build/.out/gateway
143
+ path : ${{ github.workspace }}/dist
120
144
key : nginx-kubernetes-gateway-${{ github.run_id }}-${{ github.run_number }}
121
145
- name : Docker Buildx
122
146
uses : docker/setup-buildx-action@v2
147
+ - name : Setup QEMU
148
+ uses : docker/setup-qemu-action@v2
149
+ with :
150
+ platforms : arm64
123
151
- name : Login to GitHub Container Registry
124
152
uses : docker/login-action@v2
125
153
if : ${{ startsWith(github.ref, 'refs/tags') }}
@@ -138,17 +166,16 @@ jobs:
138
166
type=edge
139
167
type=ref,event=pr
140
168
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
144
170
uses : docker/build-push-action@v3
145
171
with :
146
172
file : build/Dockerfile
147
173
context : ' .'
148
- target : local
174
+ target : goreleaser
149
175
tags : ${{ steps.meta.outputs.tags }}
150
176
load : ${{ !startsWith(github.ref, 'refs/tags') }}
151
177
push : ${{ startsWith(github.ref, 'refs/tags') }}
178
+ platforms : ${{ startsWith(github.ref, 'refs/tags') && env.platforms || '' }}
152
179
cache-from : type=gha
153
180
cache-to : type=gha,mode=max
154
181
build-args : |
0 commit comments