mirror of
https://github.com/graalvm/setup-graalvm.git
synced 2025-01-18 19:26:39 +08:00
Support new GraalVM for JDK17/JDK20 release
This commit adds support for the new GraalVM for JDK17/JDK20 release, including the new Oracle GraalVM distribution. For this, users only need to specify the 'java-version' option and the new 'distribution' option. The 'version' option is now marked as optional and kept for compatibility with older GraalVM releases and Mandrel.
This commit is contained in:
parent
2f50b91043
commit
c871f91ee0
63
.github/workflows/test.yml
vendored
63
.github/workflows/test.yml
vendored
@ -20,13 +20,49 @@ jobs:
|
||||
npm install
|
||||
- run: |
|
||||
npm run all
|
||||
test:
|
||||
name: GraalVM
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
java-version: ['17', '20', 'dev']
|
||||
distribution: ['graalvm', 'graalvm-community']
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
java-version: ${{ matrix.java-version }}
|
||||
distribution: ${{ matrix.distribution }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Check environment
|
||||
run: |
|
||||
echo "GRAALVM_HOME: $GRAALVM_HOME"
|
||||
if [[ "${{ matrix.java-version }}" == "dev" ]]; then
|
||||
[[ "$GRAALVM_HOME" == *"$RUNNER_TEMP"* ]] || exit 12
|
||||
else
|
||||
[[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 23
|
||||
fi
|
||||
echo "JAVA_HOME: $JAVA_HOME"
|
||||
java --version
|
||||
java --version | grep "GraalVM" || exit 34
|
||||
native-image --version
|
||||
if: runner.os != 'Windows'
|
||||
- name: Check Windows environment
|
||||
run: |
|
||||
echo "GRAALVM_HOME: $env:GRAALVM_HOME"
|
||||
echo "JAVA_HOME: $env:JAVA_HOME"
|
||||
java --version
|
||||
native-image --version
|
||||
test-ce: # make sure the action works on a clean machine without building
|
||||
needs: test
|
||||
name: CE ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
version: ['latest', 'dev']
|
||||
java-version: ['19', '20']
|
||||
java-version: ['17', '20']
|
||||
components: ['native-image']
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
exclude:
|
||||
@ -70,7 +106,7 @@ jobs:
|
||||
fi
|
||||
echo "JAVA_HOME: $JAVA_HOME"
|
||||
java --version
|
||||
java --version | grep "GraalVM CE" || exit 34
|
||||
java --version | grep "GraalVM" || exit 34
|
||||
native-image --version
|
||||
gu list
|
||||
if: runner.os != 'Windows'
|
||||
@ -83,6 +119,7 @@ jobs:
|
||||
gu.cmd remove native-image
|
||||
if: runner.os == 'Windows'
|
||||
test-ee:
|
||||
needs: test
|
||||
name: EE ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}
|
||||
if: github.event_name != 'pull_request'
|
||||
runs-on: ${{ matrix.os }}
|
||||
@ -130,6 +167,7 @@ jobs:
|
||||
gu.cmd remove native-image
|
||||
if: runner.os == 'Windows'
|
||||
test-mandrel:
|
||||
needs: test
|
||||
name: ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
@ -175,9 +213,8 @@ jobs:
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
version: 'dev'
|
||||
java-version: 'dev'
|
||||
components: 'native-image'
|
||||
distribution: 'graalvm-community'
|
||||
native-image-job-reports: 'true'
|
||||
native-image-pr-reports: 'true'
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@ -188,8 +225,8 @@ jobs:
|
||||
native-image HelloWorld
|
||||
./helloworld
|
||||
test-native-image-windows-msvc:
|
||||
name: native-image on windows-2019
|
||||
runs-on: windows-2019
|
||||
name: native-image on windows-2022
|
||||
runs-on: windows-2022
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write # for `native-image-pr-reports` option
|
||||
@ -198,9 +235,8 @@ jobs:
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
version: '22.3.1'
|
||||
java-version: '17'
|
||||
components: 'native-image'
|
||||
distribution: 'graalvm'
|
||||
native-image-job-reports: 'true'
|
||||
native-image-pr-reports: 'true'
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@ -221,9 +257,8 @@ jobs:
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
version: 'dev'
|
||||
java-version: 'dev'
|
||||
components: 'native-image'
|
||||
distribution: 'graalvm-community'
|
||||
native-image-musl: 'true'
|
||||
native-image-job-reports: 'true'
|
||||
native-image-pr-reports: 'true'
|
||||
@ -245,9 +280,9 @@ jobs:
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
version: 'latest'
|
||||
java-version: '17'
|
||||
components: 'espresso,llvm-toolchain,native-image,nodejs,python,R,ruby,wasm'
|
||||
distribution: 'graalvm'
|
||||
components: 'espresso,llvm-toolchain,native-image,nodejs,python,ruby,wasm'
|
||||
set-java-home: 'false'
|
||||
native-image-job-reports: 'true'
|
||||
native-image-pr-reports: 'true'
|
||||
@ -268,8 +303,6 @@ jobs:
|
||||
[[ $(which node) == *"graalvm"* ]] || exit 45
|
||||
node --version
|
||||
graalpy --version
|
||||
[[ $(which R) == *"graalvm"* ]] || exit 56
|
||||
R --version
|
||||
truffleruby --version
|
||||
wasm --version
|
||||
- name: Build HelloWorld.java with GraalVM Native Image
|
||||
@ -290,4 +323,4 @@ jobs:
|
||||
bundle exec rake test
|
||||
popd > /dev/null
|
||||
- name: Remove components
|
||||
run: gu remove espresso llvm-toolchain nodejs python R ruby wasm
|
||||
run: gu remove espresso llvm-toolchain nodejs python ruby wasm
|
||||
|
99
README.md
99
README.md
@ -1,18 +1,46 @@
|
||||
# GitHub Action for GraalVM [![build-test](https://github.com/graalvm/setup-graalvm/actions/workflows/test.yml/badge.svg)](https://github.com/graalvm/setup-graalvm/actions/workflows/test.yml)
|
||||
This GitHub action sets up GraalVM [Community Edition (CE)][repo] or [Enterprise Edition (EE)][graalvm-ee] as well as GraalVM components such as [Native Image][native-image] and [Truffle languages][truffle-languages].
|
||||
This GitHub action sets up [Oracle GraalVM][graalvm], GraalVM [Community Edition (CE)][repo], [Enterprise Edition (EE)][graalvm-ee], or [Mandrel][mandrel], as well as [Native Image][native-image] and GraalVM components such as [Truffle languages][truffle-languages].
|
||||
|
||||
## Key Features
|
||||
|
||||
This action:
|
||||
|
||||
- supports GraalVM Community Edition (CE) [releases], [dev builds][dev-builds], GraalVM Enterprise Edition (EE) [releases][graalvm-ee] (set [`gds-token`](#options)) 22.1.0 and later, and [Mandrel][mandrel] (see [options](#options))
|
||||
- has built-in support for GraalVM components and the [GraalVM Updater][gu]
|
||||
- supports Oracle GraalVM [releases][graalvm-dl], GraalVM Community Edition (CE) [releases], [dev builds][dev-builds], GraalVM Enterprise Edition (EE) [releases][graalvm-ee] (set [`gds-token`](#options)) 22.1.0 and later, and [Mandrel][mandrel] (see [Options](#options))
|
||||
- exports a `$GRAALVM_HOME` environment variable
|
||||
- adds `$GRAALVM_HOME/bin` to the `$PATH` environment variable<br>(Truffle languages and tools can be invoked directly)
|
||||
- sets `$JAVA_HOME` to `$GRAALVM_HOME` by default<br>(can be disabled via `set-java-home: 'false'`, see [options](#options))
|
||||
- supports `amd64` and `aarch64` (selected automatically, `aarch64` requires a [self-hosted runner][gha-self-hosted-runners])
|
||||
- sets up Windows environments with build tools using [vcvarsall.bat][vcvarsall]
|
||||
- adds `$GRAALVM_HOME/bin` to the `$PATH` environment variable<br>(Native Image, Truffle languages, and tools can be invoked directly)
|
||||
- sets `$JAVA_HOME` to `$GRAALVM_HOME` by default<br>(can be disabled via `set-java-home: 'false'`, see [Options](#options))
|
||||
- supports `x64` and `aarch64` (selected automatically, `aarch64` requires a [self-hosted runner][gha-self-hosted-runners])
|
||||
- supports dependency caching for Apache Maven, Gradle, and sbt (see [`cache` option](#options))
|
||||
- sets up Windows environments with build tools using [vcvarsall.bat][vcvarsall]
|
||||
- has built-in support for GraalVM components and the [GraalVM Updater][gu]
|
||||
|
||||
|
||||
## Migrating from GraalVM 22.3 or earlier to the new GraalVM for JDK 17 and later
|
||||
|
||||
The new [GraalVM release](https://medium.com/graalvm/a-new-graalvm-release-and-new-free-license-4aab483692f5) aligns the version scheme with OpenJDK.
|
||||
As a result, this action no longer requires the `version` option that was used to select a specific GraalVM version.
|
||||
At the same time, it introduces a new `distribution` option that can be used to select a specific GraalVM distribution (`graalvm`, `graalvm-community`, and `mandrel`).
|
||||
Therefore, to migrate workflows to use the latest GraalVM release, replace the `version` with the `distribution` option in your workflow `yml` config, for example:
|
||||
|
||||
```yml
|
||||
# ...
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '17'
|
||||
version: '22.3.2' # Old 'version' option for the GraalVM version
|
||||
# ...
|
||||
```
|
||||
|
||||
can be turned into:
|
||||
|
||||
```yml
|
||||
# ...
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '17.0.7' # for a specific JDK 17; or '17' for the latest JDK 17
|
||||
distribution: 'graalvm' # New 'distribution' option
|
||||
# ...
|
||||
```
|
||||
|
||||
|
||||
## Templates
|
||||
@ -20,7 +48,7 @@ This action:
|
||||
### Quickstart Template
|
||||
|
||||
```yml
|
||||
name: GraalVM Community Edition build
|
||||
name: GraalVM build
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
build:
|
||||
@ -29,17 +57,19 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
version: 'latest'
|
||||
java-version: '17'
|
||||
components: 'native-image'
|
||||
java-version: '17.0.7'
|
||||
distribution: 'graalvm' # See 'Options' for all available distributions
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Example step
|
||||
run: |
|
||||
echo "GRAALVM_HOME: $GRAALVM_HOME"
|
||||
echo "JAVA_HOME: $JAVA_HOME"
|
||||
java --version
|
||||
gu --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
|
||||
```
|
||||
|
||||
### Building a HelloWorld with GraalVM Native Image on Different Platforms
|
||||
@ -59,9 +89,8 @@ jobs:
|
||||
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
version: '22.3.0'
|
||||
java-version: '17'
|
||||
components: 'native-image'
|
||||
java-version: '17.0.7'
|
||||
distribution: 'graalvm'
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
native-image-job-reports: 'true'
|
||||
|
||||
@ -79,7 +108,29 @@ jobs:
|
||||
path: helloworld*
|
||||
```
|
||||
|
||||
### Basic GraalVM Enterprise Edition Template
|
||||
<details>
|
||||
<summary><h4>Template for older GraalVM releases</h4></summary>
|
||||
|
||||
```yml
|
||||
name: GraalVM build
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
version: '22.3.2' # GraalVM version
|
||||
java-version: '17'
|
||||
components: 'native-image'
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><h4>Template for GraalVM Enterprise Edition</h4></summary>
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
@ -109,22 +160,24 @@ jobs:
|
||||
native-image --version
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Options
|
||||
|
||||
| Name | Default | Description |
|
||||
|-----------------|:--------:|-------------|
|
||||
| `version`<br>*(required)* | n/a | `X.Y.Z` (e.g., `22.3.0`) for a specific [GraalVM release][releases]<br>`latest` for [latest stable release][stable],<br>`dev` for [latest dev build][dev-build],<br>`mandrel-X.Y.Z` (e.g., `mandrel-21.3.0.0-Final`) for a specific [Mandrel release][mandrel-releases],<br>`mandrel-latest` for [latest Mandrel stable release][mandrel-stable]. |
|
||||
| `gds-token` | `''` | Download token for the GraalVM Download Service. If a non-empty token is provided, the action will set up GraalVM Enterprise Edition (see [GraalVM EE template](#basic-graalvm-enterprise-edition-template)). |
|
||||
| `java-version`<br>*(required)* | n/a | `'17'` or `'19'` for a specific Java version, `'dev'` for the highest Java version available (requires `version: 'dev'`).<br>(`'8'`, `'11'`, `'16'` are supported for older GraalVM releases.) |
|
||||
| `components` | `''` | Comma-spearated list of GraalVM components (e.g., `native-image` or `ruby,nodejs`) that will be installed by the [GraalVM Updater][gu]. |
|
||||
| `github-token` | `'${{ github.token }}'` | Token for communication with the GitHub API. Please set to `${{ secrets.GITHUB_TOKEN }}` (see [templates](#templates)) to allow the action to authenticate with the GitHub API, which helps to reduce rate limiting issues. |
|
||||
| `java-version`<br>*(required)* | n/a | `'17.0.7'` or `'20.0.1'` for a specific Java version, `'dev'` for a dev build with the highest Java version available.<br>(`'8'`, `'11'`, `'16'`, `'19'` are supported for older GraalVM releases.) |
|
||||
| `distribution` | `''` | GraalVM distribution (`graalvm` for Oracle GraalVM, `graalvm-community` for GraalVM Community Edition, `mandrel` for Mandrel). |
|
||||
| `github-token` | `'${{ github.token }}'` | Token for communication with the GitHub API. Please set this to `${{ secrets.GITHUB_TOKEN }}` (see [templates](#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. It can be `'maven'`, `'gradle'`, or `'sbt'` and works the same way as described in [actions/setup-java][setup-java-caching]. |
|
||||
| `check-for-updates` | `'true'` | [Annotate jobs][gha-annotations] with update notifications, for example, when a new GraalVM release is available. |
|
||||
| `check-for-updates` | `'true'` | [Annotate jobs][gha-annotations] 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][native-image-static] with GraalVM Native Image *(Linux only)*. [Example usage][native-image-musl-build] (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][gha-permissions]. |
|
||||
| `components` | `''` | Comma-separated list of GraalVM components (e.g., `native-image` or `ruby,nodejs`) that will be installed by the [GraalVM Updater][gu]. |
|
||||
| `version` | n/a | `X.Y.Z` (e.g., `22.3.0`) for a specific [GraalVM release][releases] up to `22.3.2`<br>`mandrel-X.Y.Z` (e.g., `mandrel-21.3.0.0-Final`) for a specific [Mandrel release][mandrel-releases],<br>`mandrel-latest` for [latest Mandrel stable release][mandrel-stable]. |
|
||||
| `gds-token` | `''` | Download token for the GraalVM Download Service. If a non-empty token is provided, the action will set up GraalVM Enterprise Edition (see [GraalVM EE template](#template-for-graalvm-enterprise-edition)). |
|
||||
|
||||
**) Make sure that Native Image is used only once per build job. Otherwise, the report is only generated for the last Native Image build.*
|
||||
|
||||
@ -143,6 +196,8 @@ Only pull requests from committers that can be verified as having signed the OCA
|
||||
[gha-secrets]: https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository
|
||||
[gha-self-hosted-runners]: https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners
|
||||
[gu]: https://www.graalvm.org/reference-manual/graalvm-updater/
|
||||
[graalvm]: https://www.graalvm.org/
|
||||
[graalvm-dl]: https://www.oracle.com/java/technologies/downloads/
|
||||
[graalvm-ee]: https://www.oracle.com/downloads/graalvm-downloads.html
|
||||
[mandrel]: https://github.com/graalvm/mandrel
|
||||
[mandrel-releases]: https://github.com/graalvm/mandrel/releases
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as path from 'path'
|
||||
import {downloadGraalVMEE, fetchArtifact} from '../src/gds'
|
||||
import {downloadGraalVMEELegacy, fetchArtifact} from '../src/gds'
|
||||
import {expect, test} from '@jest/globals'
|
||||
|
||||
const TEST_USER_AGENT = 'GraalVMGitHubActionTest/1.0.4'
|
||||
@ -32,13 +32,15 @@ test('fetch artifacts', async () => {
|
||||
})
|
||||
|
||||
test('errors when downloading artifacts', async () => {
|
||||
await expect(downloadGraalVMEE('invalid', '22.1.0', '11')).rejects.toThrow(
|
||||
await expect(
|
||||
downloadGraalVMEELegacy('invalid', '22.1.0', '11')
|
||||
).rejects.toThrow(
|
||||
'The provided "gds-token" was rejected (reason: "Invalid download token", opc-request-id: /'
|
||||
)
|
||||
await expect(downloadGraalVMEE('invalid', '1.0.0', '11')).rejects.toThrow(
|
||||
'Unable to find JDK11-based GraalVM EE 1.0.0'
|
||||
)
|
||||
await expect(downloadGraalVMEE('invalid', '22.1.0', '1')).rejects.toThrow(
|
||||
'Unable to find JDK1-based GraalVM EE 22.1.0'
|
||||
)
|
||||
await expect(
|
||||
downloadGraalVMEELegacy('invalid', '1.0.0', '11')
|
||||
).rejects.toThrow('Unable to find JDK11-based GraalVM EE 1.0.0')
|
||||
await expect(
|
||||
downloadGraalVMEELegacy('invalid', '22.1.0', '1')
|
||||
).rejects.toThrow('Unable to find JDK1-based GraalVM EE 22.1.0')
|
||||
})
|
||||
|
@ -19,7 +19,7 @@ test('request invalid version/javaVersion', async () => {
|
||||
await graalvm.setUpGraalVMRelease('', combination[0], combination[1])
|
||||
} catch (err) {
|
||||
if (!(err instanceof Error)) {
|
||||
fail(`Unexpected non-Erro: ${err}`)
|
||||
fail(`Unexpected non-Error: ${err}`)
|
||||
}
|
||||
error = err
|
||||
}
|
||||
@ -31,6 +31,23 @@ test('request invalid version/javaVersion', async () => {
|
||||
})
|
||||
|
||||
test('find version/javaVersion', async () => {
|
||||
// Make sure the action can find the latest Java version for known major versions
|
||||
for (var majorJavaVersion of ['17', '20']) {
|
||||
await graalvm.findLatestGraalVMJDKCEJavaVersion(majorJavaVersion)
|
||||
}
|
||||
|
||||
let error = new Error('unexpected')
|
||||
try {
|
||||
await graalvm.findLatestGraalVMJDKCEJavaVersion('11')
|
||||
fail('Should not find Java version for 11')
|
||||
} catch (err) {
|
||||
if (!(err instanceof Error)) {
|
||||
fail(`Unexpected non-Error: ${err}`)
|
||||
}
|
||||
error = err
|
||||
}
|
||||
expect(error.message).toContain('Unable to find the latest Java version for')
|
||||
|
||||
const latestRelease = await getTaggedRelease(
|
||||
GRAALVM_RELEASES_REPO,
|
||||
'vm-22.3.1'
|
||||
@ -40,7 +57,7 @@ test('find version/javaVersion', async () => {
|
||||
const latestJavaVersion = findHighestJavaVersion(latestRelease, latestVersion)
|
||||
expect(latestJavaVersion).not.toBe('')
|
||||
|
||||
let error = new Error('unexpected')
|
||||
error = new Error('unexpected')
|
||||
try {
|
||||
const invalidRelease = {...latestRelease, tag_name: 'invalid'}
|
||||
findGraalVMVersion(invalidRelease)
|
||||
@ -56,7 +73,7 @@ test('find version/javaVersion', async () => {
|
||||
findHighestJavaVersion(latestRelease, 'invalid')
|
||||
} catch (err) {
|
||||
if (!(err instanceof Error)) {
|
||||
fail(`Unexpected non-Erro: ${err}`)
|
||||
fail(`Unexpected non-Error: ${err}`)
|
||||
}
|
||||
error = err
|
||||
}
|
||||
|
21
action.yml
21
action.yml
@ -1,19 +1,17 @@
|
||||
name: 'GitHub Action for GraalVM'
|
||||
description: 'Set up a specific version of GraalVM Community Edition (CE) or Enterprise Edition (EE)'
|
||||
description: 'Set up a specific version of the GraalVM JDK and add the command-line tools to the PATH'
|
||||
author: 'GraalVM Community'
|
||||
branding:
|
||||
icon: 'terminal'
|
||||
color: 'blue'
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
description: 'GraalVM version (release, latest, dev).'
|
||||
gds-token:
|
||||
required: false
|
||||
description: 'Download token for the GraalVM Download Service. If provided, the action will set up GraalVM Enterprise Edition.'
|
||||
java-version:
|
||||
required: true
|
||||
description: 'Java version (11 or 17, 8 or 16 for older releases).'
|
||||
description: 'Java version. See examples of supported syntax in the README file.'
|
||||
distribution:
|
||||
description: 'GraalVM distribution. See the list of available distributions in the README file.'
|
||||
required: false
|
||||
default: ''
|
||||
components:
|
||||
required: false
|
||||
description: 'Comma-separated list of GraalVM components to be installed.'
|
||||
@ -45,6 +43,13 @@ inputs:
|
||||
required: false
|
||||
description: 'Post a comment containing a Native Image build report on pull requests.'
|
||||
default: 'false'
|
||||
version:
|
||||
required: false
|
||||
description: 'GraalVM version (release, latest, dev).'
|
||||
default: ''
|
||||
gds-token:
|
||||
required: false
|
||||
description: 'Download token for the GraalVM Download Service. If provided, the action will set up GraalVM Enterprise Edition.'
|
||||
outputs:
|
||||
cache-hit:
|
||||
description: 'A boolean value to indicate an exact match was found for the primary key'
|
||||
|
56
dist/cleanup/index.js
generated
vendored
56
dist/cleanup/index.js
generated
vendored
@ -69858,10 +69858,11 @@ else {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.EVENT_NAME_PULL_REQUEST = exports.ENV_GITHUB_EVENT_NAME = exports.GDS_GRAALVM_PRODUCT_ID = exports.GDS_BASE = exports.MANDREL_NAMESPACE = exports.JDK_HOME_SUFFIX = exports.GRAALVM_RELEASES_REPO = exports.GRAALVM_PLATFORM = exports.GRAALVM_GH_USER = exports.GRAALVM_FILE_EXTENSION = exports.GRAALVM_ARCH = exports.VERSION_LATEST = exports.VERSION_DEV = exports.IS_WINDOWS = exports.IS_MACOS = exports.IS_LINUX = exports.INPUT_NI_MUSL = exports.INPUT_CHECK_FOR_UPDATES = exports.INPUT_CACHE = exports.INPUT_SET_JAVA_HOME = exports.INPUT_GITHUB_TOKEN = exports.INPUT_COMPONENTS = exports.INPUT_JAVA_VERSION = exports.INPUT_GDS_TOKEN = exports.INPUT_VERSION = void 0;
|
||||
exports.ERROR_HINT = exports.EVENT_NAME_PULL_REQUEST = exports.ENV_GITHUB_EVENT_NAME = exports.GDS_GRAALVM_PRODUCT_ID = exports.GDS_BASE = exports.MANDREL_NAMESPACE = exports.GRAALVM_RELEASES_REPO = exports.GRAALVM_PLATFORM = exports.GRAALVM_GH_USER = exports.GRAALVM_FILE_EXTENSION = exports.GRAALVM_ARCH = exports.JDK_HOME_SUFFIX = exports.JDK_PLATFORM = exports.JDK_ARCH = exports.VERSION_LATEST = exports.VERSION_DEV = exports.DISTRIBUTION_MANDREL = exports.DISTRIBUTION_GRAALVM_COMMUNITY = exports.DISTRIBUTION_GRAALVM = exports.IS_WINDOWS = exports.IS_MACOS = exports.IS_LINUX = exports.INPUT_NI_MUSL = exports.INPUT_CHECK_FOR_UPDATES = exports.INPUT_CACHE = exports.INPUT_SET_JAVA_HOME = exports.INPUT_GITHUB_TOKEN = exports.INPUT_COMPONENTS = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_VERSION = exports.INPUT_GDS_TOKEN = exports.INPUT_VERSION = void 0;
|
||||
exports.INPUT_VERSION = 'version';
|
||||
exports.INPUT_GDS_TOKEN = 'gds-token';
|
||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||
exports.INPUT_DISTRIBUTION = 'distribution';
|
||||
exports.INPUT_COMPONENTS = 'components';
|
||||
exports.INPUT_GITHUB_TOKEN = 'github-token';
|
||||
exports.INPUT_SET_JAVA_HOME = 'set-java-home';
|
||||
@ -69871,19 +69872,54 @@ exports.INPUT_NI_MUSL = 'native-image-musl';
|
||||
exports.IS_LINUX = process.platform === 'linux';
|
||||
exports.IS_MACOS = process.platform === 'darwin';
|
||||
exports.IS_WINDOWS = process.platform === 'win32';
|
||||
exports.DISTRIBUTION_GRAALVM = 'graalvm';
|
||||
exports.DISTRIBUTION_GRAALVM_COMMUNITY = 'graalvm-community';
|
||||
exports.DISTRIBUTION_MANDREL = 'mandrel';
|
||||
exports.VERSION_DEV = 'dev';
|
||||
exports.VERSION_LATEST = 'latest';
|
||||
exports.JDK_ARCH = determineJDKArchitecture();
|
||||
exports.JDK_PLATFORM = determineJDKPlatform();
|
||||
exports.JDK_HOME_SUFFIX = exports.IS_MACOS ? '/Contents/Home' : '';
|
||||
exports.GRAALVM_ARCH = determineGraalVMArchitecture();
|
||||
exports.GRAALVM_FILE_EXTENSION = exports.IS_WINDOWS ? '.zip' : '.tar.gz';
|
||||
exports.GRAALVM_GH_USER = 'graalvm';
|
||||
exports.GRAALVM_PLATFORM = exports.IS_WINDOWS ? 'windows' : process.platform;
|
||||
exports.GRAALVM_RELEASES_REPO = 'graalvm-ce-builds';
|
||||
exports.JDK_HOME_SUFFIX = exports.IS_MACOS ? '/Contents/Home' : '';
|
||||
exports.MANDREL_NAMESPACE = 'mandrel-';
|
||||
exports.GDS_BASE = 'https://gds.oracle.com/api/20220101';
|
||||
exports.GDS_GRAALVM_PRODUCT_ID = 'D53FAE8052773FFAE0530F15000AA6C6';
|
||||
exports.ENV_GITHUB_EVENT_NAME = 'GITHUB_EVENT_NAME';
|
||||
exports.EVENT_NAME_PULL_REQUEST = 'pull_request';
|
||||
exports.ERROR_HINT = 'If you think this is a mistake, please file an issue at: https://github.com/graalvm/setup-graalvm/issues.';
|
||||
function determineJDKArchitecture() {
|
||||
switch (process.arch) {
|
||||
case 'x64': {
|
||||
return 'x64';
|
||||
}
|
||||
case 'arm64': {
|
||||
return 'aarch64';
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported architecture: ${process.arch}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
function determineJDKPlatform() {
|
||||
switch (process.platform) {
|
||||
case 'linux': {
|
||||
return 'linux';
|
||||
}
|
||||
case 'darwin': {
|
||||
return 'macos';
|
||||
}
|
||||
case 'win32': {
|
||||
return 'windows';
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported platform: ${process.platform}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
function determineGraalVMArchitecture() {
|
||||
switch (process.arch) {
|
||||
case 'x64': {
|
||||
@ -70193,6 +70229,7 @@ function setUpNativeImageBuildReports(graalVMVersion) {
|
||||
}
|
||||
const isSupported = graalVMVersion === c.VERSION_LATEST ||
|
||||
graalVMVersion === c.VERSION_DEV ||
|
||||
graalVMVersion.length === 0 ||
|
||||
(!graalVMVersion.startsWith(c.MANDREL_NAMESPACE) &&
|
||||
(0, semver_1.gte)((0, utils_1.toSemVer)(graalVMVersion), '22.2.0'));
|
||||
if (!isSupported) {
|
||||
@ -70461,7 +70498,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.createPRComment = exports.isPREvent = exports.toSemVer = exports.calculateSHA256 = exports.downloadExtractAndCacheJDK = exports.downloadAndExtractJDK = exports.getTaggedRelease = exports.getLatestRelease = exports.exec = void 0;
|
||||
exports.createPRComment = exports.isPREvent = exports.toSemVer = exports.calculateSHA256 = exports.downloadExtractAndCacheJDK = exports.downloadAndExtractJDK = exports.getMatchingTags = exports.getTaggedRelease = exports.getLatestRelease = exports.exec = void 0;
|
||||
const c = __importStar(__nccwpck_require__(9042));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const github = __importStar(__nccwpck_require__(5438));
|
||||
@ -70516,6 +70553,19 @@ function getTaggedRelease(repo, tag) {
|
||||
});
|
||||
}
|
||||
exports.getTaggedRelease = getTaggedRelease;
|
||||
function getMatchingTags(tagPrefix) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const githubToken = getGitHubToken();
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
||||
const octokit = new GitHubDotCom(options);
|
||||
return (yield octokit.request('GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo: c.GRAALVM_RELEASES_REPO,
|
||||
tagPrefix
|
||||
})).data;
|
||||
});
|
||||
}
|
||||
exports.getMatchingTags = getMatchingTags;
|
||||
function downloadAndExtractJDK(downloadUrl) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return findJavaHomeInSubfolder(yield extract(yield tc.downloadTool(downloadUrl)));
|
||||
|
314
dist/main/index.js
generated
vendored
314
dist/main/index.js
generated
vendored
@ -69743,10 +69743,11 @@ function wrappy (fn, cb) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.EVENT_NAME_PULL_REQUEST = exports.ENV_GITHUB_EVENT_NAME = exports.GDS_GRAALVM_PRODUCT_ID = exports.GDS_BASE = exports.MANDREL_NAMESPACE = exports.JDK_HOME_SUFFIX = exports.GRAALVM_RELEASES_REPO = exports.GRAALVM_PLATFORM = exports.GRAALVM_GH_USER = exports.GRAALVM_FILE_EXTENSION = exports.GRAALVM_ARCH = exports.VERSION_LATEST = exports.VERSION_DEV = exports.IS_WINDOWS = exports.IS_MACOS = exports.IS_LINUX = exports.INPUT_NI_MUSL = exports.INPUT_CHECK_FOR_UPDATES = exports.INPUT_CACHE = exports.INPUT_SET_JAVA_HOME = exports.INPUT_GITHUB_TOKEN = exports.INPUT_COMPONENTS = exports.INPUT_JAVA_VERSION = exports.INPUT_GDS_TOKEN = exports.INPUT_VERSION = void 0;
|
||||
exports.ERROR_HINT = exports.EVENT_NAME_PULL_REQUEST = exports.ENV_GITHUB_EVENT_NAME = exports.GDS_GRAALVM_PRODUCT_ID = exports.GDS_BASE = exports.MANDREL_NAMESPACE = exports.GRAALVM_RELEASES_REPO = exports.GRAALVM_PLATFORM = exports.GRAALVM_GH_USER = exports.GRAALVM_FILE_EXTENSION = exports.GRAALVM_ARCH = exports.JDK_HOME_SUFFIX = exports.JDK_PLATFORM = exports.JDK_ARCH = exports.VERSION_LATEST = exports.VERSION_DEV = exports.DISTRIBUTION_MANDREL = exports.DISTRIBUTION_GRAALVM_COMMUNITY = exports.DISTRIBUTION_GRAALVM = exports.IS_WINDOWS = exports.IS_MACOS = exports.IS_LINUX = exports.INPUT_NI_MUSL = exports.INPUT_CHECK_FOR_UPDATES = exports.INPUT_CACHE = exports.INPUT_SET_JAVA_HOME = exports.INPUT_GITHUB_TOKEN = exports.INPUT_COMPONENTS = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_VERSION = exports.INPUT_GDS_TOKEN = exports.INPUT_VERSION = void 0;
|
||||
exports.INPUT_VERSION = 'version';
|
||||
exports.INPUT_GDS_TOKEN = 'gds-token';
|
||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||
exports.INPUT_DISTRIBUTION = 'distribution';
|
||||
exports.INPUT_COMPONENTS = 'components';
|
||||
exports.INPUT_GITHUB_TOKEN = 'github-token';
|
||||
exports.INPUT_SET_JAVA_HOME = 'set-java-home';
|
||||
@ -69756,19 +69757,54 @@ exports.INPUT_NI_MUSL = 'native-image-musl';
|
||||
exports.IS_LINUX = process.platform === 'linux';
|
||||
exports.IS_MACOS = process.platform === 'darwin';
|
||||
exports.IS_WINDOWS = process.platform === 'win32';
|
||||
exports.DISTRIBUTION_GRAALVM = 'graalvm';
|
||||
exports.DISTRIBUTION_GRAALVM_COMMUNITY = 'graalvm-community';
|
||||
exports.DISTRIBUTION_MANDREL = 'mandrel';
|
||||
exports.VERSION_DEV = 'dev';
|
||||
exports.VERSION_LATEST = 'latest';
|
||||
exports.JDK_ARCH = determineJDKArchitecture();
|
||||
exports.JDK_PLATFORM = determineJDKPlatform();
|
||||
exports.JDK_HOME_SUFFIX = exports.IS_MACOS ? '/Contents/Home' : '';
|
||||
exports.GRAALVM_ARCH = determineGraalVMArchitecture();
|
||||
exports.GRAALVM_FILE_EXTENSION = exports.IS_WINDOWS ? '.zip' : '.tar.gz';
|
||||
exports.GRAALVM_GH_USER = 'graalvm';
|
||||
exports.GRAALVM_PLATFORM = exports.IS_WINDOWS ? 'windows' : process.platform;
|
||||
exports.GRAALVM_RELEASES_REPO = 'graalvm-ce-builds';
|
||||
exports.JDK_HOME_SUFFIX = exports.IS_MACOS ? '/Contents/Home' : '';
|
||||
exports.MANDREL_NAMESPACE = 'mandrel-';
|
||||
exports.GDS_BASE = 'https://gds.oracle.com/api/20220101';
|
||||
exports.GDS_GRAALVM_PRODUCT_ID = 'D53FAE8052773FFAE0530F15000AA6C6';
|
||||
exports.ENV_GITHUB_EVENT_NAME = 'GITHUB_EVENT_NAME';
|
||||
exports.EVENT_NAME_PULL_REQUEST = 'pull_request';
|
||||
exports.ERROR_HINT = 'If you think this is a mistake, please file an issue at: https://github.com/graalvm/setup-graalvm/issues.';
|
||||
function determineJDKArchitecture() {
|
||||
switch (process.arch) {
|
||||
case 'x64': {
|
||||
return 'x64';
|
||||
}
|
||||
case 'arm64': {
|
||||
return 'aarch64';
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported architecture: ${process.arch}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
function determineJDKPlatform() {
|
||||
switch (process.platform) {
|
||||
case 'linux': {
|
||||
return 'linux';
|
||||
}
|
||||
case 'darwin': {
|
||||
return 'macos';
|
||||
}
|
||||
case 'win32': {
|
||||
return 'windows';
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported platform: ${process.platform}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
function determineGraalVMArchitecture() {
|
||||
switch (process.arch) {
|
||||
case 'x64': {
|
||||
@ -70137,6 +70173,12 @@ const graalvm_1 = __nccwpck_require__(5254);
|
||||
const constants_1 = __nccwpck_require__(9042);
|
||||
function checkForUpdates(graalVMVersion, javaVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (graalVMVersion.length > 0 &&
|
||||
(javaVersion === '17' || javaVersion === '19')) {
|
||||
const recommendedJDK = javaVersion === '17' ? '17' : '20';
|
||||
core.notice(`A new GraalVM release is available! Please consider upgrading to GraalVM for JDK ${recommendedJDK}. Release notes: https://www.graalvm.org/release-notes/JDK_${recommendedJDK}/`);
|
||||
return;
|
||||
}
|
||||
if (graalVMVersion.startsWith('22.3.') && javaVersion === '11') {
|
||||
core.notice('Please consider upgrading your project to Java 17+. GraalVM 22.3.X releases are the last to support JDK11: https://github.com/oracle/graal/issues/5063');
|
||||
return;
|
||||
@ -70305,6 +70347,7 @@ function setUpNativeImageBuildReports(graalVMVersion) {
|
||||
}
|
||||
const isSupported = graalVMVersion === c.VERSION_LATEST ||
|
||||
graalVMVersion === c.VERSION_DEV ||
|
||||
graalVMVersion.length === 0 ||
|
||||
(!graalVMVersion.startsWith(c.MANDREL_NAMESPACE) &&
|
||||
(0, semver_1.gte)((0, utils_1.toSemVer)(graalVMVersion), '22.2.0'));
|
||||
if (!isSupported) {
|
||||
@ -70573,7 +70616,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.fetchArtifact = exports.downloadGraalVMEE = void 0;
|
||||
exports.fetchArtifact = exports.downloadGraalVMEELegacy = void 0;
|
||||
const c = __importStar(__nccwpck_require__(9042));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const fs = __importStar(__nccwpck_require__(7147));
|
||||
@ -70586,14 +70629,14 @@ const retry_helper_1 = __nccwpck_require__(8279);
|
||||
const utils_1 = __nccwpck_require__(1314);
|
||||
const assert_1 = __nccwpck_require__(9491);
|
||||
const uuid_1 = __nccwpck_require__(5840);
|
||||
function downloadGraalVMEE(gdsToken, version, javaVersion) {
|
||||
function downloadGraalVMEELegacy(gdsToken, version, javaVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const userAgent = `GraalVMGitHubAction/1.0.12 (arch:${c.GRAALVM_ARCH}; os:${c.GRAALVM_PLATFORM}; java:${javaVersion})`;
|
||||
const baseArtifact = yield fetchArtifact(userAgent, 'isBase:True', version, javaVersion);
|
||||
return downloadArtifact(gdsToken, userAgent, baseArtifact);
|
||||
});
|
||||
}
|
||||
exports.downloadGraalVMEE = downloadGraalVMEE;
|
||||
exports.downloadGraalVMEELegacy = downloadGraalVMEELegacy;
|
||||
function fetchArtifact(userAgent, metadata, version, javaVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const http = new httpClient.HttpClient(userAgent);
|
||||
@ -70768,14 +70811,126 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.findHighestJavaVersion = exports.setUpGraalVMRelease = exports.setUpGraalVMDevBuild = exports.findGraalVMVersion = exports.setUpGraalVMLatest = void 0;
|
||||
exports.setUpGraalVMRelease = exports.findGraalVMVersion = exports.setUpGraalVMLatest = exports.findHighestJavaVersion = exports.setUpGraalVMJDKDevBuild = exports.findLatestGraalVMJDKCEJavaVersion = exports.setUpGraalVMJDKCE = exports.setUpGraalVMJDK = void 0;
|
||||
const c = __importStar(__nccwpck_require__(9042));
|
||||
const utils_1 = __nccwpck_require__(1314);
|
||||
const gds_1 = __nccwpck_require__(9543);
|
||||
const tool_cache_1 = __nccwpck_require__(7784);
|
||||
const path_1 = __nccwpck_require__(1017);
|
||||
const semver_1 = __nccwpck_require__(1383);
|
||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
||||
const GRAALVM_CE_DL_BASE = `https://github.com/graalvm/${c.GRAALVM_RELEASES_REPO}/releases/download`;
|
||||
const GRAALVM_REPO_DEV_BUILDS = 'graalvm-ce-dev-builds';
|
||||
const GRAALVM_JDK_TAG_PREFIX = 'jdk-';
|
||||
const GRAALVM_TAG_PREFIX = 'vm-';
|
||||
// Support for GraalVM for JDK 17 and later
|
||||
function setUpGraalVMJDK(javaVersionOrDev) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (javaVersionOrDev === c.VERSION_DEV) {
|
||||
return setUpGraalVMJDKDevBuild();
|
||||
}
|
||||
const javaVersion = javaVersionOrDev;
|
||||
const toolName = determineToolName(javaVersion, false);
|
||||
let downloadUrl;
|
||||
if (javaVersion.includes('.')) {
|
||||
const majorJavaVersion = javaVersion.split('.')[0];
|
||||
downloadUrl = `${GRAALVM_DL_BASE}/${majorJavaVersion}/archive/${toolName}${c.GRAALVM_FILE_EXTENSION}`;
|
||||
}
|
||||
else {
|
||||
downloadUrl = `${GRAALVM_DL_BASE}/${javaVersion}/latest/${toolName}${c.GRAALVM_FILE_EXTENSION}`;
|
||||
}
|
||||
const downloader = () => __awaiter(this, void 0, void 0, function* () { return downloadGraalVMJDK(downloadUrl, javaVersion); });
|
||||
return (0, utils_1.downloadExtractAndCacheJDK)(downloader, toolName, javaVersion);
|
||||
});
|
||||
}
|
||||
exports.setUpGraalVMJDK = setUpGraalVMJDK;
|
||||
function setUpGraalVMJDKCE(javaVersionOrDev) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (javaVersionOrDev === c.VERSION_DEV) {
|
||||
return setUpGraalVMJDKDevBuild();
|
||||
}
|
||||
let javaVersion = javaVersionOrDev;
|
||||
if (!javaVersion.includes('.')) {
|
||||
javaVersion = yield findLatestGraalVMJDKCEJavaVersion(javaVersion);
|
||||
}
|
||||
if (javaVersion.split('.').length != 3) {
|
||||
throw new Error(`java-version set to '${javaVersionOrDev}', which was resolved to '${javaVersion}'. Please make sure the java-version is set correctly. ${c.ERROR_HINT}`);
|
||||
}
|
||||
const toolName = determineToolName(javaVersion, true);
|
||||
const downloadUrl = `${GRAALVM_CE_DL_BASE}/jdk-${javaVersion}/${toolName}${c.GRAALVM_FILE_EXTENSION}`;
|
||||
const downloader = () => __awaiter(this, void 0, void 0, function* () { return downloadGraalVMJDK(downloadUrl, javaVersion); });
|
||||
return (0, utils_1.downloadExtractAndCacheJDK)(downloader, toolName, javaVersion);
|
||||
});
|
||||
}
|
||||
exports.setUpGraalVMJDKCE = setUpGraalVMJDKCE;
|
||||
function findLatestGraalVMJDKCEJavaVersion(majorJavaVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const matchingRefs = yield (0, utils_1.getMatchingTags)(`${GRAALVM_JDK_TAG_PREFIX}${majorJavaVersion}`);
|
||||
const lowestNonExistingVersion = '0.0.1';
|
||||
let highestVersion = lowestNonExistingVersion;
|
||||
const versionNumberStartIndex = `refs/tags/${GRAALVM_JDK_TAG_PREFIX}`.length;
|
||||
for (const matchingRef of matchingRefs) {
|
||||
const currentVersion = matchingRef.ref.substring(versionNumberStartIndex);
|
||||
if ((0, semver_1.gt)(currentVersion, highestVersion)) {
|
||||
highestVersion = currentVersion;
|
||||
}
|
||||
}
|
||||
if (highestVersion === lowestNonExistingVersion) {
|
||||
throw new Error(`Unable to find the latest Java version for '${majorJavaVersion}'. Please make sure the java-version is set correctly. ${c.ERROR_HINT}`);
|
||||
}
|
||||
return highestVersion;
|
||||
});
|
||||
}
|
||||
exports.findLatestGraalVMJDKCEJavaVersion = findLatestGraalVMJDKCEJavaVersion;
|
||||
function determineToolName(javaVersion, isCommunity) {
|
||||
return `graalvm${isCommunity ? '-community' : ''}-jdk-${javaVersion}_${c.JDK_PLATFORM}-${c.JDK_ARCH}_bin`;
|
||||
}
|
||||
function downloadGraalVMJDK(downloadUrl, javaVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
return yield (0, tool_cache_1.downloadTool)(downloadUrl);
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof Error && error.message.includes('404')) {
|
||||
// Not Found
|
||||
throw new Error(`Failed to download ${(0, path_1.basename)(downloadUrl)}. Are you sure java-version: '${javaVersion}' is correct?`);
|
||||
}
|
||||
throw new Error(`Failed to download ${(0, path_1.basename)(downloadUrl)} (error: ${error}).`);
|
||||
}
|
||||
});
|
||||
}
|
||||
// Support for GraalVM dev builds
|
||||
function setUpGraalVMJDKDevBuild() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const latestDevBuild = yield (0, utils_1.getLatestRelease)(GRAALVM_REPO_DEV_BUILDS);
|
||||
const resolvedJavaVersion = findHighestJavaVersion(latestDevBuild, c.VERSION_DEV);
|
||||
const downloadUrl = findDownloadUrl(latestDevBuild, resolvedJavaVersion);
|
||||
return (0, utils_1.downloadAndExtractJDK)(downloadUrl);
|
||||
});
|
||||
}
|
||||
exports.setUpGraalVMJDKDevBuild = setUpGraalVMJDKDevBuild;
|
||||
function findHighestJavaVersion(release, version) {
|
||||
const graalVMIdentifierPattern = determineGraalVMLegacyIdentifier(false, version, '(\\d+)');
|
||||
const expectedFileNameRegExp = new RegExp(`^${graalVMIdentifierPattern}${c.GRAALVM_FILE_EXTENSION.replace(/\./g, '\\.')}$`);
|
||||
let highestJavaVersion = 0;
|
||||
for (const asset of release.assets) {
|
||||
const matches = asset.name.match(expectedFileNameRegExp);
|
||||
if (matches) {
|
||||
const javaVersion = +matches[1];
|
||||
if (javaVersion > highestJavaVersion) {
|
||||
highestJavaVersion = javaVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (highestJavaVersion > 0) {
|
||||
return String(highestJavaVersion);
|
||||
}
|
||||
else {
|
||||
throw new Error('Could not find highest Java version. Please file an issue at: https://github.com/graalvm/setup-graalvm/issues.');
|
||||
}
|
||||
}
|
||||
exports.findHighestJavaVersion = findHighestJavaVersion;
|
||||
// Support for GraalVM 22.X releases and earlier
|
||||
function setUpGraalVMLatest(gdsToken, javaVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const lockedVersion = '22.3.1';
|
||||
@ -70796,80 +70951,41 @@ function findGraalVMVersion(release) {
|
||||
return tag_name.substring(GRAALVM_TAG_PREFIX.length, tag_name.length);
|
||||
}
|
||||
exports.findGraalVMVersion = findGraalVMVersion;
|
||||
function setUpGraalVMDevBuild(gdsToken, javaVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (gdsToken.length > 0) {
|
||||
throw new Error('Downloading GraalVM EE dev builds is not supported');
|
||||
}
|
||||
const latestDevBuild = yield (0, utils_1.getLatestRelease)(GRAALVM_REPO_DEV_BUILDS);
|
||||
let resolvedJavaVersion;
|
||||
if (javaVersion == c.VERSION_DEV) {
|
||||
resolvedJavaVersion = findHighestJavaVersion(latestDevBuild, c.VERSION_DEV);
|
||||
}
|
||||
else {
|
||||
resolvedJavaVersion = javaVersion;
|
||||
}
|
||||
const downloadUrl = findDownloadUrl(latestDevBuild, resolvedJavaVersion);
|
||||
return (0, utils_1.downloadAndExtractJDK)(downloadUrl);
|
||||
});
|
||||
}
|
||||
exports.setUpGraalVMDevBuild = setUpGraalVMDevBuild;
|
||||
function setUpGraalVMRelease(gdsToken, version, javaVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const isEE = gdsToken.length > 0;
|
||||
const toolName = determineToolName(isEE, version, javaVersion);
|
||||
const toolName = determineLegacyToolName(isEE, version, javaVersion);
|
||||
let downloader;
|
||||
if (isEE) {
|
||||
downloader = () => __awaiter(this, void 0, void 0, function* () { return (0, gds_1.downloadGraalVMEE)(gdsToken, version, javaVersion); });
|
||||
downloader = () => __awaiter(this, void 0, void 0, function* () { return (0, gds_1.downloadGraalVMEELegacy)(gdsToken, version, javaVersion); });
|
||||
}
|
||||
else {
|
||||
downloader = () => __awaiter(this, void 0, void 0, function* () { return downloadGraalVMCE(version, javaVersion); });
|
||||
downloader = () => __awaiter(this, void 0, void 0, function* () { return downloadGraalVMCELegacy(version, javaVersion); });
|
||||
}
|
||||
return (0, utils_1.downloadExtractAndCacheJDK)(downloader, toolName, version);
|
||||
});
|
||||
}
|
||||
exports.setUpGraalVMRelease = setUpGraalVMRelease;
|
||||
function findHighestJavaVersion(release, version) {
|
||||
const graalVMIdentifierPattern = determineGraalVMIdentifier(false, version, '(\\d+)');
|
||||
const expectedFileNameRegExp = new RegExp(`^${graalVMIdentifierPattern}${c.GRAALVM_FILE_EXTENSION.replace(/\./g, '\\.')}$`);
|
||||
let highestJavaVersion = 0;
|
||||
for (const asset of release.assets) {
|
||||
const matches = asset.name.match(expectedFileNameRegExp);
|
||||
if (matches) {
|
||||
const javaVersion = +matches[1];
|
||||
if (javaVersion > highestJavaVersion) {
|
||||
highestJavaVersion = javaVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (highestJavaVersion > 0) {
|
||||
return String(highestJavaVersion);
|
||||
}
|
||||
else {
|
||||
throw new Error('Could not find highest Java version. Please file an issue at: https://github.com/graalvm/setup-graalvm/issues.');
|
||||
}
|
||||
}
|
||||
exports.findHighestJavaVersion = findHighestJavaVersion;
|
||||
function findDownloadUrl(release, javaVersion) {
|
||||
const graalVMIdentifier = determineGraalVMIdentifier(false, c.VERSION_DEV, javaVersion);
|
||||
const graalVMIdentifier = determineGraalVMLegacyIdentifier(false, c.VERSION_DEV, javaVersion);
|
||||
const expectedFileName = `${graalVMIdentifier}${c.GRAALVM_FILE_EXTENSION}`;
|
||||
for (const asset of release.assets) {
|
||||
if (asset.name === expectedFileName) {
|
||||
return asset.browser_download_url;
|
||||
}
|
||||
}
|
||||
throw new Error(`Could not find GraalVM dev build for Java ${javaVersion}. It may no longer be available, so please consider upgrading the Java version. If you think this is a mistake, please file an issue at: https://github.com/graalvm/setup-graalvm/issues.`);
|
||||
throw new Error(`Could not find GraalVM dev build for Java ${javaVersion}. It may no longer be available, so please consider upgrading the Java version. ${c.ERROR_HINT}`);
|
||||
}
|
||||
function determineGraalVMIdentifier(isEE, version, javaVersion) {
|
||||
return `${determineToolName(isEE, version, javaVersion)}-${c.GRAALVM_ARCH}-${version}`;
|
||||
function determineGraalVMLegacyIdentifier(isEE, version, javaVersion) {
|
||||
return `${determineLegacyToolName(isEE, version, javaVersion)}-${c.GRAALVM_ARCH}-${version}`;
|
||||
}
|
||||
function determineToolName(isEE, version, javaVersion) {
|
||||
function determineLegacyToolName(isEE, version, javaVersion) {
|
||||
const infix = isEE ? 'ee' : version === c.VERSION_DEV ? 'community' : 'ce';
|
||||
return `graalvm-${infix}-java${javaVersion}-${c.GRAALVM_PLATFORM}`;
|
||||
}
|
||||
function downloadGraalVMCE(version, javaVersion) {
|
||||
function downloadGraalVMCELegacy(version, javaVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const graalVMIdentifier = determineGraalVMIdentifier(false, version, javaVersion);
|
||||
const graalVMIdentifier = determineGraalVMLegacyIdentifier(false, version, javaVersion);
|
||||
const downloadUrl = `${GRAALVM_CE_DL_BASE}/${GRAALVM_TAG_PREFIX}${version}/${graalVMIdentifier}${c.GRAALVM_FILE_EXTENSION}`;
|
||||
try {
|
||||
return yield (0, tool_cache_1.downloadTool)(downloadUrl);
|
||||
@ -70999,9 +71115,10 @@ const reports_1 = __nccwpck_require__(2046);
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const graalvmVersion = core.getInput(c.INPUT_VERSION, { required: true });
|
||||
const gdsToken = core.getInput(c.INPUT_GDS_TOKEN);
|
||||
const javaVersion = core.getInput(c.INPUT_JAVA_VERSION, { required: true });
|
||||
const distribution = core.getInput(c.INPUT_DISTRIBUTION);
|
||||
const graalvmVersion = core.getInput(c.INPUT_VERSION);
|
||||
const gdsToken = core.getInput(c.INPUT_GDS_TOKEN);
|
||||
const componentsString = core.getInput(c.INPUT_COMPONENTS);
|
||||
const components = componentsString.length > 0
|
||||
? componentsString.split(',').map(x => x.trim())
|
||||
@ -71019,24 +71136,58 @@ function run() {
|
||||
}
|
||||
// Download or build GraalVM
|
||||
let graalVMHome;
|
||||
switch (graalvmVersion) {
|
||||
case c.VERSION_LATEST:
|
||||
graalVMHome = yield graalvm.setUpGraalVMLatest(gdsToken, javaVersion);
|
||||
break;
|
||||
case c.VERSION_DEV:
|
||||
graalVMHome = yield graalvm.setUpGraalVMDevBuild(gdsToken, javaVersion);
|
||||
break;
|
||||
default:
|
||||
if (graalvmVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
||||
graalVMHome = yield (0, mandrel_1.setUpMandrel)(graalvmVersion, javaVersion);
|
||||
}
|
||||
else {
|
||||
if (enableCheckForUpdates) {
|
||||
yield (0, check_for_updates_1.checkForUpdates)(graalvmVersion, javaVersion);
|
||||
if (distribution.length > 0 || graalvmVersion.length == 0) {
|
||||
switch (distribution) {
|
||||
case c.DISTRIBUTION_GRAALVM:
|
||||
graalVMHome = yield graalvm.setUpGraalVMJDK(javaVersion);
|
||||
break;
|
||||
case c.DISTRIBUTION_GRAALVM_COMMUNITY:
|
||||
graalVMHome = yield graalvm.setUpGraalVMJDKCE(javaVersion);
|
||||
break;
|
||||
case c.DISTRIBUTION_MANDREL:
|
||||
throw new Error(`Mandrel requires the 'version' option (see https://github.com/graalvm/setup-graalvm/tree/main#options).`);
|
||||
case '':
|
||||
if (javaVersion === c.VERSION_DEV) {
|
||||
core.info(`This build is using the GraalVM Community Edition. To select a specific distribution, use the 'distribution' option (see https://github.com/graalvm/setup-graalvm/tree/main#options).`);
|
||||
graalVMHome = yield graalvm.setUpGraalVMJDKDevBuild();
|
||||
}
|
||||
graalVMHome = yield graalvm.setUpGraalVMRelease(gdsToken, graalvmVersion, javaVersion);
|
||||
}
|
||||
break;
|
||||
else {
|
||||
core.info(`This build is using the new Oracle GraalVM. To select a specific distribution, use the 'distribution' option (see https://github.com/graalvm/setup-graalvm/tree/main#options).`);
|
||||
graalVMHome = yield graalvm.setUpGraalVMJDK(javaVersion);
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unsupported distribution: ${distribution}`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (graalvmVersion) {
|
||||
case c.VERSION_LATEST:
|
||||
if (javaVersion.startsWith('17') || javaVersion.startsWith('20')) {
|
||||
core.info(`This build is using the new Oracle GraalVM. To select a specific distribution, use the 'distribution' option (see https://github.com/graalvm/setup-graalvm/tree/main#options).`);
|
||||
graalVMHome = yield graalvm.setUpGraalVMJDK(javaVersion);
|
||||
}
|
||||
else {
|
||||
graalVMHome = yield graalvm.setUpGraalVMLatest(gdsToken, javaVersion);
|
||||
}
|
||||
break;
|
||||
case c.VERSION_DEV:
|
||||
if (gdsToken.length > 0) {
|
||||
throw new Error('Downloading GraalVM EE dev builds is not supported');
|
||||
}
|
||||
graalVMHome = yield graalvm.setUpGraalVMJDKDevBuild();
|
||||
break;
|
||||
default:
|
||||
if (graalvmVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
||||
graalVMHome = yield (0, mandrel_1.setUpMandrel)(graalvmVersion, javaVersion);
|
||||
}
|
||||
else {
|
||||
if (enableCheckForUpdates) {
|
||||
yield (0, check_for_updates_1.checkForUpdates)(graalvmVersion, javaVersion);
|
||||
}
|
||||
graalVMHome = yield graalvm.setUpGraalVMRelease(gdsToken, graalvmVersion, javaVersion);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Activate GraalVM
|
||||
core.debug(`Activating GraalVM located at '${graalVMHome}'...`);
|
||||
@ -71293,7 +71444,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.createPRComment = exports.isPREvent = exports.toSemVer = exports.calculateSHA256 = exports.downloadExtractAndCacheJDK = exports.downloadAndExtractJDK = exports.getTaggedRelease = exports.getLatestRelease = exports.exec = void 0;
|
||||
exports.createPRComment = exports.isPREvent = exports.toSemVer = exports.calculateSHA256 = exports.downloadExtractAndCacheJDK = exports.downloadAndExtractJDK = exports.getMatchingTags = exports.getTaggedRelease = exports.getLatestRelease = exports.exec = void 0;
|
||||
const c = __importStar(__nccwpck_require__(9042));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const github = __importStar(__nccwpck_require__(5438));
|
||||
@ -71348,6 +71499,19 @@ function getTaggedRelease(repo, tag) {
|
||||
});
|
||||
}
|
||||
exports.getTaggedRelease = getTaggedRelease;
|
||||
function getMatchingTags(tagPrefix) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const githubToken = getGitHubToken();
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
||||
const octokit = new GitHubDotCom(options);
|
||||
return (yield octokit.request('GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo: c.GRAALVM_RELEASES_REPO,
|
||||
tagPrefix
|
||||
})).data;
|
||||
});
|
||||
}
|
||||
exports.getMatchingTags = getMatchingTags;
|
||||
function downloadAndExtractJDK(downloadUrl) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return findJavaHomeInSubfolder(yield extract(yield tc.downloadTool(downloadUrl)));
|
||||
|
@ -3,6 +3,7 @@ import * as otypes from '@octokit/types'
|
||||
export const INPUT_VERSION = 'version'
|
||||
export const INPUT_GDS_TOKEN = 'gds-token'
|
||||
export const INPUT_JAVA_VERSION = 'java-version'
|
||||
export const INPUT_DISTRIBUTION = 'distribution'
|
||||
export const INPUT_COMPONENTS = 'components'
|
||||
export const INPUT_GITHUB_TOKEN = 'github-token'
|
||||
export const INPUT_SET_JAVA_HOME = 'set-java-home'
|
||||
@ -14,15 +15,22 @@ export const IS_LINUX = process.platform === 'linux'
|
||||
export const IS_MACOS = process.platform === 'darwin'
|
||||
export const IS_WINDOWS = process.platform === 'win32'
|
||||
|
||||
export const DISTRIBUTION_GRAALVM = 'graalvm'
|
||||
export const DISTRIBUTION_GRAALVM_COMMUNITY = 'graalvm-community'
|
||||
export const DISTRIBUTION_MANDREL = 'mandrel'
|
||||
|
||||
export const VERSION_DEV = 'dev'
|
||||
export const VERSION_LATEST = 'latest'
|
||||
|
||||
export const JDK_ARCH = determineJDKArchitecture()
|
||||
export const JDK_PLATFORM = determineJDKPlatform()
|
||||
export const JDK_HOME_SUFFIX = IS_MACOS ? '/Contents/Home' : ''
|
||||
|
||||
export const GRAALVM_ARCH = determineGraalVMArchitecture()
|
||||
export const GRAALVM_FILE_EXTENSION = IS_WINDOWS ? '.zip' : '.tar.gz'
|
||||
export const GRAALVM_GH_USER = 'graalvm'
|
||||
export const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform
|
||||
export const GRAALVM_RELEASES_REPO = 'graalvm-ce-builds'
|
||||
export const JDK_HOME_SUFFIX = IS_MACOS ? '/Contents/Home' : ''
|
||||
|
||||
export const MANDREL_NAMESPACE = 'mandrel-'
|
||||
|
||||
@ -32,9 +40,46 @@ export const GDS_GRAALVM_PRODUCT_ID = 'D53FAE8052773FFAE0530F15000AA6C6'
|
||||
export const ENV_GITHUB_EVENT_NAME = 'GITHUB_EVENT_NAME'
|
||||
export const EVENT_NAME_PULL_REQUEST = 'pull_request'
|
||||
|
||||
export const ERROR_HINT =
|
||||
'If you think this is a mistake, please file an issue at: https://github.com/graalvm/setup-graalvm/issues.'
|
||||
|
||||
export type LatestReleaseResponse =
|
||||
otypes.Endpoints['GET /repos/{owner}/{repo}/releases/latest']['response']
|
||||
|
||||
export type MatchingRefsResponse =
|
||||
otypes.Endpoints['GET /repos/{owner}/{repo}/git/matching-refs/{ref}']['response']
|
||||
|
||||
function determineJDKArchitecture(): string {
|
||||
switch (process.arch) {
|
||||
case 'x64': {
|
||||
return 'x64'
|
||||
}
|
||||
case 'arm64': {
|
||||
return 'aarch64'
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported architecture: ${process.arch}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function determineJDKPlatform(): string {
|
||||
switch (process.platform) {
|
||||
case 'linux': {
|
||||
return 'linux'
|
||||
}
|
||||
case 'darwin': {
|
||||
return 'macos'
|
||||
}
|
||||
case 'win32': {
|
||||
return 'windows'
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported platform: ${process.platform}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function determineGraalVMArchitecture(): string {
|
||||
switch (process.arch) {
|
||||
case 'x64': {
|
||||
|
@ -8,6 +8,17 @@ export async function checkForUpdates(
|
||||
graalVMVersion: string,
|
||||
javaVersion: string
|
||||
): Promise<void> {
|
||||
if (
|
||||
graalVMVersion.length > 0 &&
|
||||
(javaVersion === '17' || javaVersion === '19')
|
||||
) {
|
||||
const recommendedJDK = javaVersion === '17' ? '17' : '20'
|
||||
core.notice(
|
||||
`A new GraalVM release is available! Please consider upgrading to GraalVM for JDK ${recommendedJDK}. Release notes: https://www.graalvm.org/release-notes/JDK_${recommendedJDK}/`
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (graalVMVersion.startsWith('22.3.') && javaVersion === '11') {
|
||||
core.notice(
|
||||
'Please consider upgrading your project to Java 17+. GraalVM 22.3.X releases are the last to support JDK11: https://github.com/oracle/graal/issues/5063'
|
||||
|
@ -88,6 +88,7 @@ export async function setUpNativeImageBuildReports(
|
||||
const isSupported =
|
||||
graalVMVersion === c.VERSION_LATEST ||
|
||||
graalVMVersion === c.VERSION_DEV ||
|
||||
graalVMVersion.length === 0 ||
|
||||
(!graalVMVersion.startsWith(c.MANDREL_NAMESPACE) &&
|
||||
gte(toSemVer(graalVMVersion), '22.2.0'))
|
||||
if (!isSupported) {
|
||||
|
@ -27,7 +27,7 @@ interface GDSErrorResponse {
|
||||
readonly message: string
|
||||
}
|
||||
|
||||
export async function downloadGraalVMEE(
|
||||
export async function downloadGraalVMEELegacy(
|
||||
gdsToken: string,
|
||||
version: string,
|
||||
javaVersion: string
|
||||
|
210
src/graalvm.ts
210
src/graalvm.ts
@ -3,78 +3,129 @@ import {
|
||||
downloadAndExtractJDK,
|
||||
downloadExtractAndCacheJDK,
|
||||
getLatestRelease,
|
||||
getMatchingTags,
|
||||
getTaggedRelease
|
||||
} from './utils'
|
||||
import {downloadGraalVMEE} from './gds'
|
||||
import {downloadGraalVMEELegacy} from './gds'
|
||||
import {downloadTool} from '@actions/tool-cache'
|
||||
import {basename} from 'path'
|
||||
import {gt} from 'semver'
|
||||
|
||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm'
|
||||
const GRAALVM_CE_DL_BASE = `https://github.com/graalvm/${c.GRAALVM_RELEASES_REPO}/releases/download`
|
||||
const GRAALVM_REPO_DEV_BUILDS = 'graalvm-ce-dev-builds'
|
||||
const GRAALVM_JDK_TAG_PREFIX = 'jdk-'
|
||||
const GRAALVM_TAG_PREFIX = 'vm-'
|
||||
|
||||
export async function setUpGraalVMLatest(
|
||||
gdsToken: string,
|
||||
javaVersion: string
|
||||
): Promise<string> {
|
||||
const lockedVersion = '22.3.1'
|
||||
if (gdsToken.length > 0) {
|
||||
return setUpGraalVMRelease(gdsToken, lockedVersion, javaVersion)
|
||||
}
|
||||
const latestRelease = await getTaggedRelease(
|
||||
c.GRAALVM_RELEASES_REPO,
|
||||
GRAALVM_TAG_PREFIX + lockedVersion
|
||||
)
|
||||
const version = findGraalVMVersion(latestRelease)
|
||||
return setUpGraalVMRelease(gdsToken, version, javaVersion)
|
||||
}
|
||||
// Support for GraalVM for JDK 17 and later
|
||||
|
||||
export function findGraalVMVersion(release: c.LatestReleaseResponse['data']) {
|
||||
const tag_name = release.tag_name
|
||||
if (!tag_name.startsWith(GRAALVM_TAG_PREFIX)) {
|
||||
throw new Error(`Could not find latest GraalVM release: ${tag_name}`)
|
||||
}
|
||||
return tag_name.substring(GRAALVM_TAG_PREFIX.length, tag_name.length)
|
||||
}
|
||||
|
||||
export async function setUpGraalVMDevBuild(
|
||||
gdsToken: string,
|
||||
javaVersion: string
|
||||
export async function setUpGraalVMJDK(
|
||||
javaVersionOrDev: string
|
||||
): Promise<string> {
|
||||
if (gdsToken.length > 0) {
|
||||
throw new Error('Downloading GraalVM EE dev builds is not supported')
|
||||
if (javaVersionOrDev === c.VERSION_DEV) {
|
||||
return setUpGraalVMJDKDevBuild()
|
||||
}
|
||||
const latestDevBuild = await getLatestRelease(GRAALVM_REPO_DEV_BUILDS)
|
||||
let resolvedJavaVersion
|
||||
if (javaVersion == c.VERSION_DEV) {
|
||||
resolvedJavaVersion = findHighestJavaVersion(latestDevBuild, c.VERSION_DEV)
|
||||
const javaVersion = javaVersionOrDev
|
||||
const toolName = determineToolName(javaVersion, false)
|
||||
let downloadUrl: string
|
||||
if (javaVersion.includes('.')) {
|
||||
const majorJavaVersion = javaVersion.split('.')[0]
|
||||
downloadUrl = `${GRAALVM_DL_BASE}/${majorJavaVersion}/archive/${toolName}${c.GRAALVM_FILE_EXTENSION}`
|
||||
} else {
|
||||
resolvedJavaVersion = javaVersion
|
||||
downloadUrl = `${GRAALVM_DL_BASE}/${javaVersion}/latest/${toolName}${c.GRAALVM_FILE_EXTENSION}`
|
||||
}
|
||||
const downloader = async () => downloadGraalVMJDK(downloadUrl, javaVersion)
|
||||
return downloadExtractAndCacheJDK(downloader, toolName, javaVersion)
|
||||
}
|
||||
|
||||
export async function setUpGraalVMJDKCE(
|
||||
javaVersionOrDev: string
|
||||
): Promise<string> {
|
||||
if (javaVersionOrDev === c.VERSION_DEV) {
|
||||
return setUpGraalVMJDKDevBuild()
|
||||
}
|
||||
let javaVersion = javaVersionOrDev
|
||||
if (!javaVersion.includes('.')) {
|
||||
javaVersion = await findLatestGraalVMJDKCEJavaVersion(javaVersion)
|
||||
}
|
||||
if (javaVersion.split('.').length != 3) {
|
||||
throw new Error(
|
||||
`java-version set to '${javaVersionOrDev}', which was resolved to '${javaVersion}'. Please make sure the java-version is set correctly. ${c.ERROR_HINT}`
|
||||
)
|
||||
}
|
||||
const toolName = determineToolName(javaVersion, true)
|
||||
const downloadUrl = `${GRAALVM_CE_DL_BASE}/jdk-${javaVersion}/${toolName}${c.GRAALVM_FILE_EXTENSION}`
|
||||
const downloader = async () => downloadGraalVMJDK(downloadUrl, javaVersion)
|
||||
return downloadExtractAndCacheJDK(downloader, toolName, javaVersion)
|
||||
}
|
||||
|
||||
export async function findLatestGraalVMJDKCEJavaVersion(
|
||||
majorJavaVersion: string
|
||||
): Promise<string> {
|
||||
const matchingRefs = await getMatchingTags(
|
||||
`${GRAALVM_JDK_TAG_PREFIX}${majorJavaVersion}`
|
||||
)
|
||||
const lowestNonExistingVersion = '0.0.1'
|
||||
let highestVersion = lowestNonExistingVersion
|
||||
const versionNumberStartIndex = `refs/tags/${GRAALVM_JDK_TAG_PREFIX}`.length
|
||||
for (const matchingRef of matchingRefs) {
|
||||
const currentVersion = matchingRef.ref.substring(versionNumberStartIndex)
|
||||
if (gt(currentVersion, highestVersion)) {
|
||||
highestVersion = currentVersion
|
||||
}
|
||||
}
|
||||
if (highestVersion === lowestNonExistingVersion) {
|
||||
throw new Error(
|
||||
`Unable to find the latest Java version for '${majorJavaVersion}'. Please make sure the java-version is set correctly. ${c.ERROR_HINT}`
|
||||
)
|
||||
}
|
||||
return highestVersion
|
||||
}
|
||||
|
||||
function determineToolName(javaVersion: string, isCommunity: boolean) {
|
||||
return `graalvm${isCommunity ? '-community' : ''}-jdk-${javaVersion}_${
|
||||
c.JDK_PLATFORM
|
||||
}-${c.JDK_ARCH}_bin`
|
||||
}
|
||||
|
||||
async function downloadGraalVMJDK(
|
||||
downloadUrl: string,
|
||||
javaVersion: string
|
||||
): Promise<string> {
|
||||
try {
|
||||
return await downloadTool(downloadUrl)
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message.includes('404')) {
|
||||
// Not Found
|
||||
throw new Error(
|
||||
`Failed to download ${basename(
|
||||
downloadUrl
|
||||
)}. Are you sure java-version: '${javaVersion}' is correct?`
|
||||
)
|
||||
}
|
||||
throw new Error(
|
||||
`Failed to download ${basename(downloadUrl)} (error: ${error}).`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Support for GraalVM dev builds
|
||||
|
||||
export async function setUpGraalVMJDKDevBuild(): Promise<string> {
|
||||
const latestDevBuild = await getLatestRelease(GRAALVM_REPO_DEV_BUILDS)
|
||||
const resolvedJavaVersion = findHighestJavaVersion(
|
||||
latestDevBuild,
|
||||
c.VERSION_DEV
|
||||
)
|
||||
const downloadUrl = findDownloadUrl(latestDevBuild, resolvedJavaVersion)
|
||||
return downloadAndExtractJDK(downloadUrl)
|
||||
}
|
||||
|
||||
export async function setUpGraalVMRelease(
|
||||
gdsToken: string,
|
||||
version: string,
|
||||
javaVersion: string
|
||||
): Promise<string> {
|
||||
const isEE = gdsToken.length > 0
|
||||
const toolName = determineToolName(isEE, version, javaVersion)
|
||||
let downloader: () => Promise<string>
|
||||
if (isEE) {
|
||||
downloader = async () => downloadGraalVMEE(gdsToken, version, javaVersion)
|
||||
} else {
|
||||
downloader = async () => downloadGraalVMCE(version, javaVersion)
|
||||
}
|
||||
return downloadExtractAndCacheJDK(downloader, toolName, version)
|
||||
}
|
||||
|
||||
export function findHighestJavaVersion(
|
||||
release: c.LatestReleaseResponse['data'],
|
||||
version: string
|
||||
): string {
|
||||
const graalVMIdentifierPattern = determineGraalVMIdentifier(
|
||||
const graalVMIdentifierPattern = determineGraalVMLegacyIdentifier(
|
||||
false,
|
||||
version,
|
||||
'(\\d+)'
|
||||
@ -104,11 +155,54 @@ export function findHighestJavaVersion(
|
||||
}
|
||||
}
|
||||
|
||||
// Support for GraalVM 22.X releases and earlier
|
||||
|
||||
export async function setUpGraalVMLatest(
|
||||
gdsToken: string,
|
||||
javaVersion: string
|
||||
): Promise<string> {
|
||||
const lockedVersion = '22.3.1'
|
||||
if (gdsToken.length > 0) {
|
||||
return setUpGraalVMRelease(gdsToken, lockedVersion, javaVersion)
|
||||
}
|
||||
const latestRelease = await getTaggedRelease(
|
||||
c.GRAALVM_RELEASES_REPO,
|
||||
GRAALVM_TAG_PREFIX + lockedVersion
|
||||
)
|
||||
const version = findGraalVMVersion(latestRelease)
|
||||
return setUpGraalVMRelease(gdsToken, version, javaVersion)
|
||||
}
|
||||
|
||||
export function findGraalVMVersion(release: c.LatestReleaseResponse['data']) {
|
||||
const tag_name = release.tag_name
|
||||
if (!tag_name.startsWith(GRAALVM_TAG_PREFIX)) {
|
||||
throw new Error(`Could not find latest GraalVM release: ${tag_name}`)
|
||||
}
|
||||
return tag_name.substring(GRAALVM_TAG_PREFIX.length, tag_name.length)
|
||||
}
|
||||
|
||||
export async function setUpGraalVMRelease(
|
||||
gdsToken: string,
|
||||
version: string,
|
||||
javaVersion: string
|
||||
): Promise<string> {
|
||||
const isEE = gdsToken.length > 0
|
||||
const toolName = determineLegacyToolName(isEE, version, javaVersion)
|
||||
let downloader: () => Promise<string>
|
||||
if (isEE) {
|
||||
downloader = async () =>
|
||||
downloadGraalVMEELegacy(gdsToken, version, javaVersion)
|
||||
} else {
|
||||
downloader = async () => downloadGraalVMCELegacy(version, javaVersion)
|
||||
}
|
||||
return downloadExtractAndCacheJDK(downloader, toolName, version)
|
||||
}
|
||||
|
||||
function findDownloadUrl(
|
||||
release: c.LatestReleaseResponse['data'],
|
||||
javaVersion: string
|
||||
): string {
|
||||
const graalVMIdentifier = determineGraalVMIdentifier(
|
||||
const graalVMIdentifier = determineGraalVMLegacyIdentifier(
|
||||
false,
|
||||
c.VERSION_DEV,
|
||||
javaVersion
|
||||
@ -120,21 +214,21 @@ function findDownloadUrl(
|
||||
}
|
||||
}
|
||||
throw new Error(
|
||||
`Could not find GraalVM dev build for Java ${javaVersion}. It may no longer be available, so please consider upgrading the Java version. If you think this is a mistake, please file an issue at: https://github.com/graalvm/setup-graalvm/issues.`
|
||||
`Could not find GraalVM dev build for Java ${javaVersion}. It may no longer be available, so please consider upgrading the Java version. ${c.ERROR_HINT}`
|
||||
)
|
||||
}
|
||||
|
||||
function determineGraalVMIdentifier(
|
||||
function determineGraalVMLegacyIdentifier(
|
||||
isEE: boolean,
|
||||
version: string,
|
||||
javaVersion: string
|
||||
): string {
|
||||
return `${determineToolName(isEE, version, javaVersion)}-${
|
||||
return `${determineLegacyToolName(isEE, version, javaVersion)}-${
|
||||
c.GRAALVM_ARCH
|
||||
}-${version}`
|
||||
}
|
||||
|
||||
function determineToolName(
|
||||
function determineLegacyToolName(
|
||||
isEE: boolean,
|
||||
version: string,
|
||||
javaVersion: string
|
||||
@ -143,11 +237,11 @@ function determineToolName(
|
||||
return `graalvm-${infix}-java${javaVersion}-${c.GRAALVM_PLATFORM}`
|
||||
}
|
||||
|
||||
async function downloadGraalVMCE(
|
||||
async function downloadGraalVMCELegacy(
|
||||
version: string,
|
||||
javaVersion: string
|
||||
): Promise<string> {
|
||||
const graalVMIdentifier = determineGraalVMIdentifier(
|
||||
const graalVMIdentifier = determineGraalVMLegacyIdentifier(
|
||||
false,
|
||||
version,
|
||||
javaVersion
|
||||
|
89
src/main.ts
89
src/main.ts
@ -14,9 +14,10 @@ import {setUpNativeImageBuildReports} from './features/reports'
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
const graalvmVersion = core.getInput(c.INPUT_VERSION, {required: true})
|
||||
const gdsToken = core.getInput(c.INPUT_GDS_TOKEN)
|
||||
const javaVersion = core.getInput(c.INPUT_JAVA_VERSION, {required: true})
|
||||
const distribution = core.getInput(c.INPUT_DISTRIBUTION)
|
||||
const graalvmVersion = core.getInput(c.INPUT_VERSION)
|
||||
const gdsToken = core.getInput(c.INPUT_GDS_TOKEN)
|
||||
const componentsString: string = core.getInput(c.INPUT_COMPONENTS)
|
||||
const components: string[] =
|
||||
componentsString.length > 0
|
||||
@ -38,27 +39,71 @@ async function run(): Promise<void> {
|
||||
|
||||
// Download or build GraalVM
|
||||
let graalVMHome
|
||||
switch (graalvmVersion) {
|
||||
case c.VERSION_LATEST:
|
||||
graalVMHome = await graalvm.setUpGraalVMLatest(gdsToken, javaVersion)
|
||||
break
|
||||
case c.VERSION_DEV:
|
||||
graalVMHome = await graalvm.setUpGraalVMDevBuild(gdsToken, javaVersion)
|
||||
break
|
||||
default:
|
||||
if (graalvmVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
||||
graalVMHome = await setUpMandrel(graalvmVersion, javaVersion)
|
||||
} else {
|
||||
if (enableCheckForUpdates) {
|
||||
await checkForUpdates(graalvmVersion, javaVersion)
|
||||
}
|
||||
graalVMHome = await graalvm.setUpGraalVMRelease(
|
||||
gdsToken,
|
||||
graalvmVersion,
|
||||
javaVersion
|
||||
if (distribution.length > 0 || graalvmVersion.length == 0) {
|
||||
switch (distribution) {
|
||||
case c.DISTRIBUTION_GRAALVM:
|
||||
graalVMHome = await graalvm.setUpGraalVMJDK(javaVersion)
|
||||
break
|
||||
case c.DISTRIBUTION_GRAALVM_COMMUNITY:
|
||||
graalVMHome = await graalvm.setUpGraalVMJDKCE(javaVersion)
|
||||
break
|
||||
case c.DISTRIBUTION_MANDREL:
|
||||
throw new Error(
|
||||
`Mandrel requires the 'version' option (see https://github.com/graalvm/setup-graalvm/tree/main#options).`
|
||||
)
|
||||
}
|
||||
break
|
||||
case '':
|
||||
if (javaVersion === c.VERSION_DEV) {
|
||||
core.info(
|
||||
`This build is using the GraalVM Community Edition. To select a specific distribution, use the 'distribution' option (see https://github.com/graalvm/setup-graalvm/tree/main#options).`
|
||||
)
|
||||
graalVMHome = await graalvm.setUpGraalVMJDKDevBuild()
|
||||
} else {
|
||||
core.info(
|
||||
`This build is using the new Oracle GraalVM. To select a specific distribution, use the 'distribution' option (see https://github.com/graalvm/setup-graalvm/tree/main#options).`
|
||||
)
|
||||
graalVMHome = await graalvm.setUpGraalVMJDK(javaVersion)
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unsupported distribution: ${distribution}`)
|
||||
}
|
||||
} else {
|
||||
switch (graalvmVersion) {
|
||||
case c.VERSION_LATEST:
|
||||
if (javaVersion.startsWith('17') || javaVersion.startsWith('20')) {
|
||||
core.info(
|
||||
`This build is using the new Oracle GraalVM. To select a specific distribution, use the 'distribution' option (see https://github.com/graalvm/setup-graalvm/tree/main#options).`
|
||||
)
|
||||
graalVMHome = await graalvm.setUpGraalVMJDK(javaVersion)
|
||||
} else {
|
||||
graalVMHome = await graalvm.setUpGraalVMLatest(
|
||||
gdsToken,
|
||||
javaVersion
|
||||
)
|
||||
}
|
||||
break
|
||||
case c.VERSION_DEV:
|
||||
if (gdsToken.length > 0) {
|
||||
throw new Error(
|
||||
'Downloading GraalVM EE dev builds is not supported'
|
||||
)
|
||||
}
|
||||
graalVMHome = await graalvm.setUpGraalVMJDKDevBuild()
|
||||
break
|
||||
default:
|
||||
if (graalvmVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
||||
graalVMHome = await setUpMandrel(graalvmVersion, javaVersion)
|
||||
} else {
|
||||
if (enableCheckForUpdates) {
|
||||
await checkForUpdates(graalvmVersion, javaVersion)
|
||||
}
|
||||
graalVMHome = await graalvm.setUpGraalVMRelease(
|
||||
gdsToken,
|
||||
graalvmVersion,
|
||||
javaVersion
|
||||
)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Activate GraalVM
|
||||
|
18
src/utils.ts
18
src/utils.ts
@ -63,6 +63,24 @@ export async function getTaggedRelease(
|
||||
).data
|
||||
}
|
||||
|
||||
export async function getMatchingTags(
|
||||
tagPrefix: string
|
||||
): Promise<c.MatchingRefsResponse['data']> {
|
||||
const githubToken = getGitHubToken()
|
||||
const options = githubToken.length > 0 ? {auth: githubToken} : {}
|
||||
const octokit = new GitHubDotCom(options)
|
||||
return (
|
||||
await octokit.request(
|
||||
'GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}',
|
||||
{
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo: c.GRAALVM_RELEASES_REPO,
|
||||
tagPrefix
|
||||
}
|
||||
)
|
||||
).data
|
||||
}
|
||||
|
||||
export async function downloadAndExtractJDK(
|
||||
downloadUrl: string
|
||||
): Promise<string> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user