Publish a new release #21
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
# Inspired from https://foojay.io/today/how-to-release-a-java-module-with-jreleaser-to-maven-central-with-github-actions/ | |
name: Publish a new release | |
on: | |
workflow_dispatch: | |
inputs: | |
previousVersion: | |
description: 'Previous version' | |
required: true | |
version: | |
description: 'Release version' | |
required: true | |
nextVersion: | |
description: 'Next version after release (-SNAPSHOT will be added automatically)' | |
required: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Java setup | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
cache: maven | |
- name: Run a build of the code base before release | |
run: ./mvnw --batch-mode --no-transfer-progress clean install | |
- name: Set release version | |
run: ./mvnw --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.version }} | |
- name: Commit & Push changes | |
uses: actions-js/[email protected] | |
with: | |
branch: '1.x' | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
message: "chore: releasing version ${{ github.event.inputs.version }}" | |
- name: Release with JReleaser | |
env: | |
JRELEASER_TAG_NAME: ${{ github.event.inputs.version }} | |
JRELEASER_PREVIOUS_TAG_NAME: ${{ github.event.inputs.previousVersion }} | |
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} | |
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} | |
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} | |
JRELEASER_NEXUS2_USERNAME: ${{ secrets.JRELEASER_NEXUS2_USERNAME }} | |
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.JRELEASER_NEXUS2_PASSWORD }} | |
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: ./release.sh | |
- name: Set the next release version | |
run: ./mvnw --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.nextVersion }}-SNAPSHOT | |
- name: Commit & Push changes | |
uses: actions-js/[email protected] | |
with: | |
branch: '1.x' | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
message: "chore: setting version ${{ github.event.inputs.nextVersion }}-SNAPSHOT" |