99 version_branch :
1010 type : string
1111 required : true
12+ release_tag :
13+ type : string
14+ required : true
1215
1316env :
14- # set the target pom to use the input directory as root
17+ # set the target pom to use the input directory as root
1518 MAVEN_ARGS : -V -ntp -e -f ${{ inputs.project_dir }}/pom.xml
1619
1720jobs :
1821 publish :
1922 runs-on : ubuntu-latest
23+ permissions :
24+ contents : write
2025 steps :
21- - name : Checkout "${{inputs.version_branch}}" branch
22- uses : actions/checkout@v7
26+ - name : Checkout "${{ inputs.version_branch }}" branch
27+ uses : actions/checkout@v4
2328 with :
24- ref : " ${{inputs.version_branch}}"
29+ ref : " ${{ inputs.version_branch }}"
30+ fetch-depth : 0
2531
2632 - name : Set up Java and Maven
27- uses : actions/setup-java@v6
33+ uses : actions/setup-java@v4
2834 with :
2935 java-version : 17
3036 distribution : temurin
@@ -36,11 +42,11 @@ jobs:
3642 gpg-passphrase : MAVEN_GPG_PASSPHRASE
3743
3844 - name : Change version to release version
39- # Assume that RELEASE_VERSION will have form like: "v1.0.1". So we cut the "v"
40- run : |
41- ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit -DprocessAllModules
4245 env :
43- RELEASE_VERSION : ${{ github.event.release.tag_name }}
46+ RELEASE_TAG : ${{ inputs.release_tag }}
47+ run : |
48+ RELEASE_VERSION="${RELEASE_TAG#v}"
49+ ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION}" versions:commit -DprocessAllModules
4450
4551 - name : Publish to Apache Maven Central
4652 run : ./mvnw package deploy -Prelease
@@ -49,19 +55,41 @@ jobs:
4955 MAVEN_CENTRAL_TOKEN : ${{ secrets.NEXUS_PASSWORD }}
5056 MAVEN_GPG_PASSPHRASE : ${{ secrets.GPG_PASSPHRASE }}
5157
52- # This is separate job because there were issues with git after release step, was not able to commit changes.
58+ - name : Commit and push release version
59+ env :
60+ TARGET_BRANCH : ${{ inputs.version_branch }}
61+ RELEASE_TAG : ${{ inputs.release_tag }}
62+ run : |
63+ git config --local user.email "action@github.com"
64+ git config --local user.name "GitHub Action"
65+ if git diff --quiet; then
66+ echo "No version changes to commit."
67+ else
68+ git commit -am "Release ${RELEASE_TAG}"
69+ git push origin HEAD:"${TARGET_BRANCH}"
70+ fi
71+
72+ - name : Override release tag to point to release commit
73+ env :
74+ RELEASE_TAG : ${{ inputs.release_tag }}
75+ run : |
76+ git tag -f -a "${RELEASE_TAG}" -m "Release ${RELEASE_TAG}"
77+ git push -f origin "refs/tags/${RELEASE_TAG}"
78+
5379 update-working-version :
5480 runs-on : ubuntu-latest
5581 needs : publish
56- if : " !contains(github.event.release.tag_name, 'RC')" # not sure we should keep this the RC part
82+ permissions :
83+ contents : write
84+ if : " !contains(inputs.release_tag, 'RC')"
5785 steps :
58- - name : Checkout "${{inputs.version_branch}}" branch
59- uses : actions/checkout@v7
86+ - name : Checkout "${{ inputs.version_branch }}" branch
87+ uses : actions/checkout@v4
6088 with :
61- ref : " ${{inputs.version_branch}}"
89+ ref : " ${{ inputs.version_branch }}"
6290
6391 - name : Set up Java and Maven
64- uses : actions/setup-java@v6
92+ uses : actions/setup-java@v4
6593 with :
6694 java-version : 17
6795 distribution : temurin
@@ -73,11 +101,9 @@ jobs:
73101 git config --local user.email "action@github.com"
74102 git config --local user.name "GitHub Action"
75103 git commit -m "Set new SNAPSHOT version into pom files." -a
76- env :
77- RELEASE_VERSION : ${{ github.event.release.tag_name }}
78104
79105 - name : Push changes to branch
80106 uses : ad-m/github-push-action@master
81107 with :
82- branch : " ${{inputs.version_branch}}"
83- github_token : ${{ secrets.GITHUB_TOKEN }}
108+ branch : " ${{ inputs.version_branch }}"
109+ github_token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments