4
4
push :
5
5
branches :
6
6
- master
7
+ tags :
8
+ - ' *'
7
9
pull_request : {}
8
10
9
11
jobs :
17
19
distribution : ' temurin'
18
20
java-version : ' 21'
19
21
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
+
20
30
- name : Configure Maven settings
21
- if : github.event_name == 'push' && github.ref == 'refs/heads/master'
31
+ if : github.event_name == 'push'
22
32
uses : s4u/maven-settings-action@v3.0.0
23
33
with :
24
34
servers : |
@@ -28,13 +38,20 @@ jobs:
28
38
"password": "${{ secrets.CENTRAL_SONATYPE_PASSWORD }}"
29
39
}]
30
40
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 '
33
43
uses : crazy-max/ghaction-import-gpg@v6
34
44
with :
35
45
gpg_private_key : ${{ secrets.GPG_TEST_PRIV_KEY }}
36
46
passphrase : ${{ secrets.GPG_TEST_PASSPHRASE }}
37
47
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
+
38
55
- name : Download dependencies
39
56
run : mvn --batch-mode dependency:go-offline
40
57
@@ -48,19 +65,24 @@ jobs:
48
65
run : mvn --batch-mode javadoc:javadoc
49
66
50
67
- name : Package without gpg
51
- if : github.event_name != 'push' || github.ref != 'refs/heads/master'
68
+ if : github.event_name != 'push'
52
69
run : mvn --batch-mode package -Dmaven.test.skip=true -Dgpg.skip=true
53
70
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/')
56
78
run : mvn --batch-mode deploy
57
79
58
80
- name : Upload build artifacts
59
81
uses : actions/upload-artifact@v4
60
82
with :
61
83
name : java-runtime-${{ github.event_name }}-${{ github.event.number || github.sha }}
62
84
path : target/*.jar
63
- retention-days : ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && 30 || 7 }}
85
+ retention-days : 30
64
86
65
87
- name : Upload test results
66
88
uses : actions/upload-artifact@v4
0 commit comments