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
2023 steps :
21- - name : Checkout "${{inputs.version_branch}}" branch
22- uses : actions/checkout@v7
24+ - name : Checkout "${{ inputs.version_branch }}" branch
25+ uses : actions/checkout@v4
2326 with :
24- ref : " ${{inputs.version_branch}}"
27+ ref : " ${{ inputs.version_branch }}"
2528
2629 - name : Set up Java and Maven
27- uses : actions/setup-java@v6
30+ uses : actions/setup-java@v4
2831 with :
2932 java-version : 17
3033 distribution : temurin
@@ -36,11 +39,11 @@ jobs:
3639 gpg-passphrase : MAVEN_GPG_PASSPHRASE
3740
3841 - 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
4242 env :
43- RELEASE_VERSION : ${{ github.event.release.tag_name }}
43+ RELEASE_TAG : ${{ inputs.release_tag }}
44+ run : |
45+ RELEASE_VERSION="${RELEASE_TAG#v}"
46+ ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION}" versions:commit -DprocessAllModules
4447
4548 - name : Publish to Apache Maven Central
4649 run : ./mvnw package deploy -Prelease
@@ -49,19 +52,67 @@ jobs:
4952 MAVEN_CENTRAL_TOKEN : ${{ secrets.NEXUS_PASSWORD }}
5053 MAVEN_GPG_PASSPHRASE : ${{ secrets.GPG_PASSPHRASE }}
5154
52- # This is separate job because there were issues with git after release step, was not able to commit changes.
53- update-working-version :
55+ finalize-release :
5456 runs-on : ubuntu-latest
5557 needs : publish
56- if : " !contains(github.event.release.tag_name, 'RC')" # not sure we should keep this the RC part
58+ permissions :
59+ contents : write
5760 steps :
58- - name : Checkout "${{inputs.version_branch}}" branch
59- uses : actions/checkout@v7
61+ - name : Checkout "${{ inputs.version_branch }}" branch
62+ uses : actions/checkout@v4
6063 with :
61- ref : " ${{inputs.version_branch}}"
64+ ref : " ${{ inputs.version_branch }}"
65+ fetch-depth : 0
6266
6367 - name : Set up Java and Maven
64- uses : actions/setup-java@v6
68+ uses : actions/setup-java@v4
69+ with :
70+ java-version : 17
71+ distribution : temurin
72+ cache : ' maven'
73+
74+ - name : Change version to release version
75+ env :
76+ RELEASE_TAG : ${{ inputs.release_tag }}
77+ run : |
78+ RELEASE_VERSION="${RELEASE_TAG#v}"
79+ ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION}" versions:commit -DprocessAllModules
80+
81+ - name : Commit and push release version
82+ env :
83+ TARGET_BRANCH : ${{ inputs.version_branch }}
84+ RELEASE_TAG : ${{ inputs.release_tag }}
85+ run : |
86+ git config --local user.email "action@github.com"
87+ git config --local user.name "GitHub Action"
88+ if git diff --quiet; then
89+ echo "No version changes to commit."
90+ else
91+ git commit -am "Release ${RELEASE_TAG}"
92+ git push origin HEAD:"${TARGET_BRANCH}"
93+ fi
94+
95+ - name : Override release tag to point to release commit
96+ env :
97+ RELEASE_TAG : ${{ inputs.release_tag }}
98+ run : |
99+ git tag -f -a "${RELEASE_TAG}" -m "Release ${RELEASE_TAG}"
100+ git push -f origin "refs/tags/${RELEASE_TAG}"
101+
102+ update-working-version :
103+ runs-on : ubuntu-latest
104+ needs : finalize-release
105+ permissions :
106+ contents : write
107+ if : " !contains(inputs.release_tag, 'RC')"
108+ steps :
109+ - name : Checkout "${{ inputs.version_branch }}" branch
110+ uses : actions/checkout@v4
111+ with :
112+ ref : " ${{ inputs.version_branch }}"
113+
114+ - name : Set up Java and Maven
115+ uses : actions/setup-java@v4
65116 with :
66117 java-version : 17
67118 distribution : temurin
@@ -73,11 +124,9 @@ jobs:
73124 git config --local user.email "action@github.com"
74125 git config --local user.name "GitHub Action"
75126 git commit -m "Set new SNAPSHOT version into pom files." -a
76- env :
77- RELEASE_VERSION : ${{ github.event.release.tag_name }}
78127
79128 - name : Push changes to branch
80- uses : ad-m/github-push-action@master
129+ uses : ad-m/github-push-action@881a6320fdb16eb5318c5054f31c218aec2b324c # v0.8.0
81130 with :
82- branch : " ${{inputs.version_branch}}"
83- github_token : ${{ secrets.GITHUB_TOKEN }}
131+ branch : " ${{ inputs.version_branch }}"
132+ github_token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments