Publish a release to the Maven Central Repository #5
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: Publish a release to the Maven Central Repository | |
on: | |
workflow_dispatch: | |
inputs: | |
release: | |
description: Is release? (Will update master version.txt) | |
required: true | |
default: false | |
type: boolean | |
tagged-version: | |
description: Release Version (For tagged version.txt) | |
required: true | |
type: string | |
new-version: | |
description: New Version (For branch version.txt) | |
required: true | |
type: string | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: false | |
env: | |
GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.java.installations.auto-detect=false -Dorg.gradle.warning.mode=fail' | |
jobs: | |
tag-release: | |
permissions: | |
contents: write | |
runs-on: self-hosted | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: update-tag | |
if: ${{ inputs.release }} | |
run: | | |
git config user.name "github-actions" | |
git config user.email "github-actions" | |
echo ${{ inputs.tagged-version }} > version.txt | |
git add version.txt | |
git status | |
git commit -m "${{ inputs.tagged-version }} released." | |
git tag ${{ inputs.tagged-version }} | |
git push | |
git push origin refs/tags/${{ inputs.tagged-version }} | |
build-java: | |
name: Release task | |
permissions: | |
contents: write | |
packages: write | |
needs: tag-release | |
runs-on: self-hosted | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Setup java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 8 | |
- name: Setup BUILD_JAVA_HOME & BUILD_JAVA_VERSION | |
run: | | |
java -Xinternalversion | |
echo "BUILD_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV | |
echo "BUILD_JAVA_VERSION=8" >> $GITHUB_ENV | |
- name: Publish a release | |
run: ./gradlew publish | |
env: | |
SIGNING_GPG_SECRET_KEY: ${{ secrets.signingKey }} | |
SIGNING_GPG_PASSWORD: ${{ secrets.signingPassword }} | |
OSSRH_USERNAME: ${{ secrets.ossrhUsername }} | |
OSSRH_PASSWORD: ${{ secrets.ossrhPassword }} | |
update-tags: | |
permissions: | |
contents: write | |
needs: build-java | |
runs-on: self-hosted | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: update-branch | |
if: ${{ inputs.release }} | |
run: | | |
git config user.name "github-actions" | |
git config user.email "github-actions" | |
echo ${{ inputs.new-version }} > version.txt | |
git add version.txt | |
git status | |
git commit -m "${{ inputs.tagged-version }} released." | |
git push |