1+ name : Release
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ build :
10+ runs-on : ubuntu-latest
11+ if : ${{ github.actor != 'protegeproject-bot[bot]' }}
12+ steps :
13+ - uses : actions/create-github-app-token@v1
14+ id : app-token
15+ with :
16+ app-id : ${{ vars.PROTEGEPROJECT_BOT_APP_ID }}
17+ private-key : ${{ secrets.PROTEGEPROJECT_BOT_APP_PRIVATE_KEY }}
18+ - uses : actions/checkout@v4
19+ with :
20+ token : ${{ steps.app-token.outputs.token }}
21+ ref : ${{ github.head_ref }}
22+ - name : Set up JDK 17
23+ uses : actions/setup-java@v3
24+ with :
25+ java-version : ' 17'
26+ distribution : ' adopt'
27+ server-id : ossrh
28+ server-username : OSSRH_USERNAME
29+ server-password : OSSRH_TOKEN
30+ gpg-private-key : ${{secrets.GPG_PRIVATE_KEY}}
31+ gpg-passphrase : GPG_PASSPHRASE
32+ - name : Get current version
33+ id : get-version
34+ run : |
35+ current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
36+ echo "Current version: $current_version"
37+ echo "::set-output name=current_version::$current_version"
38+ - name : Bump version
39+ id : bump
40+ run : |
41+ current_version=${{ steps.get-version.outputs.current_version }}
42+ branch=${GITHUB_REF##*/}
43+ echo "Current branch: $branch"
44+
45+ # Extract the base version without suffix
46+ base_version=$(echo $current_version | sed -E 's/(-.*)?$//')
47+
48+ # Increment the base version (assuming semantic versioning)
49+ IFS='.' read -r -a version_parts <<< "$base_version"
50+ version_parts[2]=$((version_parts[2] + 1))
51+ new_base_version="${version_parts[0]}.${version_parts[1]}.${version_parts[2]}"
52+
53+ echo "New version: $new_version"
54+ mvn versions:set -DnewVersion=$new_version -DgenerateBackupPoms=false
55+ echo "::set-output name=new_version::$new_version"
56+ - name : Commit new version
57+ run : |
58+ git config --global user.name "github-actions[bot]"
59+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
60+ git add pom.xml
61+ git commit -m "Bump version to ${{ steps.bump.outputs.new_version }}"
62+ git tag ${{ steps.bump.outputs.new_version }}
63+ git push origin HEAD:${GITHUB_REF##*/}
64+ git push origin ${{ steps.bump.outputs.new_version }}
65+ - name : Build with Maven
66+ run : mvn --batch-mode -Prelease deploy
67+ - name : Release
68+ uses : softprops/action-gh-release@v1
69+ env :
70+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
71+ with :
72+ tag_name : ${{ steps.bump.outputs.new_version }}
73+ generate_release_notes : true
74+
75+ env :
76+ GPG_PASSPHRASE : ${{secrets.GPG_PASSPHRASE}}
77+ OSSRH_USERNAME : ${{secrets.OSSRH_USERNAME}}
78+ OSSRH_TOKEN : ${{secrets.OSSRH_TOKEN}}
0 commit comments