Skip to content

Commit 44debfa

Browse files
authored
Move release logic to CI (#4137)
* Move release logic to CI
1 parent 7459f78 commit 44debfa

File tree

5 files changed

+74
-113
lines changed

5 files changed

+74
-113
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,11 @@ jobs:
125125
flavor: |
126126
latest=${{ (inputs.tag != '' && 'true') || 'auto' }}
127127
tags: |
128-
type=semver,pattern={{version}},suffix=${{ inputs.build-os != '' && format('-{0}', inputs.build-os) || '' }}
128+
type=semver,pattern={{version}},value=${{ inputs.tag }},enable=${{ inputs.tag != '' }},suffix=${{ inputs.build-os != '' && format('-{0}', inputs.build-os) || '' }}
129129
type=edge,suffix=${{ inputs.build-os != '' && format('-{0}', inputs.build-os) || '' }}
130130
type=schedule,suffix=${{ inputs.build-os != '' && format('-{0}', inputs.build-os) || '' }}
131131
type=ref,event=pr,suffix=${{ inputs.build-os != '' && format('-{0}', inputs.build-os) || '' }}
132132
type=ref,event=branch,suffix=-rc${{ inputs.build-os != '' && format('-{0}', inputs.build-os) || '' }},enable=${{ startsWith(github.ref, 'refs/heads/release') && inputs.tag == '' }}
133-
type=raw,value=${{ inputs.tag }},enable=${{ inputs.tag != '' }},suffix=${{ inputs.build-os != '' && format('-{0}', inputs.build-os) || '' }}
134133
labels: |
135134
org.opencontainers.image.documentation=https://docs.nginx.com/nginx-gateway-fabric
136135
org.opencontainers.image.vendor=NGINX Inc <kubernetes@nginx.com>

.github/workflows/ci.yml

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,25 @@ on:
1010
- "**"
1111
schedule:
1212
- cron: "0 3 * * *" # run every day at 3am UTC (nightly builds)
13-
workflow_call:
13+
workflow_dispatch:
1414
inputs:
1515
is_production_release:
16+
description: 'Is this a production release?'
1617
required: false
1718
type: boolean
1819
default: false
1920
release_version:
21+
description: 'Release version (e.g., v2.0.3)'
2022
required: false
2123
type: string
2224
default: ''
2325
operator_version:
26+
description: 'Operator release version (e.g., v1.0.0). Optional'
2427
required: false
2528
type: string
2629
default: ''
2730
dry_run:
31+
description: 'If true, does a dry run of the production workflow'
2832
required: false
2933
type: boolean
3034
default: false
@@ -34,13 +38,70 @@ defaults:
3438
shell: bash
3539

3640
concurrency:
37-
group: ${{ github.ref_name }}-ci
38-
cancel-in-progress: true
41+
group: ${{ inputs.is_production_release && format('prod-{0}', inputs.release_version) || format('{0}-ci', github.ref_name) }}
42+
cancel-in-progress: ${{ !inputs.is_production_release }}
3943

4044
permissions:
4145
contents: read
4246

4347
jobs:
48+
create-tag-and-release:
49+
runs-on: ubuntu-24.04
50+
if: github.event_name == 'workflow_dispatch' && inputs.release_version != '' && startsWith(github.ref, 'refs/heads/release-')
51+
permissions:
52+
contents: write
53+
steps:
54+
- name: Validate Release Branch and Version
55+
run: |
56+
echo "Validating release from: ${GITHUB_REF}"
57+
58+
INPUT_VERSION="${{ inputs.release_version }}"
59+
INPUT_OPERATOR_VERSION="${{ inputs.operator_version }}"
60+
61+
# Validate version format
62+
if [[ ! "${INPUT_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
63+
echo "❌ Invalid version format: ${INPUT_VERSION}"
64+
echo "Expected format: v1.2.3"
65+
exit 1
66+
fi
67+
68+
# Validate version format if operator version is provided
69+
if [[ -n "${INPUT_OPERATOR_VERSION}" && ! "${INPUT_OPERATOR_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
70+
echo "❌ Invalid operator version format: ${INPUT_OPERATOR_VERSION}"
71+
echo "Expected format: v1.2.3"
72+
exit 1
73+
fi
74+
75+
echo "✅ Valid release branch: ${GITHUB_REF}"
76+
echo "✅ Valid version format: ${INPUT_VERSION}"
77+
[[ -n "${INPUT_OPERATOR_VERSION}" ]] && echo "✅ Valid operator version format: ${INPUT_OPERATOR_VERSION}"
78+
79+
- name: Checkout Repository
80+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
81+
with:
82+
fetch-depth: 0
83+
84+
- name: Create Release Tag
85+
run: |
86+
VERSION="${{ inputs.release_version }}"
87+
git config user.name "NGF Release Bot"
88+
git config user.email "integrations@nginx.com"
89+
90+
if git rev-parse --verify "refs/tags/${VERSION}" >/dev/null 2>&1; then
91+
echo "Tag ${VERSION} already exists - skipping tag creation"
92+
else
93+
echo "Creating annotated tag ${VERSION}"
94+
git tag -a "${VERSION}" -m "Release ${VERSION}"
95+
96+
if [[ "${{ inputs.dry_run }}" == "true" ]]; then
97+
echo "DRY RUN: Would push tag ${VERSION} and operator tag ${{ inputs.operator_version || '' }}"
98+
git push --dry-run origin "${VERSION}"
99+
else
100+
git push origin "${VERSION}"
101+
echo "Created and pushed tag: ${VERSION}"
102+
fi
103+
fi
104+
44105
vars:
45106
name: Checks and variables
46107
runs-on: ubuntu-24.04

.github/workflows/helm.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ jobs:
4444
images: |
4545
name=ghcr.io/nginx/nginx-gateway-fabric
4646
tags: |
47-
type=semver,pattern={{version}}
47+
type=semver,pattern={{version}},value=${{ inputs.tag }},enable=${{ inputs.tag != '' }}
4848
type=edge
4949
type=schedule
5050
type=ref,event=pr
5151
type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') && inputs.tag == '' }}
52-
type=raw,value=${{ inputs.tag }},enable=${{ inputs.tag != '' }}
5352
5453
- name: NGINX Docker meta
5554
id: nginx-meta
@@ -58,12 +57,11 @@ jobs:
5857
images: |
5958
name=ghcr.io/nginx/nginx-gateway-fabric/${{ inputs.image == 'plus' && 'nginx-plus' || inputs.image }}
6059
tags: |
61-
type=semver,pattern={{version}}
60+
type=semver,pattern={{version}},value=${{ inputs.tag }},enable=${{ inputs.tag != '' }}
6261
type=edge
6362
type=schedule
6463
type=ref,event=pr
6564
type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') && inputs.tag == '' }}
66-
type=raw,value=${{ inputs.tag }},enable=${{ inputs.tag != '' }}
6765
6866
- name: Build NGF Docker Image
6967
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0

.github/workflows/production-release.yml

Lines changed: 0 additions & 102 deletions
This file was deleted.

docs/developer/release-process.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@ To create a new release, follow these steps:
5757
created. If included, use the Release Notes specified in a PR.
5858
- If the supported Gateway API minor version has changed since the last release, add a note to the release notes explaining if the previous version is no longer supported.
5959
- Merge the release PR once it has received all necessary approvals.
60-
6. Once you are ready to release, run the [Production Release](https://github.com/nginx/nginx-gateway-fabric/actions/workflows/production-release.yml) workflow with the correct tag e.g. `v2.1.0`. (Note: It is also possible to do a dry run of the production release workflow for verification if required. This will not push the tag, images, and chart, and won't publish the release)
61-
If this release includes an updated release of our [Operator](https://github.com/nginx/nginx-gateway-fabric/tree/main/operators), include the new version as well e.g. `v1.0.1`
60+
6. Once you are ready to release, trigger a production release by running the [CI workflow](https://github.com/nginx/nginx-gateway-fabric/actions/workflows/ci.yml) with the following inputs:
61+
- Select the release branch (e.g., `release-2.2`)
62+
- Set `is_production_release` to `true` (checked)
63+
- Set `release_version` to the release tag (e.g., `v2.2.0`)
64+
- If this release includes an updated release of our [Operator](https://github.com/nginx/nginx-gateway-fabric/tree/main/operators), set `operator_version` to the new version (e.g., `v1.0.1`)
65+
- Set `dry_run` to `false` (unchecked) for a real release, or `true` for a dry run (Note: A dry run will not push the tag, images, and chart, and won't publish the release)
66+
6267
As a result, the CI/CD pipeline will:
6368
- Create and push the tag
6469
- Build NGF, NGINX and NGINX Plus container images with the release tag `X.Y.Z` and push them to the registries.

0 commit comments

Comments
 (0)