Merge pull request #363 from digipost/upgrade-maven-central-deploy-wi… #403
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and deploy | |
| on: [push] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| java: [ '8', '11' ] | |
| name: build java ${{ matrix.java }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Set up java | |
| uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 | |
| with: | |
| java-version: ${{ matrix.java }} | |
| distribution: temurin | |
| cache: "maven" | |
| - name: Build with Maven | |
| run: mvn --settings .mvn/settings.xml -B verify -U --no-transfer-progress | |
| publish: | |
| needs: build | |
| name: Publish ${{ github.ref_name }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Set up Java | |
| uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 | |
| with: | |
| distribution: temurin | |
| java-version: '8' | |
| 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 }} |