Skip to content

Commit 203d5cf

Browse files
committed
Adapt reusable workflows for hotfix
* Extract `spring-compute-milestone-to-release` local action with the logic to determine if the current version in the branch is hotfix and don't search for GH Milestone, since hotfix is, essentially, a milestone * Use `hotfix` output from this action as a variable to skip logic here or there * Remove usage of `WORKFLOWS_REF` placeholder since the `github.action_ref` variable is exactly what we need to check out the reusable workflows repository for its local actions * Remove, therefore, the `WORKFLOWS_REF` manipulation from the `release-workflows.yml`
1 parent 7afc18a commit 203d5cf

13 files changed

Lines changed: 118 additions & 56 deletions
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Get the GitHub Milestone to release against current branch
2+
3+
description: 'Get the version from current branch and find the corresponding GitHub Milestone.
4+
If current version matches hotfix pattern, use it as a Milestone stripping `-SNAPSHOT` suffix.'
5+
6+
outputs:
7+
milestone:
8+
description: 'The scheduled Milestone if any'
9+
value: ${{ steps.milestone.outputs.milestone || steps.hotfix-milestone.outputs.milestone }}
10+
currentVersion:
11+
description: 'The version for Milestone to find'
12+
value: ${{ steps.compute-version.outputs.version }}
13+
hotfix:
14+
description: 'True if Milestone is hotfix'
15+
value: ${{ steps.hotfix-milestone.outputs.hotfix }}
16+
17+
runs:
18+
using: composite
19+
steps:
20+
21+
- uses: actions/setup-java@v5
22+
with:
23+
distribution: temurin
24+
java-version: 17
25+
26+
- name: Compute Version
27+
id: compute-version
28+
uses: spring-io/spring-release-actions/compute-version@0.0.4
29+
30+
- name: Compute milestone from hotfix version
31+
id: hotfix-milestone
32+
shell: bash
33+
run: |
34+
VERSION="${{ steps.compute-version.outputs.version }}"
35+
VERSION=${VERSION/-SNAPSHOT}
36+
37+
if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]
38+
then
39+
echo hotfix=true >> $GITHUB_OUTPUT
40+
else
41+
echo milestone=$VERSION >> $GITHUB_OUTPUT
42+
fi
43+
44+
- name: Compute next scheduled milestone
45+
id: milestone
46+
if: ${{ steps.hotfix-milestone.outputs.hotfix != 'true' }}
47+
uses: spring-io/spring-release-actions/compute-next-scheduled-milestone@0.0.4
48+
with:
49+
snapshot-version: ${{ steps.compute-version.outputs.version }}

.github/workflows/release-workflows.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,12 @@ jobs:
3434
3535
releaseVersion=v$(($latestRelease + 1))
3636
37-
for file in ./.github/workflows/spring-*; do
38-
sed -i "1,/WORKFLOWS_REF:.*/s/WORKFLOWS_REF:.*/WORKFLOWS_REF: $releaseVersion/" $file
39-
done
40-
41-
git commit -a -m "Release version $releaseVersion"
37+
git commit -a --allow-empty -m "Release version $releaseVersion"
4238
git tag $releaseVersion
4339
git push --tags origin
4440
45-
for file in ./.github/workflows/spring-*; do
46-
sed -i "1,/WORKFLOWS_REF:.*/s/WORKFLOWS_REF:.*/WORKFLOWS_REF: main/" $file
47-
done
48-
49-
git commit -a -m "Next development version"
41+
git commit -a --allow-empty -m "Next development version"
5042
git push origin
5143
5244
RELEASE_URL=$(gh release create $releaseVersion)
53-
echo "::notice title=Release Page::$RELEASE_URL"
45+
echo "::notice title=Release Page::$RELEASE_URL"

.github/workflows/spring-artifactory-deploy-to-maven-central.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ on:
2222

2323
env:
2424
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
25-
WORKFLOWS_REF: main
2625

2726
jobs:
2827
deploy-to-maven-central:
@@ -33,7 +32,7 @@ jobs:
3332
with:
3433
repository: spring-io/spring-github-workflows
3534
show-progress: false
36-
ref: ${{ env.WORKFLOWS_REF }}
35+
ref: ${{ github.action_ref }}
3736

3837
- uses: jfrog/setup-jfrog-cli@v5
3938

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ on:
5151

5252
env:
5353
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
54-
WORKFLOWS_REF: main
5554

5655
jobs:
5756
build-with-gradle:
@@ -74,7 +73,7 @@ jobs:
7473
repository: spring-io/spring-github-workflows
7574
path: .github/spring-github-workflows
7675
show-progress: false
77-
ref: ${{ env.WORKFLOWS_REF }}
76+
ref: ${{ github.action_ref }}
7877

7978
- name: Build and Publish
8079
id: build-and-publish
@@ -90,5 +89,3 @@ jobs:
9089
artifactoryPassword: ${{ secrets.ARTIFACTORY_PASSWORD }}
9190
gpgPrivateKey: ${{ secrets.GPG_PRIVATE_KEY }}
9291
gpgPassphrase: ${{ secrets.GPG_PASSPHRASE }}
93-
94-

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ jobs:
117117
repository: spring-io/spring-github-workflows
118118
path: .github/spring-github-workflows
119119
show-progress: false
120-
ref: ${{ env.WORKFLOWS_REF }}
120+
ref: ${{ github.action_ref }}
121121

122122
- name: Dispatch Workflow
123123
timeout-minutes: 30
@@ -160,6 +160,7 @@ jobs:
160160
artifactoryUrl: ${{ inputs.artifactoryUrl }}
161161
bundleName: ${{ inputs.bundleName }}
162162
releaseVersion: ${{ needs.release-version.outputs.releaseVersion }}
163+
hotfix: ${{ needs.release-version.outputs.hotfix }}
163164
secrets: inherit
164165

165166
finalize:
@@ -178,4 +179,5 @@ jobs:
178179
uses: ./.github/workflows/spring-post-release.yml
179180
with:
180181
milestone: ${{ needs.release-version.outputs.releaseVersion }}
181-
secrets: inherit
182+
hotfix: ${{ needs.release-version.outputs.hotfix }}
183+
secrets: inherit

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ on:
3939

4040
env:
4141
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
42-
WORKFLOWS_REF: main
4342

4443
jobs:
4544
build-snapshot-with-gradle:
@@ -52,4 +51,3 @@ jobs:
5251
artifactoryProjectKey: ${{ inputs.artifactoryProjectKey }}
5352
runner: ${{ inputs.runner }}
5453
secrets: inherit
55-

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
repository: spring-io/spring-github-workflows
106106
path: .github/spring-github-workflows
107107
show-progress: false
108-
ref: ${{ env.WORKFLOWS_REF }}
108+
ref: ${{ github.action_ref }}
109109

110110
- name: Dispatch Workflow
111111
timeout-minutes: 30
@@ -147,6 +147,7 @@ jobs:
147147
artifactoryUrl: ${{ inputs.artifactoryUrl }}
148148
bundleName: ${{ inputs.bundleName }}
149149
releaseVersion: ${{ needs.releaseVersion.outputs.releaseVersion }}
150+
hotfix: ${{ needs.release-version.outputs.hotfix }}
150151
secrets: inherit
151152

152153
finalize:
@@ -165,4 +166,5 @@ jobs:
165166
uses: ./.github/workflows/spring-post-release.yml
166167
with:
167168
milestone: ${{ needs.release-version.outputs.releaseVersion }}
168-
secrets: inherit
169+
hotfix: ${{ needs.release-version.outputs.hotfix }}
170+
secrets: inherit

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ on:
3232

3333
env:
3434
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
35-
WORKFLOWS_REF: main
3635

3736
jobs:
3837
promote-release-with-jfrog:
@@ -42,4 +41,4 @@ jobs:
4241
- uses: jfrog/setup-jfrog-cli@v5
4342

4443
- name: Promote Build
45-
run: jfrog rt build-promote ${{ inputs.buildName }} ${{ inputs.buildNumber }} ${{ inputs.targetRepository }} --project=${{ inputs.artifactoryProjectKey }}
44+
run: jfrog rt build-promote ${{ inputs.buildName }} ${{ inputs.buildNumber }} ${{ inputs.targetRepository }} --project=${{ inputs.artifactoryProjectKey }}

.github/workflows/spring-enterprise-release-bundle.yml

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ on:
1818
description: 'The Bundle Version (usually project release)'
1919
required: true
2020
type: string
21+
hotfix:
22+
description: 'If just released milestone is a hotfix, e.g 3.1.10.1'
23+
required: true
24+
type: boolean
2125
buildName:
2226
description: 'The Artifactory Build Name'
2327
required: true
@@ -37,12 +41,29 @@ jobs:
3741
distribute-spring-enterprise-release-bundle:
3842
runs-on: ubuntu22-2-8
3943
steps:
40-
- uses: spring-io/spring-release-actions/distribute-release-bundle@0.0.4
41-
with:
42-
artifactory-url: ${{ inputs.artifactoryUrl }}
43-
bundle-name: ${{ inputs.bundleName }}
44-
build-name: ${{ inputs.buildName }}
45-
build-number: ${{ inputs.buildNumber }}
46-
version: ${{ inputs.releaseVersion }}
47-
username: ${{ secrets.ARTIFACTORY_USERNAME }}
48-
password: ${{ secrets.ARTIFACTORY_PASSWORD }}
44+
45+
- name: Create Release Bundle
46+
run: |
47+
curl -s -u "${{ secrets.ARTIFACTORY_USERNAME }}:${{ secrets.ARTIFACTORY_PASSWORD }}" \
48+
-X POST -H "X-JFrog-Signing-Key-Name: packagesKey" -H "Content-Type: application/json" \
49+
"${{ inputs.artifactoryUrl }}/lifecycle/api/v2/release_bundle?project=spring&async=false" \
50+
-d '{"release_bundle_name": "${{ inputs.bundleName }}", "release_bundle_version": "${{ inputs.releaseVersion }}", "skip_docker_manifest_resolution": true, "source_type": "builds", "source": {"builds": [ {"build_repository": "spring-build-info", "build_name": "${{ inputs.buildName }}", "build_number": "${{ inputs.buildNumber }}", "include_dependencies": false}]}}'
51+
52+
- name: Distribute Release Bundle
53+
if: ${{ !inputs.hotfix }}
54+
run: |
55+
curl -s -u "${{ secrets.ARTIFACTORY_USERNAME }}:${{ secrets.ARTIFACTORY_PASSWORD }}" \
56+
-X POST -H "Content-Type: application/json" \
57+
"${{ inputs.artifactoryUrl }}/lifecycle/api/v2/distribution/distribute/${{ inputs.bundleName }}/${{ inputs.releaseVersion }}?project=spring" \
58+
-d '{"auto_create_missing_repositories": "false", "distribution_rules": [{"site_name": "JP-SaaS"}], "modifications": {"mappings": [{"input": "spring-enterprise-maven-prod-local/(.*)", "output": "spring-enterprise/$1"}]}}'
59+
60+
61+
# - uses: spring-io/spring-release-actions/distribute-release-bundle@0.0.4
62+
# with:
63+
# artifactory-url: ${{ inputs.artifactoryUrl }}
64+
# bundle-name: ${{ inputs.bundleName }}
65+
# build-name: ${{ inputs.buildName }}
66+
# build-number: ${{ inputs.buildNumber }}
67+
# version: ${{ inputs.releaseVersion }}
68+
# username: ${{ secrets.ARTIFACTORY_USERNAME }}
69+
# password: ${{ secrets.ARTIFACTORY_PASSWORD }}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ on:
1515
env:
1616
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1717
SPRING_MAIN_BANNERMODE: off
18-
WORKFLOWS_REF: main
1918

2019
jobs:
2120
finalize-release:
@@ -94,4 +93,4 @@ jobs:
9493
- name: Close Milestone
9594
uses: spring-io/spring-release-actions/close-milestone@0.0.4
9695
with:
97-
version: ${{ inputs.milestone }}
96+
version: ${{ inputs.milestone }}

0 commit comments

Comments
 (0)