Skip to content

Commit 0a0582f

Browse files
shaun-nxciarams87
authored andcommitted
Add Operator image build and publish to the pipeline (#3980)
1 parent 45ae002 commit 0a0582f

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ jobs:
120120
name=ghcr.io/${{ github.repository_owner }}/nginx-gateway-fabric/nginx,enable=${{ inputs.image == 'nginx' && github.event_name != 'pull_request' }}
121121
name=docker-mgmt.nginx.com/nginx-gateway-fabric/nginx-plus,enable=${{ inputs.image == 'plus' && github.event_name != 'pull_request' }}
122122
name=us-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/nginx-gateway-fabric/nginx-plus,enable=${{ inputs.image == 'plus' && github.event_name != 'pull_request' }}
123+
name=ghcr.io/${{ github.repository_owner }}/nginx-gateway-fabric/operator,enable=${{ inputs.image == 'operator' && github.event_name != 'pull_request' }}
123124
name=localhost:5000/nginx-gateway-fabric/${{ inputs.image }}
124125
flavor: |
125126
latest=${{ (inputs.tag != '' && 'true') || 'auto' }}
@@ -147,7 +148,7 @@ jobs:
147148
- name: Build Docker Image
148149
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
149150
with:
150-
file: ${{ inputs.build-os != '' && format('build/{0}/Dockerfile{1}', inputs.build-os, inputs.image == 'nginx' && '.nginx' || inputs.image == 'plus' && '.nginxplus' || '') || format('build/Dockerfile{0}', inputs.image == 'nginx' && '.nginx' || inputs.image == 'plus' && '.nginxplus' || '') }}
151+
file: ${{ inputs.image == 'operator' && 'operators/Dockerfile' || (inputs.build-os != '' && format('build/{0}/Dockerfile{1}', inputs.build-os, inputs.image == 'nginx' && '.nginx' || inputs.image == 'plus' && '.nginxplus' || '') || format('build/Dockerfile{0}', inputs.image == 'nginx' && '.nginx' || inputs.image == 'plus' && '.nginxplus' || '')) }}
151152
context: "."
152153
target: ${{ inputs.image == 'ngf' && 'goreleaser' || '' }}
153154
tags: ${{ steps.meta.outputs.tags }}

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ on:
2020
required: false
2121
type: string
2222
default: ''
23+
operator_version:
24+
required: false
25+
type: string
26+
default: ''
2327
dry_run:
2428
required: false
2529
type: boolean
@@ -388,6 +392,23 @@ jobs:
388392
id-token: write # for docker/login to login to NGINX registry
389393
secrets: inherit
390394

395+
build-operator:
396+
name: Build Operator images
397+
needs: [vars, binary]
398+
uses: ./.github/workflows/build.yml
399+
with:
400+
image: operator
401+
platforms: "linux/arm64, linux/amd64"
402+
tag: ${{ inputs.operator_version || '' }}
403+
dry_run: ${{ inputs.dry_run || false }}
404+
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' }}
405+
permissions:
406+
contents: read # for docker/build-push-action to read repo content
407+
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
408+
packages: write # for docker/build-push-action to push to GHCR
409+
id-token: write # for docker/login to login to NGINX registry
410+
secrets: inherit
411+
391412
functional-tests:
392413
name: Functional tests
393414
needs: [vars, build-oss, build-plus]

.github/workflows/production-release.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
description: 'Release version (e.g., v2.0.3)'
88
required: true
99
type: string
10+
operator-version:
11+
description: 'Operator release version (e.g., v1.0.0). Optional'
12+
required: false
13+
type: string
14+
default: ''
1015
dry_run:
1116
description: 'If true, does a dry run of the production workflow'
1217
required: false
@@ -33,6 +38,7 @@ jobs:
3338
echo "Validating release from: ${GITHUB_REF}"
3439
3540
INPUT_VERSION="${{ github.event.inputs.version }}"
41+
INPUT_OPERATOR_VERSION="${{ github.event.inputs.operator-version }}"
3642
3743
# Validate version format
3844
if [[ ! "${INPUT_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
@@ -41,8 +47,17 @@ jobs:
4147
exit 1
4248
fi
4349
50+
# Validate version format if operator version is provided
51+
if [[ -n "${INPUT_OPERATOR_VERSION}" && ! "${INPUT_OPERATOR_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
52+
echo "❌ Invalid operator version format: ${INPUT_OPERATOR_VERSION}"
53+
echo "Expected format: v1.2.3"
54+
exit 1
55+
fi
56+
57+
4458
echo "✅ Valid release branch: ${GITHUB_REF}"
4559
echo "✅ Valid version format: ${INPUT_VERSION}"
60+
[[ -n "${INPUT_OPERATOR_VERSION}" ]] && echo "✅ Valid operator version format: ${INPUT_OPERATOR_VERSION}"
4661
4762
- name: Checkout Repository
4863
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -62,7 +77,7 @@ jobs:
6277
git tag -a "${VERSION}" -m "Release ${VERSION}"
6378
6479
if [[ "${{ inputs.dry_run }}" == "true" ]]; then
65-
echo "DRY RUN: Would push tag ${VERSION}"
80+
echo "DRY RUN: Would push tag ${VERSION} and operator tag ${{ github.event.inputs.operator-version || '' }}"
6681
git push --dry-run origin "${VERSION}"
6782
else
6883
git push origin "${VERSION}"
@@ -76,6 +91,7 @@ jobs:
7691
with:
7792
is_production_release: true
7893
release_version: ${{ github.event.inputs.version }}
94+
operator_version: ${{ github.event.inputs.operator-version }}
7995
dry_run: ${{ github.event.inputs.dry_run }}
8096
secrets: inherit
8197
permissions:

docs/developer/release-process.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ To create a new release, follow these steps:
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.
6060
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`
6162
As a result, the CI/CD pipeline will:
6263
- Create and push the tag
6364
- 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)