Skip to content
# This workflow will build a GitHub published release of a Java project with Maven, sign the artifacts and deploy them to Maven\
# Central (Sonatype Open Source Software Repository Hosting (OSSRH))
#
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: DeployReleaseToMavenCentral
on:
release:
types: [ published ]
jobs:
release:
name: Deploy Release to Maven Central Sonatype OSSRH
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with Maven
# checks that jar and javadoc builds
# javadoc jar will be reused in the mvn deploy
run: mvn -B package --file pom.xml
- name: Set up Maven settings and import GPG keys
uses: actions/setup-java@v1
with: # running setup-java again overwrites the settings.xml
java-version: 11
server-id: ossrh
server-username: OSSRH_USERNAME
server-password: OSSRH_PASSWORD
gpg-private-key: ${{ secrets.GPG_SECRET_KEYS_ARMOR }}
gpg-passphrase: GPG_PASSPHRASE
- name: Sign and publish to Maven Central
run: mvn -P ossrh,release deploy
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}