Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Commit 0df7d54

Browse files
committed
Refactor workflows to avoid > 3 nested levels
1 parent 59c1400 commit 0df7d54

7 files changed

+59
-84
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ run-name: Release current version for branch ${{ github.ref_name }}
77

88
jobs:
99
release:
10-
uses: spring-projects/spring-integration-aws/.github/workflows/spring-release-for-branch.yml@main
10+
uses: spring-projects/spring-integration-aws/.github/workflows/spring-artifactory-release.yml@main
1111
with:
1212
buildToolArgs: dist
13-
repositoryTeam: artembilan,garyrussell
1413
secrets: inherit

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ jobs:
7070
echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
7171
echo buildName=$buildName >> $GITHUB_OUTPUT
7272
echo buildNumber=$JFROG_CLI_BUILD_NUMBER >> $GITHUB_OUTPUT
73-
echo "::notice ::Artifactory Build Name=$JFROG_CLI_BUILD_NAME"
74-
echo "::notice ::Artifactory Build Number=$JFROG_CLI_BUILD_NUMBER"
7573
7674
- name: Set Release Version
7775
run: sed -i "s/version=.*/version=${{ inputs.releaseVersion }}/" gradle.properties

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ jobs:
6161
echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
6262
echo buildName=$buildName >> $GITHUB_OUTPUT
6363
echo buildNumber=$JFROG_CLI_BUILD_NUMBER >> $GITHUB_OUTPUT
64-
echo "::notice ::Artifactory Build Name=$JFROG_CLI_BUILD_NAME"
65-
echo "::notice ::Artifactory Build Number=$JFROG_CLI_BUILD_NUMBER"
6664
6765
- name: Set Release Version
6866
run: |

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

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,50 @@ on:
1111
description: 'Additional Maven or Gradle command arguments: tasks, goals, plugins etc. The `install` for Maven is included. The `build` and `artifactoryPublish` for Gradle are included.'
1212
required: false
1313
type: string
14-
repositoryTeam:
15-
description: 'Comma-separate GitHub user names for repository team members to exclude from contributors'
16-
required: false
17-
type: string
1814

1915
jobs:
16+
releaseVersion:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
releaseVersion: ${{ steps.release-version.outputs.releaseVersion }}
20+
21+
steps:
22+
23+
- uses: actions/checkout@v4
24+
with:
25+
show-progress: false
26+
27+
- name: Find Current Version to Release
28+
id: release-version
29+
run: |
30+
if test -f pom.xml
31+
then
32+
CURRENT_VERSION=$(./mvnw help:evaluate -Dexpression="project.version" -q -DforceStdout)
33+
else
34+
CURRENT_VERSION=$(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}')
35+
fi
36+
export CANDIDATE_VERSION=${CURRENT_VERSION/-SNAPSHOT}
37+
RELEASE_VERSION=$(gh api repos/$GITHUB_REPOSITORY/milestones --jq 'map(select(.title | startswith(env.CANDIDATE_VERSION))) | .[0] | .title')
38+
if [ -z $RELEASE_VERSION ]; then
39+
echo "::error::No scheduled milestone for $CURRENT_VERSION version."
40+
exit 1
41+
fi
42+
echo releaseVersion=$RELEASE_VERSION >> $GITHUB_OUTPUT
43+
echo "::notice::RELEASE VERSION=$RELEASE_VERSION"
44+
2045
staging:
46+
needs: releaseVersion
2147
uses: spring-projects/spring-integration-aws/.github/workflows/spring-stage-release.yml@main
2248
with:
23-
releaseVersion: ${{ inputs.releaseVersion }}
49+
releaseVersion: ${{ needs.releaseVersion.outputs.releaseVersion }}
2450
buildToolArgs: ${{ inputs.buildToolArgs }}
2551
secrets: inherit
2652

2753
verify-staged:
28-
needs: staging
54+
needs: [releaseVersion, staging]
2955
uses: ./.github/workflows/verify-staged-artifacts.yml
3056
with:
31-
releaseVersion: ${{ inputs.releaseVersion }}
57+
releaseVersion: ${{ needs.releaseVersion.outputs.releaseVersion }}
3258
secrets: inherit
3359

3460
promote-milestone:
@@ -51,9 +77,8 @@ jobs:
5177

5278
finalize:
5379
if: ${{ !(failure() || cancelled()) }}
54-
needs: [promote-milestone, promote-ga]
80+
needs: [releaseVersion, promote-milestone, promote-ga]
5581
uses: spring-projects/spring-integration-aws/.github/workflows/spring-finalize-release.yml@main
5682
with:
57-
milestone: ${{ inputs.releaseVersion }}
58-
repositoryTeam: ${{ inputs.repositoryTeam }}
83+
milestone: ${{ needs.releaseVersion.outputs.releaseVersion }}
5984
secrets: inherit

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ on:
77
description: 'Milestone title, e.g 3.0.0-M1, 3.1.0-RC1, 3.2.0 etc.'
88
required: true
99
type: string
10-
repositoryTeam:
11-
description: 'Comma-separate GitHub user names for repository team members to exclude from contributors'
12-
required: false
13-
type: string
1410

1511
env:
1612
MILESTONE: ${{ inputs.milestone }}
@@ -27,13 +23,16 @@ jobs:
2723

2824
- name: Generate Changelog
2925
run: |
26+
repositoryTeam=$(gh api repos/$GITHUB_REPOSITORY/collaborators --jq 'map(select(.role_name == "admin") | .login) | tostring')
27+
repositoryTeam=$(sed 's/"//g' <<< ${repositoryTeam:1:-1})
28+
3029
wget -q https://github.com/spring-io/github-changelog-generator/releases/download/v0.0.8/github-changelog-generator.jar
3130
3231
java -jar github-changelog-generator.jar $MILESTONE changelog.md \
3332
--changelog.repository=$GITHUB_REPOSITORY \
3433
--github.username=spring-builds \
3534
--github.password=$GITHUB_TOKEN \
36-
--changelog.contributors.exclude.names=${{ inputs.repositoryTeam }}
35+
--changelog.contributors.exclude.names=$repositoryTeam
3736
3837
- name: GitHub Release
3938
run: gh release create v${{ env.MILESTONE }} -F changelog.md ${{ (contains(env.MILESTONE, '-M') || contains(env.MILESTONE, '-RC')) && '--prerelease' }}
@@ -45,13 +44,13 @@ jobs:
4544
gh api -X PATCH repos/$GITHUB_REPOSITORY/milestones/$MILESTONE_ID -f state='closed' --silent
4645
fi
4746
48-
- name: Announce Release on Slack
49-
uses: slackapi/slack-github-action@v1.24.0
50-
env:
51-
SLACK_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_SLACK_WEBHOOK_URL }}
52-
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
53-
with:
54-
payload: |
55-
{
56-
"text": "${{ github.event.repository.name }}-announcing `${{ env.MILESTONE }}`"
57-
}
47+
# - name: Announce Release on Slack
48+
# uses: slackapi/slack-github-action@v1.24.0
49+
# env:
50+
# SLACK_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_SLACK_WEBHOOK_URL }}
51+
# SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
52+
# with:
53+
# payload: |
54+
# {
55+
# "text": "${{ github.event.repository.name }}-announcing `${{ env.MILESTONE }}`"
56+
# }

.github/workflows/spring-release-for-branch.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ jobs:
7575
run: |
7676
if [ ${{ needs.staging-with-gradle.outputs.buildName }} ]
7777
then
78-
echo buildName=${{ needs.staging-with-gradle.outputs.buildName }} >> $GITHUB_OUTPUT
79-
echo buildNumber=${{ needs.staging-with-gradle.outputs.buildNumber }} >> $GITHUB_OUTPUT
78+
buildName=${{ needs.staging-with-gradle.outputs.buildName }}
79+
buildNumber=${{ needs.staging-with-gradle.outputs.buildNumber }}
8080
else
81-
echo buildName=${{ needs.staging-with-maven.outputs.buildName }} >> $GITHUB_OUTPUT
82-
echo buildNumber=${{ needs.staging-with-maven.outputs.buildNumber }} >> $GITHUB_OUTPUT
83-
fi
81+
buildName=${{ needs.staging-with-maven.outputs.buildName }}
82+
buildNumber=${{ needs.staging-with-maven.outputs.buildNumber }}
83+
fi
84+
echo buildName=$buildName >> $GITHUB_OUTPUT
85+
echo buildNumber=$buildNumber >> $GITHUB_OUTPUT
86+
echo "::notice::Artifactory Build Name=$buildName"
87+
echo "::notice::Artifactory Build Number=$buildNumber"

0 commit comments

Comments
 (0)