Skip to content

Deploy to Maven Central and GitHub Releases #8

Deploy to Maven Central and GitHub Releases

Deploy to Maven Central and GitHub Releases #8

Workflow file for this run

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 }}