mirror of
https://github.com/actions/setup-java.git
synced 2025-06-29 04:24:14 +00:00
Add support for EA builds of Oracle GraalVM
This commit is contained in:
parent
bbbb45e1c5
commit
f0a7c591b0
5 changed files with 180 additions and 16 deletions
53
dist/setup/index.js
vendored
53
dist/setup/index.js
vendored
|
@ -124366,6 +124366,8 @@ const base_installer_1 = __nccwpck_require__(59741);
|
|||
const util_1 = __nccwpck_require__(92629);
|
||||
const http_client_1 = __nccwpck_require__(96255);
|
||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
||||
class GraalVMDistribution extends base_installer_1.JavaBase {
|
||||
constructor(installerOptions) {
|
||||
super('GraalVM', installerOptions);
|
||||
|
@ -124391,10 +124393,10 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
|
|||
throw new Error(`Unsupported architecture: ${this.architecture}`);
|
||||
}
|
||||
if (!this.stable) {
|
||||
throw new Error('Early access versions are not supported');
|
||||
return this.findEABuildDownloadUrl(`${range}-ea`);
|
||||
}
|
||||
if (this.packageType !== 'jdk') {
|
||||
throw new Error('GraalVM JDK provides only the `jdk` package type');
|
||||
throw new Error('GraalVM provides only the `jdk` package type');
|
||||
}
|
||||
const platform = this.getPlatform();
|
||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||
|
@ -124409,18 +124411,59 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
|
|||
fileUrl = `${GRAALVM_DL_BASE}/${range}/latest/graalvm-jdk-${range}_${platform}-${arch}_bin.${extension}`;
|
||||
}
|
||||
if (parseInt(major) < 17) {
|
||||
throw new Error('GraalVM JDK is only supported for JDK 17 and later');
|
||||
throw new Error('GraalVM is only supported for JDK 17 and later');
|
||||
}
|
||||
const response = yield this.http.head(fileUrl);
|
||||
if (response.message.statusCode === http_client_1.HttpCodes.NotFound) {
|
||||
throw new Error(`Could not find GraalVM JDK for SemVer ${range}`);
|
||||
throw new Error(`Could not find GraalVM for SemVer ${range}`);
|
||||
}
|
||||
if (response.message.statusCode !== http_client_1.HttpCodes.OK) {
|
||||
throw new Error(`Http request for GraalVM JDK failed with status code: ${response.message.statusCode}`);
|
||||
throw new Error(`Http request for GraalVM failed with status code: ${response.message.statusCode}`);
|
||||
}
|
||||
return { url: fileUrl, version: range };
|
||||
});
|
||||
}
|
||||
findEABuildDownloadUrl(javaEaVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const versions = yield this.fetchEAJson(javaEaVersion);
|
||||
const latestVersion = versions.find(v => v.latest);
|
||||
if (!latestVersion) {
|
||||
throw new Error(`Unable to find latest version for '${javaEaVersion}'`);
|
||||
}
|
||||
const arch = this.distributionArchitecture();
|
||||
const file = latestVersion.files.find(f => f.arch === arch && f.platform === GRAALVM_PLATFORM);
|
||||
if (!file || !file.filename.startsWith('graalvm-jdk-')) {
|
||||
throw new Error(`Unable to find file metadata for '${javaEaVersion}'`);
|
||||
}
|
||||
return {
|
||||
url: `${latestVersion.download_base_url}${file.filename}`,
|
||||
version: latestVersion.version
|
||||
};
|
||||
});
|
||||
}
|
||||
fetchEAJson(javaEaVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const owner = 'graalvm';
|
||||
const repository = 'oracle-graalvm-ea-builds';
|
||||
const branch = 'main';
|
||||
const filePath = `versions/${javaEaVersion}.json`;
|
||||
const url = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||
const headers = (0, util_1.getGitHubHttpHeaders)();
|
||||
core.debug(`Trying to fetch available version info for GraalVM EA builds from '${url}'`);
|
||||
let fetchedJson;
|
||||
try {
|
||||
fetchedJson = (yield this.http.getJson(url, headers))
|
||||
.result;
|
||||
}
|
||||
catch (err) {
|
||||
throw Error(`Fetching version info for GraalVM EA builds from '${url}' failed with the error: ${err.message}`);
|
||||
}
|
||||
if (fetchedJson === null) {
|
||||
throw Error(`No GraalVM EA build found. Are you sure java-version: '${javaEaVersion}' is correct?`);
|
||||
}
|
||||
return fetchedJson;
|
||||
});
|
||||
}
|
||||
getPlatform(platform = process.platform) {
|
||||
switch (platform) {
|
||||
case 'darwin':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue