diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 39f1685..ec2ffc6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,49 +21,41 @@ jobs: - name: Build with Maven run: mvn --settings .mvn/settings.xml -B verify -U --no-transfer-progress - makeversion: - if: github.ref != 'refs/heads/main' - needs: build - runs-on: ubuntu-latest - name: Create version - outputs: - version: ${{ steps.version.outputs.version }} - steps: - - name: Decide on build version - id: version - run: | - if [[ $GITHUB_REF == *"tags"* ]]; then - TAG=${GITHUB_REF#refs/tags/} - else - TAG=${GITHUB_REF#refs/heads/}-SNAPSHOT - fi - echo "version=${TAG//\//-}" >> $GITHUB_OUTPUT - - deploy_snapshot: - if: startsWith(github.ref, 'refs/heads/') - needs: makeversion - runs-on: ubuntu-latest - - name: Deploy snapshot - steps: - - uses: actions/checkout@v3 - - uses: digipost/action-maven-publish@1.3.2 - with: - sonatype_secrets: ${{ secrets.sonatype_secrets }} - release_version: ${{ needs.makeversion.outputs.version }} - perform_release: false - - release: - if: startsWith(github.ref, 'refs/tags/') - runs-on: ubuntu-latest - needs: makeversion - name: Release to Sonatype - steps: - - name: Check out Git repository - uses: actions/checkout@v3 - - name: Release to Central Repository - uses: digipost/action-maven-publish@1.3.2 - with: - sonatype_secrets: ${{ secrets.sonatype_secrets }} - release_version: ${{ needs.makeversion.outputs.version }} - perform_release: true + publish: + needs: build + name: Publish ${{ github.ref_name }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.2.2 + - name: Set up Java + uses: actions/setup-java@v4.7.1 + with: + distribution: temurin + java-version: '21' + cache: "maven" + gpg-private-key: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PRIVATE }} + server-id: central + server-username: MAVEN_CENTRAL_TOKEN_USERNAME + server-password: MAVEN_CENTRAL_TOKEN_PASSWORD + gpg-passphrase: MAVEN_GPG_PASSPHRASE + - name: Activate Artifact Signing and Version Suffix + run: | + profiles="build-sources-and-javadoc,deploy-to-maven-central" + if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then + profiles="$profiles,sign-artifacts" + version_suffix="" + else + version_suffix="-SNAPSHOT" + fi + echo "MAVEN_PROFILES=$profiles" >> $GITHUB_ENV + version="${GITHUB_REF_NAME}${version_suffix}" + echo "VERSION=$version" >> $GITHUB_ENV + - name: Set Maven version + run: mvn --batch-mode --no-transfer-progress versions:set -DnewVersion=${VERSION} + - name: Build and deploy to Maven Central + run: | + mvn --batch-mode --no-transfer-progress --activate-profiles ${MAVEN_PROFILES} deploy + env: + MAVEN_CENTRAL_TOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }} + MAVEN_CENTRAL_TOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PASSPHRASE }} diff --git a/pom.xml b/pom.xml index a1214fd..19ec2cb 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ no.digipost digipost-open-super-pom - 13 + 14 printability-validator