Skip to content

Publish package to Maven Central and Gradle Plugin Portal #55

Publish package to Maven Central and Gradle Plugin Portal

Publish package to Maven Central and Gradle Plugin Portal #55

Workflow file for this run

name: Publish package to Maven Central and Gradle Plugin Portal
on:
workflow_dispatch:
inputs:
mode:
description: 'staging/snapshot, default is snapshot'
required: true
default: 'snapshot'
jobs:
publish:
runs-on: ${{ matrix.operating-system }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
operating-system: [ macos-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '21'
cache: 'gradle'
- name: Read and update version
run: |
BASE_VERSION=$(grep "^version=" gradle.properties | cut -d'=' -f2)
if [[ "${{ github.event.inputs.mode }}" == "staging" ]]; then
BASE_VERSION=${BASE_VERSION/-SNAPSHOT/}
fi
echo "VERSION=${BASE_VERSION}" >> $GITHUB_ENV
echo "Version: $BASE_VERSION"
- name: Create jreleaser work directory
run: mkdir -p ./build/jreleaser
- name: Build the repository
run: ./gradlew build
- name: Create stage deploy (macOS)
if: runner.os == 'macOS'
run: ./gradlew :jvmti:publish -Pversion=$VERSION
- name: Create stage deploy (Linux)
if: runner.os == 'Linux'
run: ./gradlew publish -Pversion=$VERSION
- name: Publish to Maven Central
continue-on-error: true
run: ./gradlew jreleaserFullRelease -Pversion=$VERSION
env:
JRELEASER_MAVENCENTRAL_USERNAME: ${{secrets.JRELEASER_MAVENCENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{secrets.JRELEASER_MAVENCENTRAL_PASSWORD}}
JRELEASER_GPG_PASSPHRASE: ${{secrets.JRELEASER_GPG_PASSPHRASE}}
JRELEASER_GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
JRELEASER_GPG_PUBLIC_KEY: ${{secrets.JRELEASER_GPG_PUBLIC_KEY}}
JRELEASER_GPG_SECRET_KEY: ${{secrets.JRELEASER_GPG_SECRET_KEY}}
- name: Publish to Gradle Plugins Portal
if: runner.os == 'Linux'
run: ./gradlew publishPlugins -Pversion=$VERSION
env:
GRADLE_PUBLISH_KEY: ${{secrets.GRADLE_PUBLISH_KEY}}
GRADLE_PUBLISH_SECRET: ${{secrets.GRADLE_PUBLISH_SECRET}}
- uses: actions/create-release@v1
if: runner.os == 'Linux' && github.event.inputs.mode == 'staging'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: "Release ${{ env.VERSION }}"
body: |
This release includes the following:
- Version: `${{ env.VERSION }}`
- Published packages are available in Maven central.
draft: false
prerelease: true