Release to Maven Central and Gradle Plugins #1
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 and Gradle Plugins | |
on: | |
workflow_dispatch: | |
inputs: | |
increment: | |
type: choice | |
description: Increment | |
required: true | |
options: | |
- Patch | |
- Minor | |
- Major | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Get current version | |
id: currenttag | |
uses: WyriHaximus/github-action-get-previous-tag@v1 | |
- name: Get next versions | |
id: nexttag | |
uses: WyriHaximus/github-action-next-semvers@v1 | |
with: | |
version: ${{ steps.currenttag.outputs.tag }} | |
- name: Determine release version | |
id: nextversion | |
run: | | |
case "${{ inputs.increment }}" in | |
Patch) | |
echo "version=${{ steps.nexttag.outputs.patch }}" >> $GITHUB_OUTPUT | |
;; | |
Minor) | |
echo "version=${{ steps.nexttag.outputs.minor }}" >> $GITHUB_OUTPUT | |
;; | |
Major) | |
echo "version=${{ steps.nexttag.outputs.major }}" >> $GITHUB_OUTPUT | |
;; | |
esac | |
- name: Update project version | |
run: | | |
sed -i 's/${{ steps.currenttag.outputs.tag }}/${{ steps.nextversion.outputs.version }}/g' ./gradle.properties | |
- name: Commit, push and tag | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git add . | |
git commit -m "Released version $VERSION" | |
git push | |
git tag $VERSION | |
git push origin $VERSION | |
env: | |
VERSION: ${{ steps.nextversion.outputs.version }} | |
- name: Github release | |
uses: release-drafter/release-drafter@v5 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Gradle publish | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: publishPlugins -Dgradle.publish.key=${{ secrets.PUBLISH_KEY }} -Dgradle.publish.secret=${{ secrets.PUBLISH_SECRET }} | |
gradle-version: wrapper | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Stage on Maven Central | |
uses: gradle/gradle-build-action@v2.5.1 | |
with: | |
arguments: > | |
publishAllPublicationsToOSSRHRepository | |
-Dsigning.keyId=${{ secrets.SIGNING_KEY }} | |
-Dsigning.password=${{ secrets.SIGNING_PASSWORD }} | |
-DossrhUsername=${{ secrets.OSSRH_USERNAME }} | |
-DossrhPassword=${{ secrets.OSSRH_PASSWORD }} | |
gradle-version: wrapper | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |