Release #64
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 | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "Release version" | |
required: true | |
next: | |
description: "Next version" | |
required: false | |
env: | |
JAVA_VERSION: '23' | |
JAVA_DISTRO: 'temurin' | |
jobs: | |
precheck: | |
runs-on: ubuntu-latest | |
outputs: | |
HEAD: ${{ steps.version.outputs.HEAD }} | |
NEXT_VERSION: ${{ steps.version.outputs.NEXT_VERSION }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: 'Set up Java' | |
uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ env.JAVA_VERSION }} | |
distribution: ${{ env.JAVA_DISTRO }} | |
- name: 'Cache Maven packages' | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven- | |
- name: 'Set release version' | |
id: version | |
run: | | |
RELEASE_VERSION=${{ github.event.inputs.version }} | |
NEXT_VERSION=${{ github.event.inputs.next }} | |
PLAIN_VERSION=`echo ${RELEASE_VERSION} | awk 'match($0, /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)/) { print substr($0, RSTART, RLENGTH); }'` | |
COMPUTED_NEXT_VERSION="${PLAIN_VERSION}-SNAPSHOT" | |
if [ -z $NEXT_VERSION ] | |
then | |
NEXT_VERSION=$COMPUTED_NEXT_VERSION | |
fi | |
./mvnw -B -ntp -ntp versions:set versions:commit -DnewVersion=$RELEASE_VERSION | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "GitHub Action" | |
git commit -a -m "🏁 Releasing version $RELEASE_VERSION" | |
git push origin HEAD:main | |
HEAD=`git rev-parse HEAD` | |
echo "NEXT_VERSION=$(echo $NEXT_VERSION)" >>$GITHUB_OUTPUT | |
echo "HEAD=$(echo $HEAD)" >>$GITHUB_OUTPUT | |
# Build native executable per runner | |
build: | |
needs: [ precheck ] | |
name: 'Build with Graal on ${{ matrix.os }}' | |
strategy: | |
fail-fast: true | |
matrix: | |
os: [ ubuntu-latest, macos-13, macos-14, windows-latest ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: 'Check out repository' | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.precheck.outputs.HEAD }} | |
- name: 'Set up Graal' | |
uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: ${{ env.JAVA_VERSION }} | |
distribution: 'graalvm' | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: 'Cache Maven packages' | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven- | |
- name: 'Build Native Image' | |
run: ./mvnw -B -ntp --file pom.xml -Pnative native:compile | |
- name: 'Create distribution' | |
run: ./mvnw -B -ntp --file pom.xml -Pdist package -DskipTests | |
- name: 'Upload build artifact' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-${{ matrix.os }} | |
path: | | |
target/distributions/*.zip | |
- name: 'Upload jar build artifact' | |
uses: actions/upload-artifact@v4 | |
if: matrix.os == 'ubuntu-latest' | |
with: | |
name: artifacts-jar | |
path: | | |
target/*.jar | |
# Collect all executables and release | |
release: | |
needs: [ precheck, build ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Check out repository' | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.precheck.outputs.HEAD }} | |
fetch-depth: 0 | |
- name: 'Download all build artifacts' | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: artifacts-* | |
merge-multiple: true | |
path: artifacts | |
- name: 'Set up Java' | |
uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ env.JAVA_VERSION }} | |
distribution: ${{ env.JAVA_DISTRO }} | |
- name: 'Cache Maven packages' | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven- | |
- name: 'Release with JReleaser' | |
env: | |
JRELEASER_GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }} | |
JRELEASER_CHOCOLATEY_GITHUB_TOKEN: ${{ secrets.JRELEASER_CHOCOLATEY_GITHUB_TOKEN }} | |
JRELEASER_CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }} | |
run: ./mvnw -B -ntp --file pom.xml -Prelease -DartifactsDir=artifacts jreleaser:full-release | |
- name: Capture JReleaser output | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: jreleaser-release-output | |
retention-days: 7 | |
path: | | |
target/jreleaser/trace.log | |
target/jreleaser/output.properties | |
- name: 'Set next version' | |
run: | | |
./mvnw -B -ntp versions:set versions:commit -DnewVersion=${{ needs.precheck.outputs.NEXT_VERSION }} | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "GitHub Action" | |
git commit -a -m "⬆️ Next version $NEXT_VERSION" | |
git push origin HEAD:main |