44 push :
55 branches :
66 - master
7+ tags :
8+ - ' *'
79 pull_request : {}
810
911jobs :
1719 distribution : ' temurin'
1820 java-version : ' 21'
1921
22+ - name : Get version from POM
23+ id : version
24+ if : github.event_name == 'push'
25+ run : |
26+ VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
27+ echo "version=$VERSION" >> $GITHUB_OUTPUT
28+ echo "is_snapshot=$(echo $VERSION | grep -q SNAPSHOT && echo true || echo false)" >>$GITHUB_OUTPUT
29+
2030 - name : Configure Maven settings
21- if : github.event_name == 'push' && github.ref == 'refs/heads/master'
31+ if : github.event_name == 'push'
2232 uses : s4u/maven-settings-action@v3.0.0
2333 with :
2434 servers : |
@@ -28,13 +38,20 @@ jobs:
2838 "password": "${{ secrets.CENTRAL_SONATYPE_PASSWORD }}"
2939 }]
3040
31- - name : Import GPG key
32- if : github.event_name == 'push' && github.ref == 'refs/heads/master '
41+ - name : Import GPG key for SNAPSHOT
42+ if : github.event_name == 'push' && steps.version.outputs.is_snapshot == 'true '
3343 uses : crazy-max/ghaction-import-gpg@v6
3444 with :
3545 gpg_private_key : ${{ secrets.GPG_TEST_PRIV_KEY }}
3646 passphrase : ${{ secrets.GPG_TEST_PASSPHRASE }}
3747
48+ - name : Import GPG key for release
49+ if : github.event_name == 'push' && steps.version.outputs.is_snapshot != 'true' && startsWith(github.ref, 'refs/tags/')
50+ uses : crazy-max/ghaction-import-gpg@v6
51+ with :
52+ gpg_private_key : ${{ secrets.GPG_RELEASE_PRIV_KEY }}
53+ passphrase : ${{ secrets.GPG_RELEASE_PASSPHRASE }}
54+
3855 - name : Download dependencies
3956 run : mvn --batch-mode dependency:go-offline
4057
@@ -48,19 +65,24 @@ jobs:
4865 run : mvn --batch-mode javadoc:javadoc
4966
5067 - name : Package without gpg
51- if : github.event_name != 'push' || github.ref != 'refs/heads/master'
68+ if : github.event_name != 'push'
5269 run : mvn --batch-mode package -Dmaven.test.skip=true -Dgpg.skip=true
5370
54- - name : Deploy
55- if : github.event_name == 'push' && github.ref == 'refs/heads/master'
71+ # Both "Deploy..." steps are calling the same, but separated to have clearer logs
72+ - name : Deploy SNAPSHOT
73+ if : github.event_name == 'push' && steps.version.outputs.is_snapshot == 'true'
74+ run : mvn --batch-mode deploy
75+
76+ - name : Deploy release
77+ if : github.event_name == 'push' && steps.version.outputs.is_snapshot != 'true' && startsWith(github.ref, 'refs/tags/')
5678 run : mvn --batch-mode deploy
5779
5880 - name : Upload build artifacts
5981 uses : actions/upload-artifact@v4
6082 with :
6183 name : java-runtime-${{ github.event_name }}-${{ github.event.number || github.sha }}
6284 path : target/*.jar
63- retention-days : ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && 30 || 7 }}
85+ retention-days : 30
6486
6587 - name : Upload test results
6688 uses : actions/upload-artifact@v4
0 commit comments