Skip to content

🛠️ Publish to Sonatype #9

🛠️ Publish to Sonatype

🛠️ Publish to Sonatype #9

Workflow file for this run

name: 🛠️ Publish to Sonatype
on:
release:
types: [published]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the code and clone submodules
- name: Checkout code and clone submodules
uses: actions/checkout@v4
# Step 2: Set up JDK 21
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "temurin"
# Step 3: Set up GPG
- name: Set up GPG key
run: |
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
echo "$GPG_PASSPHRASE" | gpg --batch --passphrase-fd 0 --pinentry-mode loopback --sign
# Step 4: Setup Gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: false
# Step 5: Grant execute permissions to gradlew
- name: Grant execute permissions to gradlew
run: chmod +x ./gradlew
# Step 6: Set version based on the release tag
- name: Set version based on release tag
run: echo VERSION=$(echo "${GITHUB_REF}" | sed 's/refs\/tags\///') >> $GITHUB_ENV
# Step 7: Build the project using Gradle
- name: Build with Gradle
run: ./gradlew build
# Step 8: Publish the project to Sonatype OSSRH
- name: Publish to Sonatype OSSRH
run: ./gradlew publish -Pversion=$VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
# Step 9: Send notification to Discord
- name: Send notification to Discord
uses: SethCohen/[email protected]
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }}
color: "391879"
username: "Java SDK"