Skip to content

Commit cfedd1e

Browse files
committed
Add CI/CD workflows for native image builds and releases
- Add build-cli-native workflow: 4-platform matrix (linux-amd64, linux-arm64, windows-amd64, macos-arm64); windows-arm64 excluded as GraalVM/Liberica NIK has no native Windows ARM64 support - Clear MAVEN_OPTS in native build step to prevent jvm.config options (heap size, --add-exports) propagating to the native-image subprocess - Use pwsh shell on Windows for native build to invoke mvnw.cmd - Add prepare-cli-native-release workflow: creates draft GitHub release, builds native binaries, uploads as release assets; pass --repo to gh release upload as the job has no checkout step for git context - Add setup-native composite action using Liberica NIK JDK 17
1 parent df58306 commit cfedd1e

File tree

9 files changed

+161
-4
lines changed

9 files changed

+161
-4
lines changed

.github/actions/create-github-release/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ runs:
1414
milestone: ${{ inputs.milestone }}
1515
token: ${{ inputs.token }}
1616
config-file: .github/actions/create-github-release/changelog-generator.yml
17-
- name: Create GitHub Release
17+
- name: Publish GitHub Release
1818
env:
1919
GITHUB_TOKEN: ${{ inputs.token }}
2020
shell: bash
21-
run: gh release create ${{ format('v{0}', inputs.milestone) }} --notes-file changelog.md
21+
run: gh release edit ${{ format('v{0}', inputs.milestone) }} --draft=false --notes-file changelog.md
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: 'Setup Native'
2+
runs:
3+
using: composite
4+
steps:
5+
- name: Set Up GraalVM
6+
uses: graalvm/setup-graalvm@v1
7+
with:
8+
distribution: liberica
9+
java-version: '17'
10+
cache: maven
11+
components: native-image
12+
github-token: ${{ github.token }}
13+
- name: Disable Java Problem Matcher
14+
shell: bash
15+
run: echo "::remove-matcher owner=java::"
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build CLI Native
2+
on:
3+
workflow_call:
4+
workflow_dispatch:
5+
permissions:
6+
contents: read
7+
jobs:
8+
build:
9+
name: Build (${{ matrix.name }})
10+
runs-on: ${{ matrix.runs-on }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
include:
15+
- name: linux-amd64
16+
os: linux
17+
arch: amd64
18+
runs-on: ubuntu-latest
19+
- name: linux-arm64
20+
os: linux
21+
arch: arm64
22+
runs-on: ubuntu-24.04-arm
23+
- name: windows-amd64
24+
os: windows
25+
arch: amd64
26+
runs-on: windows-latest
27+
- name: macos-arm64
28+
os: macos
29+
arch: arm64
30+
runs-on: macos-14
31+
steps:
32+
- name: Check Out
33+
uses: actions/checkout@v4
34+
- name: Set Up
35+
uses: ./.github/actions/setup-native
36+
- name: Build
37+
if: matrix.os != 'windows'
38+
shell: bash
39+
env:
40+
MAVEN_OPTS: ""
41+
run: ./mvnw -pl spring-javaformat-cli -am -Pnative package --batch-mode --no-transfer-progress --update-snapshots
42+
- name: Build
43+
if: matrix.os == 'windows'
44+
shell: pwsh
45+
env:
46+
MAVEN_OPTS: ""
47+
run: .\mvnw.cmd -pl spring-javaformat-cli -am -Pnative package --batch-mode --no-transfer-progress --update-snapshots
48+
- name: Prepare Artifact
49+
shell: bash
50+
run: |
51+
binary="spring-javaformat-cli/target/spring-javaformat-cli"
52+
extension=""
53+
if [[ "${{ matrix.os }}" == "windows" ]]; then
54+
binary="${binary}.exe"
55+
extension=".exe"
56+
fi
57+
release_name="spring-javaformat-${{ matrix.os }}-${{ matrix.arch }}${extension}"
58+
mkdir -p native-artifacts
59+
cp "${binary}" "native-artifacts/${release_name}"
60+
- name: Upload Artifact
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: spring-javaformat-${{ matrix.os }}-${{ matrix.arch }}
64+
path: native-artifacts/*

.github/workflows/build-pull-request.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,14 @@ jobs:
1414
uses: ./.github/actions/setup
1515
- name: Build
1616
run: ./mvnw clean install --batch-mode --no-transfer-progress --update-snapshots
17+
build-cli-native:
18+
name: Build CLI Native
19+
runs-on: ubuntu-latest
20+
if: ${{ github.repository == 'spring-io/spring-javaformat' }}
21+
steps:
22+
- name: Check Out
23+
uses: actions/checkout@v4
24+
- name: Set Up Native
25+
uses: ./.github/actions/setup-native
26+
- name: Build CLI Native
27+
run: ./mvnw -pl spring-javaformat-cli -am -Pnative package --batch-mode --no-transfer-progress --update-snapshots
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Prepare CLI Native Release
2+
on:
3+
workflow_call:
4+
inputs:
5+
version:
6+
type: string
7+
required: true
8+
secrets:
9+
gh-token:
10+
required: true
11+
permissions:
12+
contents: write
13+
jobs:
14+
create-draft-release:
15+
name: Create Draft GitHub Release
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check Out
19+
uses: actions/checkout@v4
20+
- name: Create Draft GitHub Release
21+
env:
22+
GH_TOKEN: ${{ secrets.gh-token }}
23+
shell: bash
24+
run: gh release create ${{ format('v{0}', inputs.version) }} --draft --verify-tag --notes "Draft release"
25+
build:
26+
name: Build
27+
needs: create-draft-release
28+
uses: ./.github/workflows/build-cli-native.yml
29+
upload-assets:
30+
name: Upload Assets
31+
needs:
32+
- create-draft-release
33+
- build
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Download Native Artifacts
37+
uses: actions/download-artifact@v4
38+
with:
39+
pattern: spring-javaformat-*
40+
path: native-artifacts
41+
merge-multiple: true
42+
- name: Upload Assets to Draft Release
43+
env:
44+
GH_TOKEN: ${{ secrets.gh-token }}
45+
run: gh release upload ${{ format('v{0}', inputs.version) }} native-artifacts/* --clobber --repo ${{ github.repository }}

.github/workflows/promote.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
build-number: ${{ inputs.build-number }}
8686
artifactory-username: ${{ secrets.ARTIFACTORY_USERNAME }}
8787
artifactory-password: ${{ secrets.ARTIFACTORY_PASSWORD }}
88-
- name: Create GitHub Release
88+
- name: Publish GitHub Release
8989
uses: ./.github/actions/create-github-release
9090
with:
9191
milestone: ${{ inputs.version }}

.github/workflows/release.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
description: Environment
99
type: environment
1010
required: true
11+
permissions:
12+
contents: write
1113
jobs:
1214
stage:
1315
name: Stage
@@ -49,9 +51,19 @@ jobs:
4951
outputs:
5052
release-version: ${{ steps.deduce-versions.outputs.release-version }}
5153
release-build-number: ${{ github.run_number }}
54+
prepare-cli-native-release:
55+
name: Prepare CLI Native Release
56+
needs: stage
57+
uses: ./.github/workflows/prepare-cli-native-release.yml
58+
with:
59+
version: ${{ needs.stage.outputs.release-version }}
60+
secrets:
61+
gh-token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
5262
promote:
5363
name: Promote
54-
needs: stage
64+
needs:
65+
- stage
66+
- prepare-cli-native-release
5567
uses: ./.github/workflows/promote.yml
5668
with:
5769
environment: ${{ inputs.environment }}

.github/workflows/rollback.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,10 @@ jobs:
3939
build_name=${{ format('spring-javaformat-{0}', inputs.version)}}
4040
build_number=${{ inputs.build-number }}
4141
jf rt delete --build ${build_name}/${build_number}
42+
- name: Delete Draft GitHub Release
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
45+
run: |
46+
if gh release view ${{ format('v{0}', inputs.version) }} > /dev/null 2>&1; then
47+
gh release delete ${{ format('v{0}', inputs.version) }} --yes --cleanup-tag
48+
fi

spring-javaformat-cli/.sdkmanrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Enable auto-env through the sdkman_auto_env config
2+
# Add key=value pairs of SDKs to use below
3+
java=23.0.11.r17-nik

0 commit comments

Comments
 (0)