@@ -2,46 +2,120 @@ name: Release
22
33on :
44 push :
5- tags :
6- - ' v*.*.* '
5+ branches :
6+ - main
77
88jobs :
99 build :
1010 runs-on : ubuntu-latest
11+ if : ${{ github.actor != 'protegeproject-bot[bot]' }}
12+ outputs :
13+ version : ${{ steps.release-outputs.outputs.version }}
14+ service : ${{ steps.release-outputs.outputs.service }}
15+
1116 steps :
1217 - name : Login to Docker Hub
1318 uses : docker/login-action@v2
1419 with :
1520 username : ${{secrets.DOCKER_USERNAME}}
1621 password : ${{secrets.DOCKER_PASSWORD}}
22+ - uses : actions/create-github-app-token@v1
23+ id : app-token
24+ with :
25+ app-id : ${{ vars.PROTEGEPROJECT_BOT_APP_ID }}
26+ private-key : ${{ secrets.PROTEGEPROJECT_BOT_APP_PRIVATE_KEY }}
1727 - uses : actions/checkout@v4
18- - name : Set up Java
28+ with :
29+ token : ${{ steps.app-token.outputs.token }}
30+ ref : ${{ github.head_ref }}
31+ - name : Set up Maven Central Repository
1932 uses : actions/setup-java@v3
2033 with :
2134 java-version : ' 17'
2235 distribution : ' adopt'
23- - name : Extract version from tag
24- id : get-version
36+ server-id : docker.io
37+ server-username : DOCKER_USERNAME
38+ server-password : DOCKER_PASSWORD
39+
40+ # Read the version from pom.xml and strip the -SNAPSHOT suffix to
41+ # produce the release version. For example, 2.0.0-SNAPSHOT becomes
42+ # 2.0.0. If there is no -SNAPSHOT suffix the version is used as-is.
43+ - name : Determine release version
44+ id : release-version
45+ run : |
46+ current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
47+ echo "Current pom version: $current_version"
48+ release_version=$(echo "$current_version" | sed -E 's/-SNAPSHOT$//')
49+ echo "Release version: $release_version"
50+ echo "release_version=$release_version" >> $GITHUB_OUTPUT
51+
52+ # Set pom.xml to the release version (without -SNAPSHOT), commit,
53+ # and tag. This is the commit that the Docker image is built from.
54+ - name : Set release version in pom.xml
2555 run : |
26- VERSION=${GITHUB_REF_NAME#v}
27- echo "version=$VERSION" >> $GITHUB_OUTPUT
28- echo "Version: $VERSION"
29- - name : Set version in pom.xml files
56+ find . -name 'pom.xml' -exec mvn versions:set \
57+ -DnewVersion=${{ steps.release-version.outputs.release_version }} \
58+ -DgenerateBackupPoms=false -f {} \;
59+ - name : Commit and tag release
3060 run : |
31- VERSION=${{ steps.get-version.outputs.version }}
32- find . -name 'pom.xml' -exec mvn versions:set -DnewVersion=$VERSION -DgenerateBackupPoms=false -f {} \;
33- - name : Build SPI plugin
34- run : mvn --batch-mode -pl spi clean package
35- - name : Build and push Docker image
36- run : mvn --batch-mode package install
61+ git config --global user.name "github-actions[bot]"
62+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
63+ git add .
64+ # If the pom already had the release version (no -SNAPSHOT suffix),
65+ # there is nothing to commit — just tag the current HEAD.
66+ git diff --cached --quiet || \
67+ git commit -m "Release ${{ steps.release-version.outputs.release_version }}"
68+ git tag ${{ steps.release-version.outputs.release_version }}
69+ git push origin HEAD:${GITHUB_REF##*/}
70+ git push origin ${{ steps.release-version.outputs.release_version }}
71+
72+ - name : Build Docker image
73+ run : mvn --batch-mode package
74+ - name : Run entrypoint integration test
75+ run : ./test-entrypoint.sh protegeproject/webprotege-keycloak:${{ steps.release-version.outputs.release_version }}
76+ - name : Push Docker image
77+ run : docker push protegeproject/webprotege-keycloak:${{ steps.release-version.outputs.release_version }}
3778 - name : Release
3879 uses : softprops/action-gh-release@v1
3980 env :
4081 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4182 with :
42- tag_name : ${{ github.ref_name }}
83+ tag_name : ${{ steps.release-version.outputs.release_version }}
4384 generate_release_notes : true
4485
86+ # After the release, bump the patch version and add -SNAPSHOT to
87+ # prepare the pom for the next development cycle. For example,
88+ # after releasing 2.0.0 the pom is set to 2.0.1-SNAPSHOT.
89+ - name : Prepare next development version
90+ run : |
91+ released=${{ steps.release-version.outputs.release_version }}
92+ IFS='.' read -r -a parts <<< "$released"
93+ parts[2]=$((parts[2] + 1))
94+ next_snapshot="${parts[0]}.${parts[1]}.${parts[2]}-SNAPSHOT"
95+ echo "Next development version: $next_snapshot"
96+ find . -name 'pom.xml' -exec mvn versions:set \
97+ -DnewVersion=$next_snapshot \
98+ -DgenerateBackupPoms=false -f {} \;
99+ git add .
100+ git commit -m "Prepare next development version ($next_snapshot)"
101+ git push origin HEAD:${GITHUB_REF##*/}
102+
103+ - name : Set outputs
104+ id : release-outputs
105+ run : |
106+ echo "version=${{ steps.release-version.outputs.release_version }}" >> $GITHUB_OUTPUT
107+ echo "service=webprotege-keycloak" >> $GITHUB_OUTPUT
108+
109+ notify-bump :
110+ needs : build
111+ uses : ./.github/workflows/notify-deploy-project.yaml
112+ with :
113+ version : ${{ needs.build.outputs.version }}
114+ service : ${{ needs.build.outputs.service }}
115+ branch_var : ${{vars.BUMP_WEBPROTEGE_BRANCH}}
116+ secrets :
117+ PROTEGE_PROJECT_CLIENT_ID : ${{ secrets.PROTEGE_PROJECT_CLIENT_ID }}
118+ PROTEGE_PROJECT_CLIENT_SECRET : ${{ secrets.PROTEGE_PROJECT_CLIENT_SECRET }}
45119
46120env :
47121 DOCKER_USERNAME : ${{secrets.DOCKER_USERNAME}}
0 commit comments