88 - ' v*'
99
1010jobs :
11+ version :
12+ runs-on : ubuntu-latest
13+
14+ outputs :
15+ VERSION : ${{ steps.setver.outputs.VERSION }}
16+
17+ steps :
18+ - name : Cache Maven repo
19+ uses : actions/cache@v4
20+ with :
21+ path : ~/.m2/repository
22+ key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
23+ restore-keys : |
24+ ${{ runner.os }}-m2-
25+
26+ - name : Determine version
27+ id : setver
28+ run : |
29+ if [[ "$GITHUB_REF" == refs/tags/* ]]; then
30+ RAW_TAG=${GITHUB_REF#refs/tags/}
31+ VERSION=${RAW_TAG#v}
32+ VERSION=${VERSION#V}
33+ else
34+ VERSION=1.0.0-SNAPSHOT
35+ fi
36+ echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
37+
1138 build :
1239 runs-on : ubuntu-latest
40+ needs : version
41+
1342 steps :
14- # --- Checkout ---
43+ - name : Cache Maven repo
44+ uses : actions/cache@v4
45+ with :
46+ path : ~/.m2/repository
47+ key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
48+ restore-keys : |
49+ ${{ runner.os }}-m2-
50+
1551 - name : Checkout code
1652 uses : actions/checkout@v4
53+
54+ - name : Setup JDK
55+ uses : actions/setup-java@v4
56+ with :
57+ java-version : ' 21'
58+ distribution : temurin
59+
60+ - name : Set version
61+ run : |
62+ mvn -B versions:set -DnewVersion=${{ needs.version.outputs.VERSION }}
63+ mvn -B versions:set-property -Dproperty=revision -DnewVersion=${{ needs.version.outputs.VERSION }}
64+
65+ - name : Build
66+ run : mvn -B -DskipTests package
67+
68+ test :
69+ runs-on : ubuntu-latest
70+ needs : version
71+
72+ steps :
73+ - name : Cache Maven repo
74+ uses : actions/cache@v4
75+ with :
76+ path : ~/.m2/repository
77+ key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
78+ restore-keys : |
79+ ${{ runner.os }}-m2-
80+
81+ - name : Checkout
82+ uses : actions/checkout@v4
83+
84+ - name : Set up JDK
85+ uses : actions/setup-java@v4
86+ with :
87+ java-version : ' 21'
88+ distribution : temurin
89+
90+ - name : Set version
91+ run : |
92+ mvn -B versions:set -DnewVersion=${{ needs.version.outputs.VERSION }}
93+ mvn -B versions:set-property -Dproperty=revision -DnewVersion=${{ needs.version.outputs.VERSION }}
94+
95+ - name : Run tests
96+ run : mvn -B test
97+
98+ deploy :
99+ runs-on : ubuntu-latest
100+ needs : [ version, test, build ]
101+ if : github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
102+
103+ steps :
104+ - name : Cache Maven repo
105+ uses : actions/cache@v4
106+ with :
107+ path : ~/.m2/repository
108+ key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
109+ restore-keys : |
110+ ${{ runner.os }}-m2-
111+
112+ - name : Checkout
113+ uses : actions/checkout@v4
17114 with :
18115 fetch-depth : 0
19116
20- # --- Setup Java + GPG ---
21- - name : Setup JDK
22- uses : actions/setup-java@v3
117+ - name : Set up JDK + GPG
118+ uses : actions/setup-java@v4
23119 with :
24120 java-version : ' 21'
25121 distribution : temurin
@@ -29,26 +125,12 @@ jobs:
29125 gpg-private-key : ${{ secrets.GPG_PRIVATE_KEY }}
30126 gpg-passphrase : GPG_PASSPHRASE
31127
32- # --- Determine version ---
33- - name : Determine version
34- run : |
35- if [[ "$GITHUB_REF" == refs/tags/* ]]; then
36- RAW_TAG=${GITHUB_REF#refs/tags/}
37- VERSION=${RAW_TAG#v}
38- VERSION=${VERSION#V}
39- else
40- VERSION=1.0.0-SNAPSHOT
41- fi
42- echo "VERSION=$VERSION" >> $GITHUB_ENV
43-
44- # --- Set Maven project version ---
45- - name : Set Maven version
128+ - name : Set version
46129 run : |
47- mvn -B versions:set -DnewVersion=$VERSION
48- mvn -B versions:set-property -Dproperty=revision -DnewVersion=$VERSION
130+ mvn -B versions:set -DnewVersion=${{ needs.version.outputs. VERSION }}
131+ mvn -B versions:set-property -Dproperty=revision -DnewVersion=${{ needs.version.outputs. VERSION }}
49132
50- # --- Build and deploy ---
51- - name : Build & Deploy
133+ - name : Deploy to Maven Central
52134 env :
53135 OSSRH_USERNAME : ${{ secrets.OSSRH_USERNAME }}
54136 OSSRH_PASSWORD : ${{ secrets.OSSRH_PASSWORD }}
0 commit comments