Release to maven central #15
This file contains 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: Release to maven central | |
on: | |
push: | |
tags: | |
- '*' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set tag name | |
run: | | |
VERSION=$(cat ./VERSION) | |
echo "TAG_NAME=$VERSION" >> $GITHUB_ENV | |
# if no tag exists, this is expected to fail | |
- name: Switch to git tag for release | |
if: contains(env.TAG_NAME, 'SNAPSHOT') != true | |
run: | | |
git fetch --all --tags | |
git checkout tags/${{ env.TAG_NAME }} -b ${{ env.TAG_NAME }}-tmp-branch | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 11 | |
- name: Publish snapshot with Gradle | |
if: contains(env.TAG_NAME, 'SNAPSHOT') == true | |
env: | |
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }} | |
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGNING_PASSWORD }} | |
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} | |
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} | |
run: ./gradlew --info clean publishToSonatype | |
- name: Close and release repository with Gradle | |
if: contains(env.TAG_NAME, 'SNAPSHOT') != true | |
env: | |
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }} | |
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGNING_PASSWORD }} | |
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} | |
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} | |
run: ./gradlew --info publishToSonatype closeAndReleaseSonatypeStagingRepository | |
- name: Create GHA release | |
uses: ncipollo/release-action@v1 | |
if: contains(env.TAG_NAME, 'SNAPSHOT') != true | |
with: | |
artifacts: "build/libs/*.jar" | |
bodyFile: RELEASE.md |