5
5
branches :
6
6
- main
7
7
- release-*
8
- tags :
9
- - " v[0-9]+.[0-9]+.[0-9]+*"
10
8
pull_request :
11
9
branches :
12
10
- " **"
13
11
schedule :
14
12
- cron : " 0 4 * * *" # run every day at 4am UTC
13
+ workflow_call :
14
+ inputs :
15
+ is_production_release :
16
+ required : false
17
+ type : boolean
18
+ default : false
19
+ release_version :
20
+ required : false
21
+ type : string
22
+ default : ' '
23
+ dry_run :
24
+ required : false
25
+ type : boolean
26
+ default : false
15
27
16
28
defaults :
17
29
run :
18
30
shell : bash
19
31
32
+ env :
33
+ GOPROXY : ${{ (github.repository_owner == 'nginx' && (inputs.is_production_release || github.event_name == 'push' && github.ref == 'refs/heads/main') && format('https://{0}:{1}@{2}', secrets.ARTIFACTORY_USER, secrets.ARTIFACTORY_TOKEN, secrets.ARTIFACTORY_ENDPOINT)) || (github.repository_owner == 'nginx' && format('https://{0}:{1}@{2}', secrets.ARTIFACTORY_USER, secrets.ARTIFACTORY_TOKEN, secrets.ARTIFACTORY_DEV_ENDPOINT) || 'direct') }}
34
+
20
35
concurrency :
21
36
group : ${{ github.ref_name }}-ci
22
37
cancel-in-progress : true
@@ -127,7 +142,7 @@ jobs:
127
142
128
143
binary :
129
144
name : Build Binary
130
- runs-on : ubuntu-24.04
145
+ runs-on : ${{ github.repository_owner == 'nginx' && (inputs.is_production_release || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && ' ubuntu-24.04-amd64' || 'ubuntu-24.04' }}
131
146
needs : [vars, unit-tests, njs-unit-tests]
132
147
permissions :
133
148
contents : write # for goreleaser/goreleaser-action and lucacome/draft-release to create/update releases
@@ -147,31 +162,37 @@ jobs:
147
162
go.sum
148
163
.github/.cache/buster-for-binary
149
164
165
+ - name : Set Go module cache
166
+ run : |
167
+ mkdir -p ${{ github.workspace }}/.gocache
168
+ echo "GOMODCACHE=${{ github.workspace }}/.gocache" >> $GITHUB_ENV
169
+ echo "GOCACHE=${{ github.workspace }}/.gocache" >> $GITHUB_ENV
170
+
150
171
- name : Create/Update Draft
151
172
uses : lucacome/draft-release@00f74370c044c322da6cb52acc707d62c7762c71 # v1.2.4
152
173
with :
153
174
minor-label : " enhancement"
154
175
major-label : " change"
155
- publish : ${{ github.ref_type == 'tag' }}
176
+ publish : ${{ inputs.is_production_release && (inputs.dry_run == false || inputs.dry_run == null) }}
156
177
collapse-after : 20
157
178
notes-header : |
158
179
*Below is the auto-generated changelog, which includes all PRs that went into the release.
159
180
For a shorter version that highlights only important changes, see [CHANGELOG.md](https://github.com/nginx/nginx-gateway-fabric/blob/{{version}}/CHANGELOG.md).*
160
181
if : ${{ github.event_name == 'push' && github.ref != 'refs/heads/main' }}
161
182
162
183
- name : Download Syft
184
+ if : ${{ inputs.is_production_release }}
163
185
uses : anchore/sbom-action/download-syft@da167eac915b4e86f08b264dbdbc867b61be6f0c # v0.20.5
164
- if : github.ref_type == 'tag'
165
186
166
187
- name : Install Cosign
188
+ if : ${{ inputs.is_production_release }}
167
189
uses : sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
168
- if : github.ref_type == 'tag'
169
190
170
191
- name : Build binary
171
192
uses : goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
172
193
with :
173
194
version : v2.12.0 # renovate: datasource=github-tags depName=goreleaser/goreleaser
174
- args : ${{ github.ref_type == 'tag' && 'release' || 'build --snapshot' }} --clean
195
+ args : ${{ (inputs.is_production_release && (inputs.dry_run == false || inputs.dry_run == null)) && 'release' || 'build --snapshot' }} --clean
175
196
env :
176
197
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
177
198
GOPATH : ${{ needs.vars.outputs.go_path }}
@@ -200,6 +221,9 @@ jobs:
200
221
with :
201
222
image : ${{ matrix.image }}
202
223
platforms : ${{ matrix.platforms }}
224
+ tag : ${{ inputs.release_version || '' }}
225
+ dry_run : ${{ inputs.dry_run || false}}
226
+ runner : ${{ github.repository_owner == 'nginx' && (inputs.is_production_release || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && 'ubuntu-24.04-amd64' || 'ubuntu-24.04' }}
203
227
permissions :
204
228
contents : read # for docker/build-push-action to read repo content
205
229
security-events : write # for github/codeql-action/upload-sarif to upload SARIF results
@@ -214,6 +238,9 @@ jobs:
214
238
with :
215
239
image : plus
216
240
platforms : " linux/arm64, linux/amd64"
241
+ tag : ${{ inputs.release_version || '' }}
242
+ dry_run : ${{ inputs.dry_run || false }}
243
+ runner : ${{ github.repository_owner == 'nginx' && (inputs.is_production_release || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && 'ubuntu-24.04-amd64' || 'ubuntu-24.04' }}
217
244
permissions :
218
245
contents : read # for docker/build-push-action to read repo content
219
246
security-events : write # for github/codeql-action/upload-sarif to upload SARIF results
@@ -259,6 +286,8 @@ jobs:
259
286
image : ${{ matrix.image }}
260
287
k8s-version : ${{ matrix.k8s-version }}
261
288
enable-experimental : ${{ matrix.enable-experimental }}
289
+ production-release : ${{ inputs.is_production_release == true && (inputs.dry_run == false || inputs.dry_run == null) }}
290
+ release_version : ${{ inputs.release_version }}
262
291
secrets : inherit
263
292
permissions :
264
293
contents : write
@@ -284,9 +313,9 @@ jobs:
284
313
285
314
publish-helm :
286
315
name : Package and Publish Helm Chart
287
- runs-on : ubuntu-24.04
316
+ runs-on : ${{ github.repository_owner == 'nginx' && (inputs.is_production_release || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && ' ubuntu-24.04-amd64' || 'ubuntu-24.04' }}
288
317
needs : [vars, helm-tests]
289
- if : ${{ github.event_name == 'push' && ! startsWith(github.ref, 'refs/heads/release-') }}
318
+ if : ${{ (inputs.is_production_release && (inputs.dry_run == false || inputs.dry_run == null)) || ( github.event_name == 'push' && ! startsWith(github.ref, 'refs/heads/release-') ) }}
290
319
permissions :
291
320
contents : read
292
321
packages : write # for helm to push to GHCR
@@ -304,10 +333,11 @@ jobs:
304
333
- name : Package
305
334
id : package
306
335
run : |
307
- output=$(helm package ${{ github.ref_type != 'tag' && '--app-version edge --version 0.0.0-edge' || '' }} charts/nginx-gateway-fabric)
336
+ output=$(helm package ${{ !inputs.is_production_release && '--app-version edge --version 0.0.0-edge' || '' }} charts/nginx-gateway-fabric)
308
337
echo "path=$(basename -- $(echo $output | cut -d: -f2))" >> $GITHUB_OUTPUT
309
338
310
339
- name : Push to GitHub Container Registry
340
+ if : ${{ inputs.dry_run == false || inputs.dry_run == null }}
311
341
run : |
312
342
helm push ${{ steps.package.outputs.path }} oci://ghcr.io/nginx/charts
313
343
0 commit comments