55 branches :
66 - main
77 - release-*
8- tags :
9- - " v[0-9]+.[0-9]+.[0-9]+*"
108 pull_request :
119 branches :
1210 - " **"
1311 schedule :
1412 - 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
1527
1628defaults :
1729 run :
1830 shell : bash
1931
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+
2035concurrency :
2136 group : ${{ github.ref_name }}-ci
2237 cancel-in-progress : true
@@ -127,7 +142,7 @@ jobs:
127142
128143 binary :
129144 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' }}
131146 needs : [vars, unit-tests, njs-unit-tests]
132147 permissions :
133148 contents : write # for goreleaser/goreleaser-action and lucacome/draft-release to create/update releases
@@ -147,31 +162,37 @@ jobs:
147162 go.sum
148163 .github/.cache/buster-for-binary
149164
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+
150171 - name : Create/Update Draft
151172 uses : lucacome/draft-release@00f74370c044c322da6cb52acc707d62c7762c71 # v1.2.4
152173 with :
153174 minor-label : " enhancement"
154175 major-label : " change"
155- publish : ${{ github.ref_type == 'tag' }}
176+ publish : ${{ inputs.is_production_release && (inputs.dry_run == false || inputs.dry_run == null) }}
156177 collapse-after : 20
157178 notes-header : |
158179 *Below is the auto-generated changelog, which includes all PRs that went into the release.
159180 For a shorter version that highlights only important changes, see [CHANGELOG.md](https://github.com/nginx/nginx-gateway-fabric/blob/{{version}}/CHANGELOG.md).*
160181 if : ${{ github.event_name == 'push' && github.ref != 'refs/heads/main' }}
161182
162183 - name : Download Syft
184+ if : ${{ inputs.is_production_release }}
163185 uses : anchore/sbom-action/download-syft@da167eac915b4e86f08b264dbdbc867b61be6f0c # v0.20.5
164- if : github.ref_type == 'tag'
165186
166187 - name : Install Cosign
188+ if : ${{ inputs.is_production_release }}
167189 uses : sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
168- if : github.ref_type == 'tag'
169190
170191 - name : Build binary
171192 uses : goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
172193 with :
173194 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
175196 env :
176197 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
177198 GOPATH : ${{ needs.vars.outputs.go_path }}
@@ -200,6 +221,9 @@ jobs:
200221 with :
201222 image : ${{ matrix.image }}
202223 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' }}
203227 permissions :
204228 contents : read # for docker/build-push-action to read repo content
205229 security-events : write # for github/codeql-action/upload-sarif to upload SARIF results
@@ -214,6 +238,9 @@ jobs:
214238 with :
215239 image : plus
216240 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' }}
217244 permissions :
218245 contents : read # for docker/build-push-action to read repo content
219246 security-events : write # for github/codeql-action/upload-sarif to upload SARIF results
@@ -259,6 +286,8 @@ jobs:
259286 image : ${{ matrix.image }}
260287 k8s-version : ${{ matrix.k8s-version }}
261288 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 }}
262291 secrets : inherit
263292 permissions :
264293 contents : write
@@ -284,9 +313,9 @@ jobs:
284313
285314 publish-helm :
286315 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' }}
288317 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-') ) }}
290319 permissions :
291320 contents : read
292321 packages : write # for helm to push to GHCR
@@ -304,10 +333,11 @@ jobs:
304333 - name : Package
305334 id : package
306335 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)
308337 echo "path=$(basename -- $(echo $output | cut -d: -f2))" >> $GITHUB_OUTPUT
309338
310339 - name : Push to GitHub Container Registry
340+ if : ${{ inputs.dry_run == false || inputs.dry_run == null }}
311341 run : |
312342 helm push ${{ steps.package.outputs.path }} oci://ghcr.io/nginx/charts
313343
0 commit comments