Skip to content

Commit 10af3ef

Browse files
committed
Simplify release name/number generation into one job
1 parent 7e87c58 commit 10af3ef

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

.github/workflows/release.yaml

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,22 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15+
release-name:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
name: ${{ steps.release_number.outputs.substring }}
19+
steps:
20+
- uses: bhowell2/[email protected]
21+
id: release_number
22+
with:
23+
value: ${{github.ref_name}}
24+
index_of_str: "release-"
25+
1526
prepare-release:
1627
# Don't push back to a tag!
1728
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
29+
needs:
30+
- release-name
1831
name: Prepare release
1932
runs-on: ubuntu-latest
2033
permissions:
@@ -31,33 +44,27 @@ jobs:
3144
with:
3245
go-version-file: go.mod
3346

34-
- uses: bhowell2/[email protected]
35-
id: release_number
36-
with:
37-
value: ${{github.ref_name}}
38-
index_of_str: "release-"
39-
4047
- name: Find and Replace Helm Chart Version
4148
uses: jacobtomlinson/gha-find-replace@v3
4249
with:
4350
find: 'v(\d+)\.(\d+)\.(\d+)(-rc(\d)+)?'
44-
replace: "${{steps.release_number.outputs.substring}}"
51+
replace: "${{needs.release-name.outputs.name}}"
4552
include: "deploy/charts/version-checker/Chart.yaml"
4653
regex: true
4754

4855
- name: Find and Replace Kubernetes Manifests
4956
uses: jacobtomlinson/gha-find-replace@v3
5057
with:
5158
find: 'v(\d+)\.(\d+)\.(\d+)(-rc(\d)+)?'
52-
replace: "${{steps.release_number.outputs.substring}}"
59+
replace: "${{needs.release-name.outputs.name}}"
5360
include: "deploy/yaml/deploy.yaml"
5461
regex: true
5562

5663
- name: Find and Replace Makefile versions
5764
uses: jacobtomlinson/gha-find-replace@v3
5865
with:
5966
find: 'v(\d+)\.(\d+)\.(\d+)(-rc(\d)+)?'
60-
replace: "${{steps.release_number.outputs.substring}}"
67+
replace: "${{needs.release-name.outputs.name}}"
6168
include: "Makefile"
6269
regex: true
6370

@@ -89,7 +96,7 @@ jobs:
8996
git config --local user.email "github-actions[bot]@users.noreply.github.com"
9097
git config --local user.name "github-actions[bot]"
9198
git status
92-
git commit -a -m "Bump versions to ${{steps.release_number.outputs.substring}}"
99+
git commit -a -m "Bump versions to ${{needs.release-name.outputs.name}}"
93100
94101
- name: Push changes
95102
if: steps.filter.outputs.versions == 'true'
@@ -107,7 +114,7 @@ jobs:
107114
with:
108115
github_token: ${{ secrets.GITHUB_TOKEN }}
109116
target_branch: main
110-
title: "Release ${{steps.release_number.outputs.substring}}"
117+
title: "Release ${{needs.release-name.outputs.name}}"
111118
body: |-
112119
"**Automated Release Pull Request**
113120
@@ -121,6 +128,8 @@ jobs:
121128
runs-on: ubuntu-latest
122129
permissions:
123130
id-token: write
131+
needs:
132+
- release-name
124133
steps:
125134
- name: Checkout code
126135
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
@@ -142,6 +151,7 @@ jobs:
142151
uses: azure/setup-helm@v4
143152

144153
- name: Login to Quay.io
154+
if: startsWith(github.ref, 'refs/tags/')
145155
run: echo "${{ secrets.QUAY_ROBOT_TOKEN }}" | helm registry login quay.io -u ${{ secrets.QUAY_USERNAME }} --password-stdin
146156

147157
- name: package helm chart
@@ -150,15 +160,15 @@ jobs:
150160
151161
- name: Sign Helm Chart
152162
run: |
153-
cosign sign-blob -y jetstack-charts/charts/version-checker-${{steps.release_number.outputs.substring}}.tgz \
154-
--bundle jetstack-charts/charts/version-checker-${{steps.release_number.outputs.substring}}.tgz.cosign.bundle
163+
cosign sign-blob -y jetstack-charts/charts/version-checker-${{needs.release-name.outputs.name}}.tgz \
164+
--bundle jetstack-charts/charts/version-checker-${{needs.release-name.outputs.name}}.tgz.cosign.bundle
155165
156166
- name: Creating PR
157167
uses: peter-evans/create-pull-request@v7
158168
with:
159169
token: ${{ secrets.JETSTACK_CHARTS_PAT }}
160-
title: "Release version-checker ${{github.ref_name }}"
161-
commit-message: "Release version-checker ${{github.ref_name }}"
170+
title: "Release version-checker ${{needs.release-name.outputs.name }}"
171+
commit-message: "Release version-checker ${{needs.release-name.outputs.name }}"
162172
branch: version-checker/${{github.ref_name}}
163173
path: jetstack-charts
164174
add-paths: |
@@ -172,12 +182,14 @@ jobs:
172182
- name: Push to Quay
173183
if: startsWith(github.ref, 'refs/tags/')
174184
run: |-
175-
helm push jetstack-charts/charts/version-checker-${{ steps.release_number.outputs.substring }}.tgz oci://quay.io/quay.io/jetstack/version-checker/chart
185+
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}}
176186
177187
docker-release:
178188
runs-on: ubuntu-latest
179189
permissions:
180190
id-token: write
191+
needs:
192+
- release-name
181193
steps:
182194
- name: Checkout code
183195
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
@@ -239,6 +251,8 @@ jobs:
239251
permissions:
240252
contents: write
241253
runs-on: ubuntu-latest
254+
needs:
255+
- release-name
242256
steps:
243257
- name: Create Release / Change Logs
244258
uses: softprops/action-gh-release@v2

0 commit comments

Comments
 (0)