Publish package to MavenCentral #4
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: Publish package to MavenCentral | |
on: | |
release: | |
types: [ created ] | |
workflow_dispatch: | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Set version | |
id: version | |
run: | | |
DATE=$(date +'%Y%m%d') | |
HASH=$(git rev-parse --short HEAD) | |
echo "VERSION=${DATE}-${HASH}" >> $GITHUB_ENV | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Configure GPG Key | |
run: | | |
echo -n "${{ secrets.GPG_SIGNING_KEY }}" | base64 --decode > $HOME/secring.gpg | |
- name: Publish package | |
run: ./gradlew publish -Pversion=$VERSION -Psigning.secretKeyRingFile="$HOME/secring.gpg" -Psigning.password="${{ secrets.GPG_SIGNING_KEY_PASSWORD }}" -Psigning.keyId="${{ secrets.GPG_SIGNING_KEY_ID }}" -PsonatypeUsername="${{ secrets.SONATYPE_USERNAME }}" -PsonatypePassword="${{ secrets.SONATYPE_PASSWORD }}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |