Deploy to Maven Central and GitHub Releases #8
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
name: Deploy to Maven Central and GitHub Releases | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
workflow_dispatch: | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout code repository' | |
uses: actions/checkout@v3 | |
- name: 'Set up Java 17' | |
uses: actions/setup-java@v2 | |
with: | |
java-version: 17 | |
distribution: 'zulu' | |
server-id: ossrh | |
server-username: OSSRH_USERNAME | |
server-password: OSSRH_PASSWORD | |
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
- name: 'Cache Maven packages' | |
uses: actions/cache@v2 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: 'Import GPG key' | |
run: | | |
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import | |
- name: 'Release to Maven Central' | |
env: | |
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | |
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
run: | | |
export GPG_TTY=$(tty) | |
mvn --batch-mode --no-transfer-progress -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} clean deploy | |
- name: Create GitHub Release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ github.ref }} | |
name: ${{ github.ref }} | |
commit: ${{ github.sha }} | |
body: | | |
Release of version ${{ github.ref }} | |
token: ${{ secrets.GITHUB_TOKEN }} |