-
Notifications
You must be signed in to change notification settings - Fork 80
263 lines (231 loc) · 8.56 KB
/
release.yaml
File metadata and controls
263 lines (231 loc) · 8.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
name: Version-Checker Release
on:
push:
branches:
- "release-v*"
tags:
- "v*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
release-name:
name: Generate a clean release name from the branch/tag
runs-on: ubuntu-latest
outputs:
name: ${{ steps.release_number.outputs.substring }}
steps:
- uses: bhowell2/github-substring-action@1.0.2
id: release_number
with:
value: ${{github.ref_name}}
index_of_str: "release-"
prepare-release:
# Don't push back to a tag!
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
needs:
- release-name
name: Prepare release
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Find and Replace Helm Chart Version
uses: jacobtomlinson/gha-find-replace@v3
with:
find: 'v(\d+)\.(\d+)\.(\d+)(-rc(\d)+)?'
replace: "${{needs.release-name.outputs.name}}"
include: "deploy/charts/version-checker/Chart.yaml"
regex: true
- name: Find and Replace Kubernetes Manifests
uses: jacobtomlinson/gha-find-replace@v3
with:
find: 'v(\d+)\.(\d+)\.(\d+)(-rc(\d)+)?'
replace: "${{needs.release-name.outputs.name}}"
include: "deploy/yaml/deploy.yaml"
regex: true
- name: Find and Replace Makefile versions
uses: jacobtomlinson/gha-find-replace@v3
with:
find: 'v(\d+)\.(\d+)\.(\d+)(-rc(\d)+)?'
replace: "${{needs.release-name.outputs.name}}"
include: "Makefile"
regex: true
- name: Install Helm Docs
uses: envoy/install-helm-docs@v1.0.0
with:
version: 1.14.2
- name: Update Helm Docs
run: |
set -ex
cd deploy/charts/version-checker
helm-docs
- name: Detect any Local Changes
uses: dorny/paths-filter@v3
id: filter
with:
base: HEAD
filters: |
versions:
- 'Makefile'
- 'deploy/yaml/deploy.yaml'
- 'deploy/charts/version-checker/Chart.yaml'
- 'deploy/charts/version-checker/README.md'
- name: Commit files
if: steps.filter.outputs.versions == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git status
git commit -a -m "Bump versions to ${{needs.release-name.outputs.name}}"
- name: Push changes
if: steps.filter.outputs.versions == 'true'
uses: ad-m/github-push-action@v0.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref_name }}
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v5
- name: Create Release PR
uses: devops-infra/action-pull-request@v0.6.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
target_branch: main
title: "Release ${{needs.release-name.outputs.name}}"
body: |-
**Automated Release Pull Request**
## Change log:
${{steps.github_release.outputs.changelog}}
draft: false
get_diff: false
allow_no_diff: false
helm-release:
runs-on: ubuntu-latest
permissions:
id-token: write
needs:
- release-name
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
path: version-checker
- name: Setup Cosign
uses: sigstore/cosign-installer@main
- name: checkout jetstack-charts
uses: actions/checkout@v4
with:
token: ${{ secrets.JETSTACK_CHARTS_PAT }}
repository: jetstack/jetstack-charts
ref: main
path: jetstack-charts
- name: Setup Helm
uses: azure/setup-helm@v4
- name: Login to Quay.io
if: startsWith(github.ref, 'refs/tags/')
run: echo "${{ secrets.QUAY_ROBOT_TOKEN }}" | helm registry login quay.io -u ${{ secrets.QUAY_USERNAME }} --password-stdin
- name: package helm chart
run: |
helm package version-checker/deploy/charts/version-checker -d jetstack-charts/charts/
- name: Sign Helm Chart
run: |
cosign sign-blob -y jetstack-charts/charts/version-checker-${{ needs.release-name.outputs.name }}.tgz \
--bundle jetstack-charts/charts/version-checker-${{ needs.release-name.outputs.name }}.tgz.cosign.bundle
- name: Creating Publishing Chart's PR
uses: peter-evans/create-pull-request@v7
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
token: ${{ secrets.JETSTACK_CHARTS_PAT }}
title: "Release version-checker ${{ needs.release-name.outputs.name }}"
commit-message: "Release version-checker ${{ needs.release-name.outputs.name }}"
branch: version-checker/${{ github.ref_name }}
path: jetstack-charts
add-paths: |
charts/*.tgz
charts/*.tgz.cosign.bundle
delete-branch: true
signoff: true
base: main
- name: Push to Quay
if: startsWith(github.ref, 'refs/tags/')
run: |-
helm push jetstack-charts/charts/version-checker-${{ needs.release-name.outputs.name }}.tgz oci://quay.io/quay.io/jetstack/version-checker/chart:${{needs.release-name.outputs.name}}
docker-release:
runs-on: ubuntu-latest
permissions:
id-token: write
needs:
- release-name
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
with:
cosign-release: "v2.2.4"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
- name: Build and push (if applicable)
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ startsWith(github.ref, 'refs/tags/') }}
pull: true
tags: quay.io/jetstack/version-checker:${{github.ref_name}}
cache-from: type=gha
cache-to: type=gha,mode=max
attests: |-
type=sbom
type=provenance,mode=max
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
github-release:
name: Create/Update GitHub Release
permissions:
contents: write
runs-on: ubuntu-latest
needs:
- release-name
steps:
- name: Create Release / Change Logs
uses: softprops/action-gh-release@v2
with:
draft: ${{ !startsWith(github.ref, 'refs/tags/') }}
prerelease: ${{ contains('-rc', github.ref_name) || !startsWith(github.ref, 'refs/tags/') }}
generate_release_notes: true