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