1111 required : true
1212
1313env :
14- # set the target pom to use the input directory as root
14+ # set the target pom to use the input directory as root
1515 MAVEN_ARGS : -V -ntp -e -f ${{ inputs.project_dir }}/pom.xml
1616
1717jobs :
1818 publish :
1919 runs-on : ubuntu-latest
20+ permissions :
21+ contents : write
2022 steps :
2123 - name : Checkout "${{inputs.version_branch}}" branch
22- uses : actions/checkout@v7
24+ uses : actions/checkout@v4
2325 with :
2426 ref : " ${{inputs.version_branch}}"
27+ fetch-depth : 0
28+
29+ - name : Parse release version
30+ id : vars
31+ run : |
32+ RAW_TAG="${{ github.event.release.tag_name }}"
33+ STRIPPED="${RAW_TAG#v}"
34+ FINAL_VERSION="${STRIPPED%-tmp}"
35+ FINAL_TAG="v${FINAL_VERSION}"
36+
37+ echo "raw_tag=${RAW_TAG}" >> "$GITHUB_OUTPUT"
38+ echo "final_version=${FINAL_VERSION}" >> "$GITHUB_OUTPUT"
39+ echo "final_tag=${FINAL_TAG}" >> "$GITHUB_OUTPUT"
2540
2641 - name : Set up Java and Maven
27- uses : actions/setup-java@v6
42+ uses : actions/setup-java@v4
2843 with :
2944 java-version : 17
3045 distribution : temurin
@@ -36,11 +51,39 @@ jobs:
3651 gpg-passphrase : MAVEN_GPG_PASSPHRASE
3752
3853 - name : Change version to release version
39- # Assume that RELEASE_VERSION will have form like: "v1.0.1". So we cut the "v"
4054 run : |
41- ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit -DprocessAllModules
55+ ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${{ steps.vars.outputs.final_version }}" versions:commit -DprocessAllModules
56+
57+ - name : Commit and push release version
58+ run : |
59+ git config --local user.email "action@github.com"
60+ git config --local user.name "GitHub Action"
61+ if git diff --quiet; then
62+ echo "No version changes to commit."
63+ else
64+ git commit -am "Release ${{ steps.vars.outputs.final_tag }}"
65+ git push origin HEAD:${{ inputs.version_branch }}
66+ fi
67+
68+ - name : Re-tag commit and update GitHub Release
4269 env :
43- RELEASE_VERSION : ${{ github.event.release.tag_name }}
70+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
71+ GH_REPO : ${{ github.repository }}
72+ run : |
73+ RAW_TAG="${{ steps.vars.outputs.raw_tag }}"
74+ FINAL_TAG="${{ steps.vars.outputs.final_tag }}"
75+
76+ if [ "$RAW_TAG" != "$FINAL_TAG" ]; then
77+ echo "Creating final release tag: ${FINAL_TAG}"
78+ git tag -a "${FINAL_TAG}" -m "Release ${FINAL_TAG}"
79+ git push origin "${FINAL_TAG}"
80+
81+ echo "Pointing GitHub release to final tag ${FINAL_TAG}"
82+ gh release edit "${RAW_TAG}" --tag "${FINAL_TAG}"
83+
84+ echo "Deleting temporary tag ${RAW_TAG}"
85+ git push origin --delete "${RAW_TAG}" || true
86+ fi
4487
4588 - name : Publish to Apache Maven Central
4689 run : ./mvnw package deploy -Prelease
@@ -49,19 +92,20 @@ jobs:
4992 MAVEN_CENTRAL_TOKEN : ${{ secrets.NEXUS_PASSWORD }}
5093 MAVEN_GPG_PASSPHRASE : ${{ secrets.GPG_PASSPHRASE }}
5194
52- # This is separate job because there were issues with git after release step, was not able to commit changes.
5395 update-working-version :
5496 runs-on : ubuntu-latest
5597 needs : publish
56- if : " !contains(github.event.release.tag_name, 'RC')" # not sure we should keep this the RC part
98+ permissions :
99+ contents : write
100+ if : " !contains(github.event.release.tag_name, 'RC')"
57101 steps :
58102 - name : Checkout "${{inputs.version_branch}}" branch
59- uses : actions/checkout@v7
103+ uses : actions/checkout@v4
60104 with :
61105 ref : " ${{inputs.version_branch}}"
62106
63107 - name : Set up Java and Maven
64- uses : actions/setup-java@v6
108+ uses : actions/setup-java@v4
65109 with :
66110 java-version : 17
67111 distribution : temurin
@@ -73,11 +117,9 @@ jobs:
73117 git config --local user.email "action@github.com"
74118 git config --local user.name "GitHub Action"
75119 git commit -m "Set new SNAPSHOT version into pom files." -a
76- env :
77- RELEASE_VERSION : ${{ github.event.release.tag_name }}
78120
79121 - name : Push changes to branch
80122 uses : ad-m/github-push-action@master
81123 with :
82124 branch : " ${{inputs.version_branch}}"
83- github_token : ${{ secrets.GITHUB_TOKEN }}
125+ github_token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments