Skip to content

Commit 9a83d54

Browse files
committed
Extract spring-pre-release.yml & spring-post-release.yml
The pre- and post-release processes could be extracted into separate reusable workflows. * Fix `spring-finalize-release.yml` for a proper description. Remove out of use now `SPRING_RELEASE_CHAT_WEBHOOK_URL` secret * Improve `spring-artifactory-gradle-release.yml` for consistent job names. Use `spring-pre-release.yml` & `spring-post-release.yml`
1 parent e411157 commit 9a83d54

4 files changed

Lines changed: 128 additions & 82 deletions

File tree

.github/workflows/spring-artifactory-gradle-release.yml

Lines changed: 38 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ on:
3535
required: false
3636
type: string
3737
default: verify-staged-artifacts.yml
38+
snapshotWorkflow:
39+
description: 'A workflow name in the target project to check for latest green SNAPSHOT before going for release.'
40+
required: false
41+
type: string
42+
default: ci-snapshot.yml
3843
runner:
3944
description: 'The runner for job'
4045
required: false
@@ -78,50 +83,24 @@ on:
7883
ARTIFACTORY_PASSWORD:
7984
required: true
8085

81-
env:
82-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83-
8486
jobs:
85-
releaseVersion:
87+
release-version:
8688
uses: ./.github/workflows/spring-find-release-version.yml
8789

88-
check-if-no-opened-issues:
89-
needs: releaseVersion
90-
name: Check is no opened issues for ${{ needs.releaseVersion.outputs.releaseVersion }}
91-
runs-on: ${{ inputs.runner }}
92-
steps:
93-
- uses: spring-io/spring-release-actions/count-open-issues@0.0.3
94-
id: count-open-issues
95-
with:
96-
milestone: ${{ needs.releaseVersion.outputs.releaseVersion }}
97-
- name: Check if no opened issues
98-
run: |
99-
if [[ ${{ steps.count-open-issues.outputs.count }} -gt 0 ]]
100-
then
101-
gh run cancel ${{ github.run_id }}
102-
echo "::warning title=Cannot release::The milestone ${{ needs.releaseVersion.outputs.releaseVersion }} has opened issues"
103-
fi
104-
105-
check-last-snapshot-build:
106-
needs: [ releaseVersion, check-if-no-opened-issues ]
107-
name: Check the last SNAPSHOT build for ${{ needs.releaseVersion.outputs.releaseVersion }}
108-
runs-on: ${{ inputs.runner }}
109-
steps:
110-
- name: Check the last SNAPSHOT build is green
111-
run: |
112-
LAST_SNAPSHOT_BUILD_STATUS=$(gh run list -R ${{ github.repository }} -b ${{ github.ref_name }} -L 1 -w ci-snapshot.yml --json conclusion --jq .[0].conclusion)
113-
if [[ $LAST_SNAPSHOT_BUILD_STATUS != 'success' ]]
114-
then
115-
gh run cancel ${{ github.run_id }}
116-
echo "::warning title=Cannot release::The last SNAPSHOT build for milestone ${{ needs.releaseVersion.outputs.releaseVersion }} has not passed"
117-
fi
90+
pre-release:
91+
needs: release-version
92+
name: Pre-release checks for ${{ needs.release-version.outputs.releaseVersion }}
93+
uses: ./.github/workflows/spring-pre-release.yml
94+
with:
95+
milestone: ${{ needs.release-version.outputs.releaseVersion }}
96+
snapshotWorkflow: ${{ inputs.snapshotWorkflow }}
11897

11998
staging:
120-
needs: [ releaseVersion, check-last-snapshot-build]
121-
name: Stage ${{ needs.releaseVersion.outputs.releaseVersion }}
99+
needs: [ release-version, pre-release]
100+
name: Stage ${{ needs.release-version.outputs.releaseVersion }}
122101
uses: ./.github/workflows/spring-artifactory-gradle-build.yml
123102
with:
124-
releaseVersion: ${{ needs.releaseVersion.outputs.releaseVersion }}
103+
releaseVersion: ${{ needs.release-version.outputs.releaseVersion }}
125104
gradleTasks: ${{ inputs.buildToolArgs }}
126105
artifactoryUrl: ${{ inputs.artifactoryUrl }}
127106
targetRepository: ${{ inputs.stagingRepository }}
@@ -130,8 +109,8 @@ jobs:
130109
secrets: inherit
131110

132111
verify-staged:
133-
needs: [ releaseVersion, staging ]
134-
name: Verify ${{ needs.releaseVersion.outputs.releaseVersion }}
112+
needs: [ release-version, staging ]
113+
name: Verify ${{ needs.release-version.outputs.releaseVersion }}
135114
runs-on: ${{ inputs.runner }}
136115
steps:
137116
- uses: actions/checkout@v6
@@ -152,78 +131,58 @@ jobs:
152131
with:
153132
workflow: ${{ inputs.verifyStagedWorkflow }}
154133
token: ${{ secrets.GITHUB_TOKEN }}
155-
inputs: '{ "releaseVersion": "${{ needs.releaseVersion.outputs.releaseVersion }}" }'
134+
inputs: '{ "releaseVersion": "${{ needs.release-version.outputs.releaseVersion }}" }'
156135

157136
promote-release:
158-
needs: [ releaseVersion, staging, verify-staged ]
159-
name: Promote ${{ needs.releaseVersion.outputs.releaseVersion }}
137+
needs: [ release-version, staging, verify-staged ]
138+
name: Promote ${{ needs.release-version.outputs.releaseVersion }}
160139
uses: ./.github/workflows/spring-artifactory-promote-release.yml
161140
with:
162141
buildName: ${{ needs.staging.outputs.buildName }}
163142
buildNumber: ${{ needs.staging.outputs.buildNumber }}
164-
targetRepository: ${{ contains(needs.releaseVersion.outputs.releaseVersion, '-') && inputs.targetMilestoneRepository || inputs.targetReleaseRepository }}
143+
targetRepository: ${{ contains(needs.release-version.outputs.releaseVersion, '-') && inputs.targetMilestoneRepository || inputs.targetReleaseRepository }}
165144
artifactoryProjectKey: ${{ inputs.artifactoryProjectKey }}
166145
runner: ${{ inputs.runner }}
167146
secrets: inherit
168147

169148
deploy-to-central:
170-
needs: [ releaseVersion, staging, promote-release ]
171-
name: Deploy ${{ needs.releaseVersion.outputs.releaseVersion }} to Maven Central
172-
if: ${{ !inputs.bundleName && (!contains(needs.releaseVersion.outputs.releaseVersion, '-') || inputs.deployMilestoneToCentral) }}
149+
needs: [ release-version, staging, promote-release ]
150+
name: Deploy ${{ needs.release-version.outputs.releaseVersion }} to Maven Central
151+
if: ${{ !inputs.bundleName && (!contains(needs.release-version.outputs.releaseVersion, '-') || inputs.deployMilestoneToCentral) }}
173152
uses: ./.github/workflows/spring-artifactory-deploy-to-maven-central.yml
174153
with:
175154
buildName: ${{ needs.staging.outputs.buildName }}
176155
buildNumber: ${{ needs.staging.outputs.buildNumber }}
177156
runner: ${{ inputs.runner }}
178157
secrets: inherit
179158

180-
spring-release-bundle:
181-
needs: [ releaseVersion, staging, promote-release ]
182-
name: Release Bundle for ${{ needs.releaseVersion.outputs.releaseVersion }}
159+
release-bundle:
160+
needs: [ release-version, staging, promote-release ]
161+
name: Release Bundle for ${{ needs.release-version.outputs.releaseVersion }}
183162
if: inputs.bundleName
184163
uses: ./.github/workflows/spring-enterprise-release-bundle.yml
185164
with:
186165
buildName: ${{ needs.staging.outputs.buildName }}
187166
buildNumber: ${{ needs.staging.outputs.buildNumber }}
188167
artifactoryUrl: ${{ inputs.artifactoryUrl }}
189168
bundleName: ${{ inputs.bundleName }}
190-
releaseVersion: ${{ needs.releaseVersion.outputs.releaseVersion }}
169+
releaseVersion: ${{ needs.release-version.outputs.releaseVersion }}
191170
secrets: inherit
192171

193172
finalize:
194173
if: ${{ !(failure() || cancelled()) }}
195-
needs: [ releaseVersion, deploy-to-central, spring-release-bundle ]
196-
name: Finalize ${{ needs.releaseVersion.outputs.releaseVersion }} release
174+
needs: [ release-version, deploy-to-central, release-bundle ]
175+
name: Finalize ${{ needs.release-version.outputs.releaseVersion }} release
197176
uses: ./.github/workflows/spring-finalize-release.yml
198177
with:
199-
milestone: ${{ needs.releaseVersion.outputs.releaseVersion }}
178+
milestone: ${{ needs.release-version.outputs.releaseVersion }}
200179
secrets: inherit
201180

202181
post-release:
203182
if: ${{ !(failure() || cancelled()) }}
204-
needs: [ releaseVersion, finalize ]
205-
name: Post-procedure for ${{ needs.releaseVersion.outputs.releaseVersion }} release
206-
runs-on: ${{ inputs.runner }}
207-
steps:
208-
- name: Checkout Common Repo
209-
uses: actions/checkout@v6
210-
with:
211-
repository: spring-io/spring-github-workflows
212-
path: .github/spring-github-workflows
213-
show-progress: false
214-
ref: ${{ env.WORKFLOWS_REF }}
215-
216-
- name: Update Spring IO website for new version
217-
uses: ./.github/spring-github-workflows/.github/actions/spring-website-project-version-update
218-
with:
219-
newVersion: ${{ needs.releaseVersion.outputs.releaseVersion }}
220-
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
221-
222-
- name: Announce Release in Chat
223-
if: env.CHAT_WEBHOOK_URL
224-
uses: spring-io/spring-release-actions/announce-on-gchat@0.0.3
225-
with:
226-
gchat-webhook-url: ${{ env.CHAT_WEBHOOK_URL }}
227-
version: ${{ needs.releaseVersion.outputs.releaseVersion }}
228-
env:
229-
CHAT_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_CHAT_WEBHOOK_URL }}
183+
needs: [ release-version, finalize ]
184+
name: Post-procedure for ${{ needs.release-version.outputs.releaseVersion }} release
185+
uses: ./.github/workflows/spring-post-release.yml
186+
with:
187+
milestone: ${{ needs.release-version.outputs.releaseVersion }}
188+
secrets: inherit

.github/workflows/spring-finalize-release.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Create GH release and Notify Slack
1+
name: Create GH release and close milestone
22

33
on:
44
workflow_call:
@@ -9,8 +9,6 @@ on:
99
type: string
1010

1111
secrets:
12-
SPRING_RELEASE_CHAT_WEBHOOK_URL:
13-
required: false
1412
GH_ACTIONS_REPO_TOKEN:
1513
required: true
1614

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Perform Post Release Procedures
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
milestone:
7+
description: 'Milestone title, e.g 3.0.0-M1, 3.1.0-RC1, 3.2.0 etc.'
8+
required: true
9+
type: string
10+
11+
secrets:
12+
SPRING_RELEASE_CHAT_WEBHOOK_URL:
13+
required: false
14+
GH_ACTIONS_REPO_TOKEN:
15+
required: true
16+
17+
env:
18+
WORKFLOWS_REF: main
19+
20+
jobs:
21+
post-release:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout Common Repo
25+
uses: actions/checkout@v6
26+
with:
27+
repository: spring-io/spring-github-workflows
28+
path: .github/spring-github-workflows
29+
show-progress: false
30+
ref: ${{ env.WORKFLOWS_REF }}
31+
32+
- name: Update Spring IO website for new version
33+
uses: ./.github/spring-github-workflows/.github/actions/spring-website-project-version-update
34+
with:
35+
newVersion: ${{ inputs.milestone }}
36+
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
37+
38+
- name: Announce Release in Chat
39+
if: env.CHAT_WEBHOOK_URL
40+
uses: spring-io/spring-release-actions/announce-on-gchat@0.0.3
41+
with:
42+
gchat-webhook-url: ${{ env.CHAT_WEBHOOK_URL }}
43+
version: ${{ inputs.milestone }}
44+
env:
45+
CHAT_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_CHAT_WEBHOOK_URL }}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Perform Pre Release Checks
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
milestone:
7+
description: 'Milestone title, e.g 3.0.0-M1, 3.1.0-RC1, 3.2.0 etc.'
8+
required: true
9+
type: string
10+
snapshotWorkflow:
11+
description: 'A workflow name in the target project to check for latest green SNAPSHOT before going for release.'
12+
required: false
13+
type: string
14+
default: ci-snapshot.yml
15+
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
19+
jobs:
20+
pre-release:
21+
runs-on: ubuntu-latest
22+
steps:
23+
24+
- uses: spring-io/spring-release-actions/count-open-issues@0.0.3
25+
id: count-open-issues
26+
with:
27+
milestone: ${{ inputs.milestone }}
28+
29+
- name: Check if no opened issues
30+
run: |
31+
if [[ ${{ steps.count-open-issues.outputs.count }} -gt 0 ]]
32+
then
33+
gh run cancel ${{ github.run_id }}
34+
echo "::warning title=Cannot release::The milestone ${{ inputs.milestone }} has opened issues"
35+
fi
36+
37+
- name: Check the last SNAPSHOT build is green
38+
run: |
39+
LAST_SNAPSHOT_BUILD_STATUS=$(gh run list -R ${{ github.repository }} -b ${{ github.ref_name }} -L 1 -w ${{ inputs.snapshotWorkflow }} --json conclusion --jq .[0].conclusion)
40+
if [[ $LAST_SNAPSHOT_BUILD_STATUS != 'success' ]]
41+
then
42+
gh run cancel ${{ github.run_id }}
43+
echo "::warning title=Cannot release::The last SNAPSHOT build for milestone ${{ inputs.milestone }} has not passed"
44+
fi

0 commit comments

Comments
 (0)