This GitHub action sets up Oracle GraalVM, GraalVM Community Edition (CE), Enterprise Edition (EE), Mandrel, or Liberica Native Image Kit as well as Native Image and GraalVM components such as Truffle languages.
This action:
gds-token
) 22.1.0 and later, Mandrel, and Liberica Native Image Kit (see Options)$GRAALVM_HOME
environment variable$GRAALVM_HOME/bin
to the $PATH
environment variable$JAVA_HOME
to $GRAALVM_HOME
by defaultset-java-home: 'false'
, see Options)x64
and aarch64
(selected automatically, aarch64
requires a self-hosted runner)cache
option)name: GraalVM build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21' # See 'Options' for more details
distribution: 'graalvm' # See 'Supported distributions' for available options
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Example step
run: |
echo "GRAALVM_HOME: $GRAALVM_HOME"
echo "JAVA_HOME: $JAVA_HOME"
java --version
native-image --version
- name: Example step using Maven plugin # https://graalvm.github.io/native-build-tools/latest/maven-plugin.html
run: mvn -Pnative package
- name: Example step using Gradle plugin # https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html
run: gradlew nativeCompile
name: GraalVM Native Image builds
on: [push, pull_request]
jobs:
build:
name: HelloWorld on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
- name: Build and run HelloWorld.java
run: |
echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }' > HelloWorld.java
javac HelloWorld.java
native-image HelloWorld
./helloworld
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: helloworld-${{ matrix.os }}
path: helloworld*
name: Oracle GraalVM Early Access build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: '24-ea' # or 'latest-ea' for the latest Java version available
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
Currently, the following distributions are supported:
Keyword | Distribution | Official site | License |
---|---|---|---|
graalvm |
Oracle GraalVM | Link | Link |
graalvm-community |
GraalVM Community Edition | Link | Link |
mandrel |
Mandrel | Link | Link |
liberica |
Liberica NIK | Link | Link |
This actions can be configured with the following options:
Name | Default | Description |
---|---|---|
java-version (required) |
n/a | Java version
|
distribution |
'graalvm' |
GraalVM distribution (see supported distributions) |
java-package |
'jdk' |
The package type ('jdk' or 'jdk+fx' ). Currently applies to Liberica only. |
github-token |
'${{ github.token }}' |
Token for communication with the GitHub API. Please set this to ${{ secrets.GITHUB_TOKEN }} (see templates) to allow the action to authenticate with the GitHub API, which helps reduce rate-limiting issues. |
set-java-home |
'true' |
If set to 'true' , instructs the action to set $JAVA_HOME to the path of the GraalVM installation. Overrides any previous action or command that sets $JAVA_HOME . |
cache |
'' |
Name of the build platform to cache dependencies. Turned off by default ('' ). It can also be 'maven' , 'gradle' , or 'sbt' and works the same way as described in actions/setup-java. |
check-for-updates |
'true' |
Annotate jobs with update notifications, for example when a new GraalVM release is available. |
native-image-musl |
'false' |
If set to 'true' , sets up musl to build static binaries with GraalVM Native Image (Linux only). Example usage (be sure to replace uses: ./ with uses: graalvm/setup-graalvm@v1 ). |
native-image-job-reports *) |
'false' |
If set to 'true' , post a job summary containing a Native Image build report. |
native-image-pr-reports *) |
'false' |
If set to 'true' , post a comment containing a Native Image build report on pull requests. Requires write permissions for the pull-requests scope. |
native-image-pr-reports-update-existing *) |
'false' |
Instead of posting another comment, update an existing PR comment with the latest Native Image build report. Requires native-image-pr-reports to be true . |
components |
'' |
Comma-separated list of GraalVM components (e.g., native-image or ruby,nodejs ) that will be installed by the GraalVM Updater. |
version |
'' |
X.Y.Z (e.g., 22.3.0 ) for a specific GraalVM release up to 22.3.2 mandrel-X.Y.Z.W or X.Y.Z.W-Final (e.g., mandrel-21.3.0.0-Final or 21.3.0.0-Final ) for a specific Mandrel release,mandrel-latest or latest for the latest Mandrel stable release. |
gds-token |
'' Download token for the GraalVM Download Service. If a non-empty token is provided, the action will set up Oracle GraalVM (see Oracle GraalVM via GDS template) or GraalVM Enterprise Edition (see GraalVM EE template) via GDS. |
*) Make sure that Native Image is used only once per build job. Otherwise, the report is only generated for the last Native Image build.
GraalVM for JDK 17.0.12 is the last release of Oracle GraalVM for JDK 17 under the GFTC. Updates after September 2024 will be licensed under the GraalVM OTN License Including License for Early Adopter Versions (GOTN) and production use beyond the limited free grants of the GraalVM OTN license will require a fee.
As a user of setup-graalvm
, you have the following options:
java-version: '17'
, use java-version: '17.0.12'
in your workflow to keep using the last release under GFTC. This will also disable the warning. Note that switching to GraalVM Community Edition or other GraalVM distributions might provide you with even older releases of GraalVM.gds-token
to access Oracle GraalVM for JDK 17 under GOTN (see Oracle GraalVM via GDS template).The GraalVM for JDK 17 and JDK 20 release aligns the GraalVM version scheme with OpenJDK.
As a result, this action no longer requires the version
option to select a specific GraalVM version.
At the same time, it introduces a new distribution
option to select a specific GraalVM distribution (graalvm
, graalvm-community
, or mandrel
).
Therefore, to migrate your workflow to use the latest GraalVM release, replace the version
with the distribution
option in the workflow yml
config, for example:
# ...
- uses: graalvm/setup-graalvm@v1
with:
java-version: '17'
version: '22.3.2' # Old 'version' option for the GraalVM version
# ...
can be replaced with:
# ...
- uses: graalvm/setup-graalvm@v1
with:
java-version: '17.0.12' # for a specific JDK 17; or '17' for the latest JDK 17
distribution: 'graalvm' # New 'distribution' option
# ...
We welcome code contributions. To get started, you will need to sign the Oracle Contributor Agreement (OCA).
Only pull requests from committers that can be verified as having signed the OCA can be accepted.