1111
1212 name : build java ${{ matrix.java }}
1313 steps :
14- - uses : actions/checkout@v4
14+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1515 - name : Set up java
16- uses : actions/setup-java@v3
16+ uses : actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
1717 with :
1818 java-version : ${{ matrix.java }}
1919 distribution : temurin
@@ -23,49 +23,41 @@ jobs:
2323 - name : Build with Maven
2424 run : mvn -B package --no-transfer-progress --file pom.xml
2525
26- makeversion :
27- if : github.ref != 'refs/heads/main'
26+ publish :
2827 needs : build
28+ name : Publish ${{ github.ref_name }}
2929 runs-on : ubuntu-latest
30- name : Create version
31- outputs :
32- version : ${{ steps.version.outputs.version }}
3330 steps :
34- - name : Decide on build version
35- id : version
31+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
32+ - name : Set up Java
33+ uses : actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
34+ with :
35+ distribution : temurin
36+ java-version : ' 21'
37+ cache : " maven"
38+ gpg-private-key : ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PRIVATE }}
39+ server-id : central
40+ server-username : MAVEN_CENTRAL_TOKEN_USERNAME
41+ server-password : MAVEN_CENTRAL_TOKEN_PASSWORD
42+ gpg-passphrase : MAVEN_GPG_PASSPHRASE
43+ - name : Activate Artifact Signing and Version Suffix
3644 run : |
37- if [[ $GITHUB_REF == *"tags"* ]]; then
38- TAG=${GITHUB_REF#refs/tags/}
45+ profiles="build-sources-and-javadoc,deploy-to-maven-central"
46+ if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
47+ profiles="$profiles,sign-artifacts"
48+ version_suffix=""
3949 else
40- TAG=${GITHUB_REF#refs/heads/} -SNAPSHOT
50+ version_suffix=" -SNAPSHOT"
4151 fi
42- echo "version=${TAG//\//-}" >> $GITHUB_OUTPUT
43-
44- deploy_snapshot :
45- if : startsWith(github.ref, 'refs/heads/')
46- needs : makeversion
47- runs-on : ubuntu-latest
48-
49- name : Deploy snapshot
50- steps :
51- - uses : actions/checkout@v4
52- -
uses :
digipost/[email protected] 53- with :
54- sonatype_secrets : ${{ secrets.sonatype_secrets }}
55- release_version : ${{ needs.makeversion.outputs.version }}
56- perform_release : false
57-
58- release :
59- if : startsWith(github.ref, 'refs/tags/')
60- runs-on : ubuntu-latest
61- needs : makeversion
62- name : Release to Sonatype
63- steps :
64- - name : Check out Git repository
65- uses : actions/checkout@v4
66- - name : Release to Central Repository
67- 68- with :
69- sonatype_secrets : ${{ secrets.sonatype_secrets }}
70- release_version : ${{ needs.makeversion.outputs.version }}
71- perform_release : true
52+ echo "MAVEN_PROFILES=$profiles" >> $GITHUB_ENV
53+ version="${GITHUB_REF_NAME}${version_suffix}"
54+ echo "VERSION=$version" >> $GITHUB_ENV
55+ - name : Set Maven version
56+ run : mvn --batch-mode --no-transfer-progress versions:set -DnewVersion=${VERSION}
57+ - name : Build and deploy to Maven Central
58+ run : |
59+ mvn --batch-mode --no-transfer-progress --activate-profiles ${MAVEN_PROFILES} deploy
60+ env :
61+ MAVEN_CENTRAL_TOKEN_USERNAME : ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }}
62+ MAVEN_CENTRAL_TOKEN_PASSWORD : ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }}
63+ MAVEN_GPG_PASSPHRASE : ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PASSPHRASE }}
0 commit comments