Publish to Maven Central #4
This file contains hidden or 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 to Maven Central | |
| on: | |
| workflow_dispatch: # Manual trigger | |
| release: | |
| types: [published] | |
| jobs: | |
| publish: | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Setup Xcode | |
| uses: maxim-lobanov/setup-xcode@v1 | |
| with: | |
| xcode-version: latest-stable | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v2 | |
| - name: Setup Gradle | |
| uses: gradle/gradle-build-action@v2 | |
| - name: Import GPG key | |
| run: | | |
| # Create GPG directory | |
| mkdir -p ~/.gnupg/ | |
| chmod 700 ~/.gnupg/ | |
| # Setup GPG on macOS | |
| 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 }} | |
| - 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: | | |
| if [[ ${{ github.event_name }} == 'release' ]]; then | |
| ./gradlew publishAllPublicationsToMavenCentral --no-daemon --no-parallel | |
| else | |
| ./gradlew publishAllPublicationsToMavenCentral --no-daemon --no-parallel | |
| fi |