Skip to content

Publish to Maven Central #1

Publish to Maven Central

Publish to Maven Central #1

Workflow file for this run

name: Publish to Maven Central
on:
workflow_dispatch: # Allows manual triggering of the workflow
release:
types: [published] # Triggers when a new release is published
jobs:
publish:
runs-on: macos-latest # Or ubuntu-latest, depending on your needs
steps:
- name: Checkout
uses: actions/checkout@v4 # Use a newer version of the checkout action
- name: Set up JDK 17 # Consistent with KopyBuilder; change if viform-multiplatform needs a different version
uses: actions/setup-java@v4
with:
java-version: '17' # Consistent with KopyBuilder; change if viform-multiplatform needs a different version
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3 # Use the new Gradle action path
- name: Import GPG key
run: |
# Create GPG directory
mkdir -p ~/.gnupg/
chmod 700 ~/.gnupg/
# Set GPG agent and conf for loopback pinentry
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
# Import key
echo "${{ secrets.GPG_KEY_CONTENTS }}" | base64 --decode | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
env:
GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }} # Needs to be configured in GitHub secrets
- name: Publish to Maven Central
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
# ORG_GRADLE_PROJECT_sonatypeStagingProfileId: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
run: |
./gradlew publishAllPublicationsToMavenCentral --no-daemon --no-parallel