Last active
October 21, 2022 13:00
-
-
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 file contains hidden or 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
# 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/[email protected] | |
- 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/[email protected] | |
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/[email protected] | |
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