mirror of
https://github.com/graalvm/setup-graalvm.git
synced 2025-12-06 07:48:06 +08:00
Compare commits
5 Commits
cfa19cdd20
...
dec5790292
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dec5790292 | ||
|
|
181df6a97e | ||
|
|
00d42bd278 | ||
|
|
339a71db2d | ||
|
|
ad3c25e809 |
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@@ -54,6 +54,9 @@ jobs:
|
||||
]
|
||||
set-gds-token: [false]
|
||||
components: ['']
|
||||
exclude:
|
||||
- os: macos-13
|
||||
java-version: 'dev'
|
||||
include:
|
||||
- java-version: 'latest-ea'
|
||||
distribution: 'graalvm'
|
||||
|
||||
@@ -76,7 +76,7 @@ test('find version/javaVersion', async () => {
|
||||
}
|
||||
error = err
|
||||
}
|
||||
expect(error.message).toContain('Could not find highest Java version.')
|
||||
expect(error.message).toContain('Could not find latest GraalVM release:')
|
||||
})
|
||||
|
||||
test('find EA version/javaVersion', async () => {
|
||||
|
||||
2
dist/cleanup.js
generated
vendored
2
dist/cleanup.js
generated
vendored
@@ -27288,7 +27288,7 @@ function requireCore () {
|
||||
|
||||
var coreExports = requireCore();
|
||||
|
||||
const ACTION_VERSION = '1.4.2';
|
||||
const ACTION_VERSION = '1.4.3';
|
||||
const INPUT_GITHUB_TOKEN = 'github-token';
|
||||
const INPUT_CACHE = 'cache';
|
||||
process.platform === 'linux';
|
||||
|
||||
36
dist/main.js
generated
vendored
36
dist/main.js
generated
vendored
@@ -3,7 +3,7 @@ import require$$0$4, { createHash, randomUUID as randomUUID$2, createHmac } from
|
||||
import * as fs from 'fs';
|
||||
import fs__default, { readdirSync, readFileSync, existsSync } from 'fs';
|
||||
import * as require$$1$1 from 'path';
|
||||
import require$$1__default, { join, basename as basename$1 } from 'path';
|
||||
import require$$1__default, { join, extname, basename as basename$1 } from 'path';
|
||||
import require$$0$5 from 'http';
|
||||
import require$$1$2 from 'https';
|
||||
import require$$0$7 from 'net';
|
||||
@@ -39,7 +39,7 @@ import * as https from 'node:https';
|
||||
import * as zlib from 'node:zlib';
|
||||
import require$$1$6 from 'tty';
|
||||
|
||||
const ACTION_VERSION = '1.4.2';
|
||||
const ACTION_VERSION = '1.4.3';
|
||||
const INPUT_VERSION = 'version';
|
||||
const INPUT_GDS_TOKEN = 'gds-token';
|
||||
const INPUT_JAVA_VERSION = 'java-version';
|
||||
@@ -38705,6 +38705,20 @@ async function downloadExtractAndCacheJDK(downloader, toolName, version) {
|
||||
}
|
||||
return findJavaHomeInSubfolder(toolPath);
|
||||
}
|
||||
/**
|
||||
* This copy of tc.downloadTool() preserves the file extension in the dest.
|
||||
* The file extension is required on Windows runners without .NET to extract zip files correctly.
|
||||
* See #195 and https://github.com/actions/toolkit/blob/6b63a2bfc339a753a113d2266323a4d52d84dee0/packages/tool-cache/src/tool-cache.ts#L44
|
||||
*/
|
||||
async function downloadFile(downloadUrl) {
|
||||
const dest = join(_getTempDirectory(), crypto.randomUUID(), extname(downloadUrl));
|
||||
return toolCacheExports.downloadTool(downloadUrl, dest);
|
||||
}
|
||||
function _getTempDirectory() {
|
||||
const tempDirectory = process.env['RUNNER_TEMP'] || '';
|
||||
ok(tempDirectory, 'Expected RUNNER_TEMP to be defined');
|
||||
return tempDirectory;
|
||||
}
|
||||
function calculateSHA256(filePath) {
|
||||
const hashSum = createHash('sha256');
|
||||
hashSum.update(readFileSync(filePath));
|
||||
@@ -40549,7 +40563,7 @@ function determineToolName$2(javaVersion, isCommunity) {
|
||||
}
|
||||
async function downloadGraalVMJDK(downloadUrl, javaVersion) {
|
||||
try {
|
||||
return await toolCacheExports.downloadTool(downloadUrl);
|
||||
return await downloadFile(downloadUrl);
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof Error && error.message.includes('404')) {
|
||||
@@ -40583,7 +40597,7 @@ function findHighestJavaVersion(release, version) {
|
||||
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.');
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
// Support for GraalVM 22.X releases and earlier
|
||||
@@ -40616,7 +40630,9 @@ async function setUpGraalVMRelease(gdsToken, version, javaVersion) {
|
||||
return downloadExtractAndCacheJDK(downloader, toolName, version);
|
||||
}
|
||||
function findDownloadUrl(release, javaVersion) {
|
||||
const graalVMIdentifier = determineGraalVMLegacyIdentifier(false, VERSION_DEV, javaVersion);
|
||||
const graalVMIdentifier = javaVersion
|
||||
? determineGraalVMLegacyIdentifier(false, VERSION_DEV, javaVersion)
|
||||
: determineGraalVMIdentifier(false, VERSION_DEV);
|
||||
const expectedFileName = `${graalVMIdentifier}${GRAALVM_FILE_EXTENSION}`;
|
||||
for (const asset of release.assets) {
|
||||
if (asset.name === expectedFileName) {
|
||||
@@ -40625,6 +40641,10 @@ function findDownloadUrl(release, javaVersion) {
|
||||
}
|
||||
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. ${ERROR_HINT}`);
|
||||
}
|
||||
function determineGraalVMIdentifier(isEE, version) {
|
||||
const infix = 'community' ;
|
||||
return `graalvm-${infix}-${version}-${GRAALVM_PLATFORM}-${GRAALVM_ARCH}`;
|
||||
}
|
||||
function determineGraalVMLegacyIdentifier(isEE, version, javaVersion) {
|
||||
return `${determineLegacyToolName(isEE, version, javaVersion)}-${GRAALVM_ARCH}-${version}`;
|
||||
}
|
||||
@@ -40636,7 +40656,7 @@ async function downloadGraalVMCELegacy(version, javaVersion) {
|
||||
const graalVMIdentifier = determineGraalVMLegacyIdentifier(false, version, javaVersion);
|
||||
const downloadUrl = `${GRAALVM_CE_DL_BASE}/${GRAALVM_TAG_PREFIX}${version}/${graalVMIdentifier}${GRAALVM_FILE_EXTENSION}`;
|
||||
try {
|
||||
return await toolCacheExports.downloadTool(downloadUrl);
|
||||
return await downloadFile(downloadUrl);
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof Error && error.message.includes('404')) {
|
||||
@@ -93574,7 +93594,7 @@ async function setUpLiberica(javaVersion, javaPackage) {
|
||||
const resolvedJavaVersion = await findLatestLibericaJavaVersion(javaVersion);
|
||||
const downloadUrl = await findLibericaURL(resolvedJavaVersion, javaPackage);
|
||||
const toolName = determineToolName(javaVersion, javaPackage);
|
||||
return downloadExtractAndCacheJDK(async () => toolCacheExports.downloadTool(downloadUrl), toolName, javaVersion);
|
||||
return downloadExtractAndCacheJDK(async () => downloadFile(downloadUrl), toolName, javaVersion);
|
||||
}
|
||||
async function findLatestLibericaJavaVersion(javaVersion) {
|
||||
const matchingRefs = await getMatchingTags(LIBERICA_GH_USER, LIBERICA_RELEASES_REPO, `${LIBERICA_JDK_TAG_PREFIX}${javaVersion}`);
|
||||
@@ -93667,7 +93687,7 @@ async function setUpNativeImageMusl() {
|
||||
}
|
||||
else {
|
||||
coreExports.startGroup(`Setting up musl for GraalVM Native Image...`);
|
||||
const muslDownloadPath = await toolCacheExports.downloadTool(`https://gds.oracle.com/download/bfs/archive/musl-toolchain-${MUSL_VERSION}-linux-amd64.tar.gz`);
|
||||
const muslDownloadPath = await downloadFile(`https://gds.oracle.com/download/bfs/archive/musl-toolchain-${MUSL_VERSION}-linux-amd64.tar.gz`);
|
||||
const muslExtractPath = await toolCacheExports.extractTar(muslDownloadPath);
|
||||
const muslPath = join(muslExtractPath, MUSL_NAME);
|
||||
coreExports.info(`Adding ${MUSL_NAME} ${MUSL_VERSION} to tool-cache ...`);
|
||||
|
||||
37
package-lock.json
generated
37
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "setup-graalvm",
|
||||
"version": "1.4.2",
|
||||
"version": "1.4.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "setup-graalvm",
|
||||
"version": "1.4.2",
|
||||
"version": "1.4.3",
|
||||
"license": "UPL",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^4.1.0",
|
||||
@@ -42,7 +42,7 @@
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-prettier": "^5.5.4",
|
||||
"jest": "^30.2.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"js-yaml": "^4.1.1",
|
||||
"prettier": "^3.6.2",
|
||||
"prettier-eslint": "^16.4.2",
|
||||
"rollup": "^4.52.5",
|
||||
@@ -603,6 +603,7 @@
|
||||
"integrity": "sha512-UlLAnTPrFdNGoFtbSXwcGFQBtQZJCNjaN6hQNP3UPvuNXT1i82N26KL3dZeIpNalWywr9IuQuncaAfUaS1g6sQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@ampproject/remapping": "^2.2.0",
|
||||
"@babel/code-frame": "^7.27.1",
|
||||
@@ -1603,9 +1604,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": {
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
|
||||
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
|
||||
"version": "3.14.2",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz",
|
||||
"integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -2238,6 +2239,7 @@
|
||||
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.0.tgz",
|
||||
"integrity": "sha512-1LFfa/qnMQvEOAdzlQymH0ulepxbxnCYAKJZfMci/5XJyIHWgEYnDmgnKakbTh7CH2tFQ5O60oYDvns4i9RAIg==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@octokit/auth-token": "^4.0.0",
|
||||
"@octokit/graphql": "^7.1.0",
|
||||
@@ -2553,6 +2555,7 @@
|
||||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
@@ -3216,6 +3219,7 @@
|
||||
"integrity": "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"undici-types": "~7.16.0"
|
||||
}
|
||||
@@ -3304,6 +3308,7 @@
|
||||
"integrity": "sha512-BnOroVl1SgrPLywqxyqdJ4l3S2MsKVLDVxZvjI1Eoe8ev2r3kGDo+PcMihNmDE+6/KjkTubSJnmqGZZjQSBq/g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "8.46.2",
|
||||
"@typescript-eslint/types": "8.46.2",
|
||||
@@ -3803,6 +3808,7 @@
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
|
||||
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
@@ -4247,6 +4253,7 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"caniuse-lite": "^1.0.30001726",
|
||||
"electron-to-chromium": "^1.5.173",
|
||||
@@ -4995,6 +5002,7 @@
|
||||
"integrity": "sha512-iy2GE3MHrYTL5lrCtMZ0X1KLEKKUjmK0kzwcnefhR66txcEmXZD2YWgR5GNdcEwkNx3a0siYkSvl0vIC+Svjmg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.8.0",
|
||||
"@eslint-community/regexpp": "^4.12.1",
|
||||
@@ -5071,6 +5079,7 @@
|
||||
"integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"eslint-config-prettier": "bin/cli.js"
|
||||
},
|
||||
@@ -5234,6 +5243,7 @@
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.32.0.tgz",
|
||||
"integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@rtsao/scc": "^1.1.0",
|
||||
"array-includes": "^3.1.9",
|
||||
@@ -6990,6 +7000,7 @@
|
||||
"integrity": "sha512-F26gjC0yWN8uAA5m5Ss8ZQf5nDHWGlN/xWZIh8S5SRbsEKBovwZhxGd6LJlbZYxBgCYOtreSUyb8hpXyGC5O4A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@jest/core": "30.2.0",
|
||||
"@jest/types": "30.2.0",
|
||||
@@ -8121,9 +8132,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/js-yaml": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
|
||||
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -8193,6 +8204,7 @@
|
||||
"integrity": "sha512-WYDyuc/uFcGp6YtM2H0uKmUwieOuzeE/5YocFJLnLfclZ4inf3mRn8ZVy1s7Hxji7Jxm6Ss8gqpexD/GlKoGgg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"acorn": "^8.5.0",
|
||||
"eslint-visitor-keys": "^3.0.0",
|
||||
@@ -9086,6 +9098,7 @@
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz",
|
||||
"integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
@@ -9323,6 +9336,7 @@
|
||||
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.2.0",
|
||||
"@eslint-community/regexpp": "^4.6.1",
|
||||
@@ -9755,6 +9769,7 @@
|
||||
"integrity": "sha512-3GuObel8h7Kqdjt0gxkEzaifHTqLVW56Y/bjN7PSQtkKr0w3V/QYSdt6QWYtd7A1xUtYQigtdUfgj1RvWVtorw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@types/estree": "1.0.8"
|
||||
},
|
||||
@@ -10424,6 +10439,7 @@
|
||||
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
@@ -10724,6 +10740,7 @@
|
||||
"integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@cspotcode/source-map-support": "^0.8.0",
|
||||
"@tsconfig/node10": "^1.0.7",
|
||||
@@ -10933,6 +10950,7 @@
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
@@ -11005,6 +11023,7 @@
|
||||
"integrity": "sha512-VUyWiTNQD7itdiMuJy+EuLEErLj3uwX/EpHQF8EOf33Dq3Ju6VW1GXm+swk6+1h7a49uv9fKZ+dft9jU7esdLA==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"napi-postinstall": "^0.2.4"
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "setup-graalvm",
|
||||
"author": "GraalVM Community",
|
||||
"description": "GitHub Action for GraalVM",
|
||||
"version": "1.4.2",
|
||||
"version": "1.4.3",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"repository": {
|
||||
@@ -70,7 +70,7 @@
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-prettier": "^5.5.4",
|
||||
"jest": "^30.2.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"js-yaml": "^4.1.1",
|
||||
"prettier": "^3.6.2",
|
||||
"prettier-eslint": "^16.4.2",
|
||||
"rollup": "^4.52.5",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as otypes from '@octokit/types'
|
||||
|
||||
export const ACTION_VERSION = '1.4.2'
|
||||
export const ACTION_VERSION = '1.4.3'
|
||||
|
||||
export const INPUT_VERSION = 'version'
|
||||
export const INPUT_GDS_TOKEN = 'gds-token'
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as c from '../constants.js'
|
||||
import * as core from '@actions/core'
|
||||
import * as tc from '@actions/tool-cache'
|
||||
import { join } from 'path'
|
||||
import { downloadFile } from '../utils.js'
|
||||
|
||||
const MUSL_NAME = 'musl-toolchain'
|
||||
const MUSL_VERSION = '1.2.5-oracle-00001'
|
||||
@@ -16,7 +17,7 @@ export async function setUpNativeImageMusl(): Promise<void> {
|
||||
core.info(`Found ${MUSL_NAME} ${MUSL_VERSION} in tool-cache @ ${toolPath}`)
|
||||
} else {
|
||||
core.startGroup(`Setting up musl for GraalVM Native Image...`)
|
||||
const muslDownloadPath = await tc.downloadTool(
|
||||
const muslDownloadPath = await downloadFile(
|
||||
`https://gds.oracle.com/download/bfs/archive/musl-toolchain-${MUSL_VERSION}-linux-amd64.tar.gz`
|
||||
)
|
||||
const muslExtractPath = await tc.extractTar(muslDownloadPath)
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as c from './constants.js'
|
||||
import * as core from '@actions/core'
|
||||
import * as semver from 'semver'
|
||||
import {
|
||||
downloadFile,
|
||||
downloadAndExtractJDK,
|
||||
downloadExtractAndCacheJDK,
|
||||
getContents,
|
||||
@@ -10,7 +11,6 @@ import {
|
||||
getTaggedRelease
|
||||
} from './utils.js'
|
||||
import { downloadGraalVM, downloadGraalVMEELegacy } from './gds.js'
|
||||
import { downloadTool } from '@actions/tool-cache'
|
||||
import { basename } from 'path'
|
||||
|
||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm'
|
||||
@@ -153,7 +153,7 @@ function determineToolName(javaVersion: string, isCommunity: boolean) {
|
||||
|
||||
async function downloadGraalVMJDK(downloadUrl: string, javaVersion: string): Promise<string> {
|
||||
try {
|
||||
return await downloadTool(downloadUrl)
|
||||
return await downloadFile(downloadUrl)
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message.includes('404')) {
|
||||
// Not Found
|
||||
@@ -174,7 +174,7 @@ export async function setUpGraalVMJDKDevBuild(): Promise<string> {
|
||||
return downloadAndExtractJDK(downloadUrl)
|
||||
}
|
||||
|
||||
export function findHighestJavaVersion(release: c.LatestReleaseResponseData, version: string): string {
|
||||
export function findHighestJavaVersion(release: c.LatestReleaseResponseData, version: string): string | undefined {
|
||||
const graalVMIdentifierPattern = determineGraalVMLegacyIdentifier(false, version, '(\\d+)')
|
||||
const expectedFileNameRegExp = new RegExp(
|
||||
`^${graalVMIdentifierPattern}${c.GRAALVM_FILE_EXTENSION.replace(/\./g, '\\.')}$`
|
||||
@@ -192,9 +192,7 @@ export function findHighestJavaVersion(release: c.LatestReleaseResponseData, ver
|
||||
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.'
|
||||
)
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,8 +232,10 @@ export async function setUpGraalVMRelease(gdsToken: string, version: string, jav
|
||||
return downloadExtractAndCacheJDK(downloader, toolName, version)
|
||||
}
|
||||
|
||||
function findDownloadUrl(release: c.LatestReleaseResponseData, javaVersion: string): string {
|
||||
const graalVMIdentifier = determineGraalVMLegacyIdentifier(false, c.VERSION_DEV, javaVersion)
|
||||
function findDownloadUrl(release: c.LatestReleaseResponseData, javaVersion?: string): string {
|
||||
const graalVMIdentifier = javaVersion
|
||||
? determineGraalVMLegacyIdentifier(false, c.VERSION_DEV, javaVersion)
|
||||
: determineGraalVMIdentifier(false, c.VERSION_DEV)
|
||||
const expectedFileName = `${graalVMIdentifier}${c.GRAALVM_FILE_EXTENSION}`
|
||||
for (const asset of release.assets) {
|
||||
if (asset.name === expectedFileName) {
|
||||
@@ -247,6 +247,11 @@ function findDownloadUrl(release: c.LatestReleaseResponseData, javaVersion: stri
|
||||
)
|
||||
}
|
||||
|
||||
function determineGraalVMIdentifier(isEE: boolean, version: string): string {
|
||||
const infix = isEE ? 'ee' : version === c.VERSION_DEV ? 'community' : 'ce'
|
||||
return `graalvm-${infix}-${version}-${c.GRAALVM_PLATFORM}-${c.GRAALVM_ARCH}`
|
||||
}
|
||||
|
||||
function determineGraalVMLegacyIdentifier(isEE: boolean, version: string, javaVersion: string): string {
|
||||
return `${determineLegacyToolName(isEE, version, javaVersion)}-${c.GRAALVM_ARCH}-${version}`
|
||||
}
|
||||
@@ -260,7 +265,7 @@ async function downloadGraalVMCELegacy(version: string, javaVersion: string): Pr
|
||||
const graalVMIdentifier = determineGraalVMLegacyIdentifier(false, version, javaVersion)
|
||||
const downloadUrl = `${GRAALVM_CE_DL_BASE}/${GRAALVM_TAG_PREFIX}${version}/${graalVMIdentifier}${c.GRAALVM_FILE_EXTENSION}`
|
||||
try {
|
||||
return await downloadTool(downloadUrl)
|
||||
return await downloadFile(downloadUrl)
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message.includes('404')) {
|
||||
// Not Found
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as c from './constants.js'
|
||||
import * as semver from 'semver'
|
||||
import { downloadExtractAndCacheJDK, getTaggedRelease, getMatchingTags } from './utils.js'
|
||||
import { downloadTool } from '@actions/tool-cache'
|
||||
import { downloadFile, downloadExtractAndCacheJDK, getTaggedRelease, getMatchingTags } from './utils.js'
|
||||
import { spawnSync } from 'child_process'
|
||||
|
||||
const LIBERICA_GH_USER = 'bell-sw'
|
||||
@@ -13,7 +12,7 @@ export async function setUpLiberica(javaVersion: string, javaPackage: string): P
|
||||
const resolvedJavaVersion = await findLatestLibericaJavaVersion(javaVersion)
|
||||
const downloadUrl = await findLibericaURL(resolvedJavaVersion, javaPackage)
|
||||
const toolName = determineToolName(javaVersion, javaPackage)
|
||||
return downloadExtractAndCacheJDK(async () => downloadTool(downloadUrl), toolName, javaVersion)
|
||||
return downloadExtractAndCacheJDK(async () => downloadFile(downloadUrl), toolName, javaVersion)
|
||||
}
|
||||
|
||||
export async function findLatestLibericaJavaVersion(javaVersion: string): Promise<string> {
|
||||
|
||||
19
src/utils.ts
19
src/utils.ts
@@ -5,9 +5,10 @@ import * as semver from 'semver'
|
||||
import * as tc from '@actions/tool-cache'
|
||||
import * as fs from 'fs'
|
||||
import { ExecOptions, exec as e } from '@actions/exec'
|
||||
import { ok } from 'assert'
|
||||
import { readFileSync, readdirSync } from 'fs'
|
||||
import { createHash } from 'crypto'
|
||||
import { join } from 'path'
|
||||
import { extname, join } from 'path'
|
||||
import { tmpdir } from 'os'
|
||||
import { GitHub } from '@actions/github/lib/utils.js'
|
||||
|
||||
@@ -86,6 +87,22 @@ export async function downloadExtractAndCacheJDK(
|
||||
return findJavaHomeInSubfolder(toolPath)
|
||||
}
|
||||
|
||||
/**
|
||||
* This copy of tc.downloadTool() preserves the file extension in the dest.
|
||||
* The file extension is required on Windows runners without .NET to extract zip files correctly.
|
||||
* See #195 and https://github.com/actions/toolkit/blob/6b63a2bfc339a753a113d2266323a4d52d84dee0/packages/tool-cache/src/tool-cache.ts#L44
|
||||
*/
|
||||
export async function downloadFile(downloadUrl: string): Promise<string> {
|
||||
const dest = join(_getTempDirectory(), crypto.randomUUID(), extname(downloadUrl))
|
||||
return tc.downloadTool(downloadUrl, dest)
|
||||
}
|
||||
|
||||
function _getTempDirectory(): string {
|
||||
const tempDirectory = process.env['RUNNER_TEMP'] || ''
|
||||
ok(tempDirectory, 'Expected RUNNER_TEMP to be defined')
|
||||
return tempDirectory
|
||||
}
|
||||
|
||||
export function calculateSHA256(filePath: string): string {
|
||||
const hashSum = createHash('sha256')
|
||||
hashSum.update(readFileSync(filePath))
|
||||
|
||||
Reference in New Issue
Block a user