Publish to Maven Central when a tag is pushed #124
Workflow file for this run
This file contains 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
# This workflow will build a Java project with Maven | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | |
name: Java CI with Maven | |
on: | |
push: | |
branches: [master] | |
tags: ["**"] | |
pull_request: | |
branches: [master] | |
jobs: | |
build: | |
env: | |
SQUARE_ENVIRONMENT: sandbox | |
SQUARE_ACCESS_TOKEN: ${{ secrets.SQUARE_SANDBOX_TOKEN }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: "8" | |
distribution: "adopt" | |
- name: Build with Maven | |
run: mvn test -B | |
- name: Import signing key | |
if: ${{ github.ref_type == 'tag' }} | |
env: | |
ARTIFACT_SIGNING_PRIVATE_KEY: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }} | |
run: | | |
echo "-----BEGIN PGP PUBLIC KEY BLOCK-----" > key.txt | |
echo "$ARTIFACT_SIGNING_PRIVATE_KEY" >> key.txt | |
echo "-----END PGP PUBLIC KEY BLOCK-----" >> key.txt | |
gpg --import key.txt | |
- name: Release to Maven Central | |
if: ${{ github.ref_type == 'tag' }} | |
env: | |
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }} | |
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} | |
run: mvn package gpg:sign deploy --batch-mode --settings .maven_settings.xml | |
labeler: | |
needs: build | |
if: ${{ github.event_name == 'pull_request' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: automerge-labeler | |
uses: fuxingloh/multi-labeler@v1 | |
automerge: | |
needs: labeler | |
if: ${{ github.event_name == 'pull_request' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: automerge | |
uses: "pascalgn/[email protected]" | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
MERGE_LABELS: "automerge,automerge-branch,automerge-author" |