Skip to content

Commit 911a771

Browse files
authored
Update CI (#3836)
1 parent 3bb019a commit 911a771

File tree

5 files changed

+64
-133
lines changed

5 files changed

+64
-133
lines changed

.github/workflows/build-oss.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0
4646
with:
4747
platforms: arm,arm64,ppc64le,s390x
48-
if: github.event_name != 'pull_request'
48+
if: ${{ github.event_name != 'pull_request' && ! startsWith(github.ref, 'refs/heads/release-') }}
4949

5050
- name: Docker Buildx
5151
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2.5.0
@@ -55,36 +55,36 @@ jobs:
5555
with:
5656
username: ${{ secrets.DOCKER_USERNAME }}
5757
password: ${{ secrets.DOCKER_PASSWORD }}
58-
if: github.event_name != 'pull_request'
58+
if: ${{ github.event_name != 'pull_request' && ! startsWith(github.ref, 'refs/heads/release-') }}
5959

6060
- name: Login to GitHub Container Registry
6161
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
6262
with:
6363
registry: ghcr.io
6464
username: ${{ github.repository_owner }}
6565
password: ${{ secrets.GITHUB_TOKEN }}
66-
if: github.event_name != 'pull_request'
66+
if: ${{ github.event_name != 'pull_request' && ! startsWith(github.ref, 'refs/heads/release-') }}
6767

6868
- name: Configure AWS Credentials
6969
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
7070
with:
7171
aws-region: us-east-1
7272
role-to-assume: ${{ secrets.AWS_ROLE_PUBLIC_ECR }}
73-
if: github.event_name != 'pull_request'
73+
if: ${{ github.event_name != 'pull_request' && ! startsWith(github.ref, 'refs/heads/release-') }}
7474

7575
- name: Login to Public ECR
7676
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
7777
with:
7878
registry: public.ecr.aws
79-
if: github.event_name != 'pull_request'
79+
if: ${{ github.event_name != 'pull_request' && ! startsWith(github.ref, 'refs/heads/release-') }}
8080

8181
- name: Login to Quay.io
8282
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
8383
with:
8484
registry: quay.io
8585
username: ${{ secrets.QUAY_USERNAME }}
8686
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
87-
if: github.event_name != 'pull_request'
87+
if: ${{ github.event_name != 'pull_request' && ! startsWith(github.ref, 'refs/heads/release-') }}
8888

8989
- name: Get short tag
9090
id: tag
@@ -136,16 +136,16 @@ jobs:
136136
target: goreleaser
137137
tags: ${{ steps.meta.outputs.tags }}
138138
labels: ${{ steps.meta.outputs.labels }}
139-
platforms: ${{ github.event_name != 'pull_request' && inputs.platforms || '' }}
140-
load: ${{ github.event_name == 'pull_request' }}
141-
push: ${{ github.event_name != 'pull_request' }}
139+
platforms: ${{ github.event_name != 'pull_request' && ! startsWith(github.ref, 'refs/heads/release-') && inputs.platforms || '' }}
140+
load: ${{ github.event_name == 'pull_request' || startsWith(github.ref, 'refs/heads/release-') }}
141+
push: ${{ github.event_name != 'pull_request' && ! startsWith(github.ref, 'refs/heads/release-') }}
142142
pull: true
143-
no-cache: ${{ github.event_name != 'pull_request' }}
144-
sbom: ${{ github.event_name != 'pull_request' }}
143+
no-cache: ${{ github.event_name != 'pull_request' && ! startsWith(github.ref, 'refs/heads/release-') }}
144+
sbom: ${{ github.event_name != 'pull_request' && ! startsWith(github.ref, 'refs/heads/release-') }}
145145
provenance: false
146146
build-args: |
147147
BUILD_OS=${{ inputs.image }}
148-
IC_VERSION=${{ github.event_name == 'pull_request' && 'CI' || steps.meta.outputs.version }}
148+
IC_VERSION=${{ (github.event_name == 'pull_request' || startsWith(github.ref, 'refs/heads/release-')) && 'CI' || steps.meta.outputs.version }}
149149
150150
- name: Run Trivy vulnerability scanner
151151
uses: aquasecurity/trivy-action@e5f43133f6e8736992c9f3c1b3296e24b37e17f2 # 0.10.0

.github/workflows/build-plus.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ jobs:
9595
tags: |
9696
type=edge
9797
type=ref,event=pr
98+
type=ref,event=branch,enable=${{ startsWith(github.ref, 'refs/heads/release-') }}
9899
type=schedule,pattern={{date 'YYYYMMDD'}}
99100
type=semver,pattern={{version}}
100101
labels: |

.github/workflows/ci.yml

Lines changed: 51 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- release-*
78
tags:
89
- 'v[0-9]+.[0-9]+.[0-9]+'
910
pull_request:
@@ -31,28 +32,31 @@ jobs:
3132
name: Checks and variables
3233
runs-on: ubuntu-22.04
3334
outputs:
34-
go_path: ${{ steps.go.outputs.go_path }}
35+
go_path: ${{ steps.vars.outputs.go_path }}
3536
k8s_latest: ${{ steps.vars.outputs.k8s_latest }}
37+
chart_version: ${{ steps.vars.outputs.chart_version }}
3638
steps:
3739
- name: Checkout Repository
3840
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
39-
- name: Output Variables
40-
id: vars
41-
run: |
42-
echo "k8s_latest=$(grep -m1 'FROM kindest/node' <tests/docker/Dockerfile | awk -F'[:v]' '{print $3}')" >> $GITHUB_OUTPUT
41+
4342
- name: Setup Golang Environment
4443
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
4544
with:
4645
go-version-file: go.mod
47-
- name: Determine GOPATH
48-
id: go
49-
run: echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT
50-
- name: Check if go.mod and go.sum are up to date
46+
47+
- name: Output Variables
48+
id: vars
5149
run: |
52-
go mod tidy && git diff --exit-code -- go.mod go.sum
50+
echo "k8s_latest=$(grep -m1 'FROM kindest/node' <tests/docker/Dockerfile | awk -F'[:v]' '{print $3}')" >> $GITHUB_OUTPUT
51+
echo "chart_version=$(yq '.version' <deployments/helm-chart/Chart.yaml)" >> $GITHUB_OUTPUT
52+
echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT
53+
54+
- name: Check if go.mod and go.sum are up to date
55+
run: go mod tidy && git diff --exit-code -- go.mod go.sum
56+
5357
- name: Check if CRDs changed
54-
run: |
55-
make update-crds && git diff --name-only --exit-code deployments/common/crds* deployments/helm-chart/crds*
58+
run: make update-crds && git diff --name-only --exit-code deployments/common/crds* deployments/helm-chart/crds*
59+
5660
- name: Check if Codegen changed
5761
run: |
5862
cd ../.. && mkdir -p github.com/nginxinc && mv kubernetes-ingress/kubernetes-ingress github.com/nginxinc/ && cd github.com/nginxinc/kubernetes-ingress
@@ -78,10 +82,33 @@ jobs:
7882
files: ./coverage.txt
7983

8084
release:
81-
name: Release
82-
if: startsWith(github.ref, 'refs/tags/')
83-
uses: ./.github/workflows/release.yml
84-
secrets: inherit
85+
runs-on: ubuntu-22.04
86+
needs: [checks, unit-tests]
87+
if: ${{ github.event_name == 'push' && ! github.ref != 'refs/heads/main' }}
88+
steps:
89+
- name: Checkout Repository
90+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
91+
92+
- name: Create/Update Draft
93+
uses: lucacome/draft-release@b79be3ff634f771230b2b6ee9f47308c5793671a # v0.2.0
94+
with:
95+
minor-label: 'enhancement'
96+
major-label: 'change'
97+
publish: ${{ startsWith(github.ref, 'refs/tags/') }}
98+
collapse-after: 50
99+
variables: |
100+
helm-chart=${{ needs.checks.outputs.chart_version }}
101+
notes-footer: |
102+
## Upgrade
103+
- For NGINX, use the {{version}} image from our [DockerHub](https://hub.docker.com/r/nginx/nginx-ingress/tags?page=1&ordering=last_updated&name={{version-number}}), [GitHub Container](https://github.com/nginxinc/kubernetes-ingress/pkgs/container/kubernetes-ingress), [Amazon ECR Public Gallery](https://gallery.ecr.aws/nginx/nginx-ingress) or [Quay.io](https://quay.io/repository/nginx/nginx-ingress).
104+
- For NGINX Plus, use the {{version}} image from the F5 Container registry or the [AWS Marketplace](https://aws.amazon.com/marketplace/search/?CREATOR=741df81b-dfdc-4d36-b8da-945ea66b522c&FULFILLMENT_OPTION_TYPE=CONTAINER&filters=CREATOR%2CFULFILLMENT_OPTION_TYPE) or build your own image using the {{version}} source code.
105+
- For Helm, use version {{helm-chart}} of the chart.
106+
107+
## Resources
108+
- Documentation -- https://docs.nginx.com/nginx-ingress-controller/
109+
- Configuration examples -- https://github.com/nginxinc/kubernetes-ingress/tree/{{version}}/examples
110+
- Helm Chart -- https://github.com/nginxinc/kubernetes-ingress/tree/{{version}}/deployments/helm-chart
111+
- Operator -- https://github.com/nginxinc/nginx-ingress-operator/
85112
86113
binaries:
87114
name: Build Binaries
@@ -106,7 +133,7 @@ jobs:
106133
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0
107134
with:
108135
version: latest
109-
args: ${{ startsWith(github.ref, 'refs/tags/') && 'release' || 'build --snapshot' }} ${{ github.event_name == 'pull_request' && '--single-target' || '' }} --rm-dist
136+
args: ${{ startsWith(github.ref, 'refs/tags/') && 'release' || 'build --snapshot' }} ${{ github.event_name == 'pull_request' && '--single-target' || '' }} --clean
110137
env:
111138
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112139
GOPATH: ${{ needs.checks.outputs.go_path }}
@@ -210,7 +237,6 @@ jobs:
210237
name: Setup Matrix for Smoke Tests
211238
runs-on: ubuntu-22.04
212239
needs: [checks, binaries]
213-
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
214240
outputs:
215241
matrix: ${{ steps.set-matrix.outputs.matrix }}
216242
steps:
@@ -336,8 +362,8 @@ jobs:
336362
publish-helm:
337363
name: Package and Publish Helm Chart
338364
runs-on: ubuntu-22.04
339-
needs: helm-tests
340-
if: ${{ github.event_name == 'push' }}
365+
needs: [checks, helm-tests]
366+
if: ${{ github.event_name == 'push' && ! startsWith(github.ref, 'refs/heads/release-') }}
341367
steps:
342368
- name: Checkout Repository
343369
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
@@ -375,22 +401,15 @@ jobs:
375401
fetch-depth: 1
376402
token: ${{ secrets.NGINX_PAT }}
377403
path: helm-charts
378-
379-
- name: Get Chart type
380-
id: package-helm
381-
run: |
382-
echo "type=${{ contains(steps.package.outputs.path, 'edge') && 'edge' || 'stable' }}" >> $GITHUB_OUTPUT
383-
384-
- name: Remove previous Chart
385-
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
386-
run: rm -f ${{ github.workspace }}/helm-charts/edge/nginx-ingress-0.0.0-edge.tgz
404+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
387405

388406
- name: Push Helm Chart to Helm Charts Repository
389407
run: |
390-
mv ${{ steps.package.outputs.path }} ${{ github.workspace }}/helm-charts/${{ steps.package-helm.outputs.type }}/
408+
mv ${{ steps.package.outputs.path }} ${{ github.workspace }}/helm-charts/stable/
391409
cd ${{ github.workspace }}/helm-charts
392-
helm repo index ${{ steps.package-helm.outputs.type }} --url https://helm.nginx.com/${{ steps.package-helm.outputs.type }}
410+
helm repo index stable --url https://helm.nginx.com/stable
393411
git add -A
394412
git -c user.name='NGINX Kubernetes Team' -c user.email='[email protected]' \
395-
commit -m "NGINX Ingress Controller - Release ${{ steps.package-helm.outputs.type }} ${{ steps.package-helm.outputs.version }}"
413+
commit -m "NGINX Ingress Controller - Release ${{ needs.checks.outputs.chart_version }}"
396414
git push -u origin master
415+
if: ${{ startsWith(github.ref, 'refs/tags/') }}

.github/workflows/draft-release.yaml

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

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)