Skip to content

Instantly share code, notes, and snippets.

@linux-china
Last active October 21, 2022 13:00
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save linux-china/8745394fbc308168b20068386771ea1b to your computer and use it in GitHub Desktop.
Save linux-china/8745394fbc308168b20068386771ea1b to your computer and use it in GitHub Desktop.
Github actions for GraalVM native image build on Windows, Mac and Linux. Please adjust 'demo-cli' to final name.
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: GraalVM Native Image build
on:
push:
branches: [ master ]
tags: [ '*' ]
jobs:
buildOnWindows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: ilammy/msvc-dev-cmd@v1.5.0
- uses: microsoft/setup-msbuild@v1
- uses: ayltai/setup-graalvm@v1
with:
java-version: 11
graalvm-version: 20.3.0
native-image: true
- name: Build with Maven
run: mvn -DskipTests -B clean package native-image:native-image --file pom.xml
shell: powershell
- name: Run UPX
uses: crazy-max/ghaction-upx@v1.3.3
with:
version: latest
file: target/demo-cli.exe
args: '-7'
- uses: actions/upload-artifact@v2
with:
if-no-files-found: warn
name: package
path: target/*.exe
buildOnMac:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: ayltai/setup-graalvm@v1
with:
java-version: 11
graalvm-version: 20.3.0
native-image: true
- name: Build with Maven
run: mvn -DskipTests -B clean package native-image:native-image --file pom.xml
- name: Run UPX
uses: svenstaro/upx-action@v2
with:
file: target/demo-cli
args: '-7'
- name: Upload artifacts
run: mkdir staging && cp target/demo-cli staging/demo-cli-mac-amd64
- uses: actions/upload-artifact@v2
with:
name: package
path: staging
buildOnLinux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ayltai/setup-graalvm@v1
with:
java-version: 11
graalvm-version: 20.3.0
native-image: true
- name: Build with Maven
run: mvn -DskipTests -B clean package native-image:native-image --file pom.xml
- name: Run UPX
uses: crazy-max/ghaction-upx@v1.3.3
with:
version: latest
file: target/demo-cli
args: '-7'
- name: Upload artifacts
run: mkdir staging && cp target/demo-cli staging/demo-cli-linux-amd64
- uses: actions/upload-artifact@v2
with:
name: package
path: staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment