2022-01-03 08:52:11 +01:00
|
|
|
import * as c from './constants'
|
2022-01-03 08:43:40 +01:00
|
|
|
import * as core from '@actions/core'
|
2022-01-03 08:52:11 +01:00
|
|
|
import * as graalvm from './graalvm'
|
|
|
|
import {join} from 'path'
|
2022-01-03 08:54:37 +01:00
|
|
|
import {setUpDependencies} from './dependencies'
|
2022-01-03 08:57:03 +01:00
|
|
|
import {setUpGUComponents} from './gu'
|
2022-01-03 09:00:36 +01:00
|
|
|
import {setUpMandrel} from './mandrel'
|
2022-01-20 17:49:45 +01:00
|
|
|
import {setUpNativeImageMusl} from './features'
|
2022-01-03 08:53:37 +01:00
|
|
|
import {setUpWindowsEnvironment} from './msvc'
|
2022-01-03 08:43:40 +01:00
|
|
|
|
|
|
|
async function run(): Promise<void> {
|
|
|
|
try {
|
2022-01-20 17:49:45 +01:00
|
|
|
const graalvmVersion = core.getInput('version', {required: true})
|
2022-03-03 17:24:24 +01:00
|
|
|
const gdsToken = core.getInput('gds-token')
|
2022-01-20 17:49:45 +01:00
|
|
|
const javaVersion = core.getInput('java-version', {required: true})
|
2022-01-03 08:52:11 +01:00
|
|
|
const componentsString: string = core.getInput('components')
|
|
|
|
const components: string[] =
|
|
|
|
componentsString.length > 0 ? componentsString.split(',') : []
|
|
|
|
const setJavaHome = core.getInput('set-java-home') === 'true'
|
2022-01-20 17:49:45 +01:00
|
|
|
const enableNativeImageMusl = core.getInput('native-image-musl') === 'true'
|
2022-01-03 08:52:11 +01:00
|
|
|
|
2022-01-03 08:53:37 +01:00
|
|
|
if (c.IS_WINDOWS) {
|
|
|
|
setUpWindowsEnvironment()
|
|
|
|
}
|
2022-01-20 17:49:45 +01:00
|
|
|
await setUpDependencies(components)
|
|
|
|
if (enableNativeImageMusl) {
|
|
|
|
await setUpNativeImageMusl()
|
|
|
|
}
|
2022-01-03 08:53:37 +01:00
|
|
|
|
2022-01-03 08:52:11 +01:00
|
|
|
// Download or build GraalVM
|
2022-01-03 08:43:40 +01:00
|
|
|
let graalVMHome
|
2022-01-03 08:52:11 +01:00
|
|
|
switch (graalvmVersion) {
|
|
|
|
case c.VERSION_LATEST:
|
2022-03-03 17:24:24 +01:00
|
|
|
graalVMHome = await graalvm.setUpGraalVMLatest(gdsToken, javaVersion)
|
2022-01-03 08:52:11 +01:00
|
|
|
break
|
2022-01-03 13:11:04 +01:00
|
|
|
case c.VERSION_DEV:
|
2022-03-03 17:24:24 +01:00
|
|
|
graalVMHome = await graalvm.setUpGraalVMDevBuild(gdsToken, javaVersion)
|
2022-01-03 08:52:11 +01:00
|
|
|
break
|
|
|
|
default:
|
2022-01-03 09:00:36 +01:00
|
|
|
if (graalvmVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
|
|
|
graalVMHome = await setUpMandrel(graalvmVersion, javaVersion)
|
|
|
|
} else {
|
|
|
|
graalVMHome = await graalvm.setUpGraalVMRelease(
|
2022-03-03 17:24:24 +01:00
|
|
|
gdsToken,
|
2022-01-03 09:00:36 +01:00
|
|
|
graalvmVersion,
|
|
|
|
javaVersion
|
|
|
|
)
|
|
|
|
}
|
2022-01-03 08:52:11 +01:00
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
// Activate GraalVM
|
|
|
|
core.debug(`Activating GraalVM located at '${graalVMHome}'...`)
|
2022-01-03 08:43:40 +01:00
|
|
|
core.exportVariable('GRAALVM_HOME', graalVMHome)
|
2022-01-03 08:52:11 +01:00
|
|
|
core.addPath(join(graalVMHome, 'bin'))
|
|
|
|
if (setJavaHome) {
|
|
|
|
core.exportVariable('JAVA_HOME', graalVMHome)
|
|
|
|
}
|
2022-01-03 08:57:03 +01:00
|
|
|
|
|
|
|
// Set up GraalVM components (if any)
|
|
|
|
if (components.length > 0) {
|
2022-01-14 10:20:26 +01:00
|
|
|
if (graalvmVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
2022-01-03 09:00:36 +01:00
|
|
|
core.warning(
|
|
|
|
`Mandrel does not support GraalVM components: ${componentsString}`
|
|
|
|
)
|
2022-01-03 08:57:03 +01:00
|
|
|
} else {
|
2022-03-03 17:24:24 +01:00
|
|
|
await setUpGUComponents(gdsToken, graalVMHome, components)
|
2022-01-03 08:57:03 +01:00
|
|
|
}
|
|
|
|
}
|
2022-01-03 08:43:40 +01:00
|
|
|
} catch (error) {
|
|
|
|
if (error instanceof Error) core.setFailed(error.message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
run()
|