Skip to content

Commit 64dda4c

Browse files
authored
Update release step to use GitHub Action (#699)
Replaces the release scripts with lucacome/draft-release
1 parent 5aea284 commit 64dda4c

File tree

2 files changed

+37
-168
lines changed

2 files changed

+37
-168
lines changed

.github/workflows/ci.yml

+37-39
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- main
77
- release-*
88
tags:
9-
- 'v[0-9]+.[0-9]+.[0-9]+*'
9+
- "v[0-9]+.[0-9]+.[0-9]+*"
1010
pull_request:
1111
branches:
1212
- main
@@ -28,7 +28,6 @@ env:
2828
platforms: "linux/arm64, linux/amd64"
2929

3030
jobs:
31-
3231
vars:
3332
name: Checks and variables
3433
runs-on: ubuntu-20.04
@@ -45,12 +44,10 @@ jobs:
4544

4645
- name: Output Variables
4746
id: vars
48-
run: |
49-
echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT
47+
run: echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT
5048

5149
- name: Check if go.mod and go.sum are up to date
52-
run: |
53-
go mod tidy && git diff --exit-code -- go.mod go.sum
50+
run: go mod tidy && git diff --exit-code -- go.mod go.sum
5451

5552
unit-tests:
5653
name: Unit Tests
@@ -88,6 +85,26 @@ jobs:
8885
node-version: 18
8986
- run: npm --prefix ${{ github.workspace }}/internal/nginx/modules install-ci-test
9087

88+
release:
89+
name: Release
90+
runs-on: ubuntu-20.04
91+
needs: [unit-tests, njs-unit-tests]
92+
if: ${{ github.event_name == 'push' && github.ref != 'refs/heads/main' }}
93+
steps:
94+
- name: Checkout Repository
95+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
96+
97+
- name: Create/Update Draft
98+
uses: lucacome/draft-release@b79be3ff634f771230b2b6ee9f47308c5793671a # v0.2.0
99+
with:
100+
minor-label: "enhancement"
101+
major-label: "change"
102+
publish: ${{ startsWith(github.ref, 'refs/tags/') }}
103+
collapse-after: 20
104+
notes-header: |
105+
*Below is the auto-generated changelog, which includes all PRs that went into the release.
106+
For a shorter version that highlights only important changes, see [CHANGELOG.md](https://github.com/nginxinc/nginx-kubernetes-gateway/blob/{{version}}/CHANGELOG.md).*
107+
91108
binary:
92109
name: Build Binary
93110
runs-on: ubuntu-20.04
@@ -103,32 +120,6 @@ jobs:
103120
with:
104121
go-version-file: go.mod
105122

106-
- name: Publish release on tag
107-
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
108-
continue-on-error: true
109-
with:
110-
github-token: ${{secrets.GITHUB_TOKEN}}
111-
script: |
112-
const ref = context.ref.split("/")[2]
113-
114-
const releases = (await github.rest.repos.listReleases({
115-
owner: context.payload.repository.owner.login,
116-
repo: context.payload.repository.name,
117-
per_page: 100,
118-
})).data
119-
120-
const draft_release = releases.find(release => release.draft && release.tag_name === ref)
121-
122-
const update = await github.rest.repos.updateRelease({
123-
owner: context.payload.repository.owner.login,
124-
repo: context.payload.repository.name,
125-
release_id: draft_release.id,
126-
draft: false
127-
});
128-
console.log(`Release published: ${update.data.html_url}`)
129-
console.log(`Release notes: ${update.data.body}`)
130-
if: startsWith(github.ref, 'refs/tags/')
131-
132123
- name: Download Syft
133124
uses: anchore/sbom-action/download-syft@4d571ad1038a9cc29d676154ef265ab8f9027042 # v0.14.2
134125
if: startsWith(github.ref, 'refs/tags/')
@@ -158,24 +149,29 @@ jobs:
158149
steps:
159150
- name: Checkout Repository
160151
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
152+
161153
- name: Fetch Cached Artifacts
162154
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
163155
with:
164156
path: ${{ github.workspace }}/dist
165157
key: nginx-kubernetes-gateway-${{ github.run_id }}-${{ github.run_number }}
158+
166159
- name: Docker Buildx
167160
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2.5.0
161+
168162
- name: Setup QEMU
169163
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0
170164
with:
171165
platforms: arm64
166+
172167
- name: Login to GitHub Container Registry
173168
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
174169
if: ${{ github.event_name != 'pull_request' }}
175170
with:
176171
registry: ghcr.io
177172
username: ${{ github.repository_owner }}
178173
password: ${{ secrets.GITHUB_TOKEN }}
174+
179175
- name: Docker meta
180176
id: meta
181177
uses: docker/metadata-action@c4ee3adeed93b1fa6a762f209fb01608c1a22f1e # v4.4.0
@@ -192,7 +188,7 @@ jobs:
192188
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
193189
with:
194190
file: build/Dockerfile
195-
context: '.'
191+
context: "."
196192
target: goreleaser
197193
tags: ${{ steps.meta.outputs.tags }}
198194
labels: ${{ steps.meta.outputs.labels }}
@@ -209,18 +205,20 @@ jobs:
209205
continue-on-error: true
210206
with:
211207
image-ref: ghcr.io/nginxinc/nginx-kubernetes-gateway:${{ steps.meta.outputs.version }}
212-
format: 'sarif'
213-
output: 'trivy-results-nginx-kubernetes-gateway.sarif'
214-
ignore-unfixed: 'true'
208+
format: "sarif"
209+
output: "trivy-results-nginx-kubernetes-gateway.sarif"
210+
ignore-unfixed: "true"
211+
215212
- name: Upload Trivy scan results to GitHub Security tab
216213
uses: github/codeql-action/upload-sarif@0225834cc549ee0ca93cb085b92954821a145866 # v2.3.5
217214
continue-on-error: true
218215
with:
219-
sarif_file: 'trivy-results-nginx-kubernetes-gateway.sarif'
216+
sarif_file: "trivy-results-nginx-kubernetes-gateway.sarif"
217+
220218
- name: Upload Scan Results
221219
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
222220
continue-on-error: true
223221
with:
224-
name: 'trivy-results-nginx-kubernetes-gateway.sarif'
225-
path: 'trivy-results-nginx-kubernetes-gateway.sarif'
222+
name: "trivy-results-nginx-kubernetes-gateway.sarif"
223+
path: "trivy-results-nginx-kubernetes-gateway.sarif"
226224
if: always()

.github/workflows/release.yaml

-129
This file was deleted.

0 commit comments

Comments
 (0)