Skip to content

Migrate from OSSRH to Sonatype Central publishing #21

Migrate from OSSRH to Sonatype Central publishing

Migrate from OSSRH to Sonatype Central publishing #21

Workflow file for this run

name: Publish to Sonatype Central
on:
push:
branches:
- sonatype-publish
tags:
- "[0-9]+.[0-9]+.[0-9]+*" # Match version tags like 3.5.13, 3.6.0-beta1, etc.
workflow_dispatch: # Allow manual trigger
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
cache: gradle
- name: Import GPG Key
run: |
echo "${{ secrets.GPG_SECRET_KEY }}" | base64 -d | gpg --batch --import
# Extract last 8 characters for short format
GPG_KEY="${{ secrets.GPG_KEY_ID }}"
echo "SHORT_GPG_KEY_ID=${GPG_KEY: -8}" >> $GITHUB_ENV
- name: Build and Publish to Sonatype Central
run: ./gradlew clean assemble publishAllPublicationsToCentralPortal
env:
ORG_GRADLE_PROJECT_SIGNING_KEY_ID: ${{ env.SHORT_GPG_KEY_ID }}
ORG_GRADLE_PROJECT_SIGNING_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}
ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}