mirror of
https://gitea.com/actions/setup-java.git
synced 2025-11-07 02:36:26 +08:00
Compare commits
12 Commits
2dfa2011c5
...
update-gra
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e579f12ce6 | ||
|
|
6c05717f11 | ||
|
|
8df1039502 | ||
|
|
870c199c48 | ||
|
|
83a06ff9d9 | ||
|
|
292cc14be8 | ||
|
|
b36c23c0d9 | ||
|
|
40b9536ce5 | ||
|
|
0a40ce6f61 | ||
|
|
68b1d5a3da | ||
|
|
bcfbca5b71 | ||
|
|
78eae7945c |
22
.github/workflows/e2e-versions.yml
vendored
22
.github/workflows/e2e-versions.yml
vendored
@@ -45,11 +45,22 @@ jobs:
|
|||||||
version: 17
|
version: 17
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
version: 20
|
version: 21
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
version: 20
|
version: 21
|
||||||
|
- distribution: graalvm
|
||||||
|
os: macos-latest
|
||||||
|
version: 17.0.12
|
||||||
|
- distribution: graalvm
|
||||||
|
os: windows-latest
|
||||||
|
version: 21
|
||||||
|
- distribution: graalvm
|
||||||
|
os: ubuntu-latest
|
||||||
|
version: 21
|
||||||
|
- distribution: graalvm
|
||||||
|
os: ubuntu-latest
|
||||||
|
version: '24-ea'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -79,7 +90,10 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
version: '20.0.1'
|
version: '21.0.4'
|
||||||
|
- distribution: graalvm
|
||||||
|
os: ubuntu-latest
|
||||||
|
version: '21.0.4'
|
||||||
- distribution: dragonwell
|
- distribution: dragonwell
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
version: '11.0'
|
version: '11.0'
|
||||||
|
|||||||
20
.github/workflows/publish-immutable-actions.yml
vendored
Normal file
20
.github/workflows/publish-immutable-actions.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: 'Publish Immutable Action Version'
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checking out
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Publish
|
||||||
|
id: publish
|
||||||
|
uses: actions/publish-immutable-action@0.0.3
|
||||||
@@ -23,7 +23,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Update the ${{ env.TAG_NAME }} tag
|
- name: Update the ${{ env.TAG_NAME }} tag
|
||||||
id: update-major-tag
|
id: update-major-tag
|
||||||
uses: actions/publish-action@v0.2.2
|
uses: actions/publish-action@v0.3.0
|
||||||
with:
|
with:
|
||||||
source-tag: ${{ env.TAG_NAME }}
|
source-tag: ${{ env.TAG_NAME }}
|
||||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ Currently, the following distributions are supported:
|
|||||||
| `oracle` | Oracle JDK | [Link](https://www.oracle.com/java/technologies/downloads/) | [Link](https://java.com/freeuselicense)
|
| `oracle` | Oracle JDK | [Link](https://www.oracle.com/java/technologies/downloads/) | [Link](https://java.com/freeuselicense)
|
||||||
| `dragonwell` | Alibaba Dragonwell JDK | [Link](https://dragonwell-jdk.io/) | [Link](https://www.aliyun.com/product/dragonwell/)
|
| `dragonwell` | Alibaba Dragonwell JDK | [Link](https://dragonwell-jdk.io/) | [Link](https://www.aliyun.com/product/dragonwell/)
|
||||||
| `sapmachine` | SAP SapMachine JDK/JRE | [Link](https://sapmachine.io/) | [Link](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE)
|
| `sapmachine` | SAP SapMachine JDK/JRE | [Link](https://sapmachine.io/) | [Link](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE)
|
||||||
|
| `graalvm` | Oracle GraalVM | [Link](https://www.graalvm.org/) | [Link](https://www.oracle.com/downloads/licenses/graal-free-license.html)
|
||||||
|
|
||||||
**NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions.
|
**NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions.
|
||||||
|
|
||||||
@@ -116,6 +117,8 @@ Currently, the following distributions are supported:
|
|||||||
|
|
||||||
**NOTE:** For Azul Zulu OpenJDK architectures x64 and arm64 are mapped to x86 / arm with proper hw_bitness.
|
**NOTE:** For Azul Zulu OpenJDK architectures x64 and arm64 are mapped to x86 / arm with proper hw_bitness.
|
||||||
|
|
||||||
|
**NOTE:** To comply with the GraalVM Free Terms and Conditions (GFTC) license, it is recommended to use GraalVM JDK 17 version 17.0.12, as this is the only version of GraalVM JDK 17 available under the GFTC license. Additionally, it is encouraged to consider upgrading to GraalVM JDK 21, which offers the latest features and improvements.
|
||||||
|
|
||||||
### Caching packages dependencies
|
### Caching packages dependencies
|
||||||
The action has a built-in functionality for caching and restoring dependencies. It uses [toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle, maven and sbt. The format of the used cache key is `setup-java-${{ platform }}-${{ packageManager }}-${{ fileHash }}`, where the hash is based on the following files:
|
The action has a built-in functionality for caching and restoring dependencies. It uses [toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle, maven and sbt. The format of the used cache key is `setup-java-${{ platform }}-${{ packageManager }}-${{ fileHash }}`, where the hash is based on the following files:
|
||||||
|
|
||||||
@@ -259,6 +262,7 @@ In the example above multiple JDKs are installed for the same job. The result af
|
|||||||
- [Oracle](docs/advanced-usage.md#Oracle)
|
- [Oracle](docs/advanced-usage.md#Oracle)
|
||||||
- [Alibaba Dragonwell](docs/advanced-usage.md#Alibaba-Dragonwell)
|
- [Alibaba Dragonwell](docs/advanced-usage.md#Alibaba-Dragonwell)
|
||||||
- [SapMachine](docs/advanced-usage.md#SapMachine)
|
- [SapMachine](docs/advanced-usage.md#SapMachine)
|
||||||
|
- [GraalVM](docs/advanced-usage.md#GraalVM)
|
||||||
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
|
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
|
||||||
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
|
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
|
||||||
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)
|
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)
|
||||||
|
|||||||
152
__tests__/distributors/graalvm-installer.test.ts
Normal file
152
__tests__/distributors/graalvm-installer.test.ts
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
import {GraalVMDistribution} from '../../src/distributions/graalvm/installer';
|
||||||
|
import os from 'os';
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import {getDownloadArchiveExtension} from '../../src/util';
|
||||||
|
import {HttpClient} from '@actions/http-client';
|
||||||
|
|
||||||
|
describe('findPackageForDownload', () => {
|
||||||
|
let distribution: GraalVMDistribution;
|
||||||
|
let spyDebug: jest.SpyInstance;
|
||||||
|
let spyHttpClient: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
distribution = new GraalVMDistribution({
|
||||||
|
version: '',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
|
||||||
|
spyDebug = jest.spyOn(core, 'debug');
|
||||||
|
spyDebug.mockImplementation(() => {});
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
'21',
|
||||||
|
'21',
|
||||||
|
'https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'21.0.4',
|
||||||
|
'21.0.4',
|
||||||
|
'https://download.oracle.com/graalvm/21/archive/graalvm-jdk-21.0.4_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'17',
|
||||||
|
'17',
|
||||||
|
'https://download.oracle.com/graalvm/17/latest/graalvm-jdk-17_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'17.0.12',
|
||||||
|
'17.0.12',
|
||||||
|
'https://download.oracle.com/graalvm/17/archive/graalvm-jdk-17.0.12_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
|
||||||
|
]
|
||||||
|
])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => {
|
||||||
|
/* Needed only for this particular test because /latest/ urls tend to change */
|
||||||
|
spyHttpClient = jest.spyOn(HttpClient.prototype, 'head');
|
||||||
|
spyHttpClient.mockReturnValue(
|
||||||
|
Promise.resolve({
|
||||||
|
message: {
|
||||||
|
statusCode: 200
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
const result = await distribution['findPackageForDownload'](input);
|
||||||
|
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
|
||||||
|
expect(result.version).toBe(expectedVersion);
|
||||||
|
const osType = distribution.getPlatform();
|
||||||
|
const archiveType = getDownloadArchiveExtension();
|
||||||
|
const url = expectedUrl
|
||||||
|
.replace('{{OS_TYPE}}', osType)
|
||||||
|
.replace('{{ARCHIVE_TYPE}}', archiveType);
|
||||||
|
expect(result.url).toBe(url);
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
'24-ea',
|
||||||
|
/^https:\/\/github\.com\/graalvm\/oracle-graalvm-ea-builds\/releases\/download\/jdk-24\.0\.0-ea\./
|
||||||
|
]
|
||||||
|
])('version is %s -> %s', async (version, expectedUrlPrefix) => {
|
||||||
|
/* Needed only for this particular test because /latest/ urls tend to change */
|
||||||
|
spyHttpClient = jest.spyOn(HttpClient.prototype, 'head');
|
||||||
|
spyHttpClient.mockReturnValue(
|
||||||
|
Promise.resolve({
|
||||||
|
message: {
|
||||||
|
statusCode: 200
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
const eaDistro = new GraalVMDistribution({
|
||||||
|
version,
|
||||||
|
architecture: '', // to get default value
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const versionWithoutEA = version.split('-')[0];
|
||||||
|
const result = await eaDistro['findPackageForDownload'](versionWithoutEA);
|
||||||
|
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
|
||||||
|
expect(result.url).toEqual(expect.stringMatching(expectedUrlPrefix));
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
['amd64', 'x64'],
|
||||||
|
['arm64', 'aarch64']
|
||||||
|
])(
|
||||||
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
|
async (osArch: string, distroArch: string) => {
|
||||||
|
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
||||||
|
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
||||||
|
|
||||||
|
const version = '21';
|
||||||
|
const distro = new GraalVMDistribution({
|
||||||
|
version,
|
||||||
|
architecture: '', // to get default value
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const osType = distribution.getPlatform();
|
||||||
|
if (osType === 'windows' && distroArch == 'aarch64') {
|
||||||
|
return; // skip, aarch64 is not available for Windows
|
||||||
|
}
|
||||||
|
const archiveType = getDownloadArchiveExtension();
|
||||||
|
const result = await distro['findPackageForDownload'](version);
|
||||||
|
const expectedUrl = `https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_${osType}-${distroArch}_bin.${archiveType}`;
|
||||||
|
|
||||||
|
expect(result.url).toBe(expectedUrl);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it('should throw an error', async () => {
|
||||||
|
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
|
||||||
|
/GraalVM is only supported for JDK 17 and later/
|
||||||
|
);
|
||||||
|
await expect(distribution['findPackageForDownload']('11')).rejects.toThrow(
|
||||||
|
/GraalVM is only supported for JDK 17 and later/
|
||||||
|
);
|
||||||
|
await expect(distribution['findPackageForDownload']('18')).rejects.toThrow(
|
||||||
|
/Could not find GraalVM for SemVer */
|
||||||
|
);
|
||||||
|
|
||||||
|
const unavailableEADistro = new GraalVMDistribution({
|
||||||
|
version: '17-ea',
|
||||||
|
architecture: '', // to get default value
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
await expect(
|
||||||
|
unavailableEADistro['findPackageForDownload']('17')
|
||||||
|
).rejects.toThrow(
|
||||||
|
/No GraalVM EA build found\. Are you sure java-version: '17-ea' is correct\?/
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -3,7 +3,8 @@ import * as core from '@actions/core';
|
|||||||
import {
|
import {
|
||||||
convertVersionToSemver,
|
convertVersionToSemver,
|
||||||
isVersionSatisfies,
|
isVersionSatisfies,
|
||||||
isCacheFeatureAvailable
|
isCacheFeatureAvailable,
|
||||||
|
isGhes
|
||||||
} from '../src/util';
|
} from '../src/util';
|
||||||
|
|
||||||
jest.mock('@actions/cache');
|
jest.mock('@actions/cache');
|
||||||
@@ -80,3 +81,41 @@ describe('convertVersionToSemver', () => {
|
|||||||
expect(actual).toBe(expected);
|
expect(actual).toBe(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('isGhes', () => {
|
||||||
|
const pristineEnv = process.env;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
process.env = {...pristineEnv};
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
process.env = pristineEnv;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable is not defined', async () => {
|
||||||
|
delete process.env['GITHUB_SERVER_URL'];
|
||||||
|
expect(isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable is set to github.com', async () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://github.com';
|
||||||
|
expect(isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL', async () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://contoso.ghe.com';
|
||||||
|
expect(isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix', async () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://mock-github.localhost';
|
||||||
|
expect(isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns true when the GITHUB_SERVER_URL environment variable is set to some other URL', async () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://src.onpremise.fabrikam.com';
|
||||||
|
expect(isGhes()).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
21
dist/cleanup/index.js
vendored
21
dist/cleanup/index.js
vendored
@@ -88116,7 +88116,7 @@ function computeCacheKey(packageManager, cacheDependencyPath) {
|
|||||||
if (!fileHash) {
|
if (!fileHash) {
|
||||||
throw new Error(`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`);
|
throw new Error(`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`);
|
||||||
}
|
}
|
||||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${fileHash}`;
|
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${packageManager.id}-${fileHash}`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -88470,7 +88470,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.getGitHubHttpHeaders = exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
|
exports.renameWinArchive = exports.getGitHubHttpHeaders = exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
|
||||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
const fs = __importStar(__nccwpck_require__(7147));
|
const fs = __importStar(__nccwpck_require__(7147));
|
||||||
@@ -88552,7 +88552,11 @@ function isJobStatusSuccess() {
|
|||||||
exports.isJobStatusSuccess = isJobStatusSuccess;
|
exports.isJobStatusSuccess = isJobStatusSuccess;
|
||||||
function isGhes() {
|
function isGhes() {
|
||||||
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
||||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
||||||
|
const isGitHubHost = hostname === 'GITHUB.COM';
|
||||||
|
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
|
||||||
|
const isLocalHost = hostname.endsWith('.LOCALHOST');
|
||||||
|
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
||||||
}
|
}
|
||||||
exports.isGhes = isGhes;
|
exports.isGhes = isGhes;
|
||||||
function isCacheFeatureAvailable() {
|
function isCacheFeatureAvailable() {
|
||||||
@@ -88630,6 +88634,17 @@ function getGitHubHttpHeaders() {
|
|||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
|
exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
|
||||||
|
// Rename archive to add extension because after downloading
|
||||||
|
// archive does not contain extension type and it leads to some issues
|
||||||
|
// on Windows runners without PowerShell Core.
|
||||||
|
//
|
||||||
|
// For default PowerShell Windows it should contain extension type to unpack it.
|
||||||
|
function renameWinArchive(javaArchivePath) {
|
||||||
|
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
|
||||||
|
fs.renameSync(javaArchivePath, javaArchivePathRenamed);
|
||||||
|
return javaArchivePathRenamed;
|
||||||
|
}
|
||||||
|
exports.renameWinArchive = renameWinArchive;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|||||||
266
dist/setup/index.js
vendored
266
dist/setup/index.js
vendored
@@ -123365,7 +123365,7 @@ function computeCacheKey(packageManager, cacheDependencyPath) {
|
|||||||
if (!fileHash) {
|
if (!fileHash) {
|
||||||
throw new Error(`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`);
|
throw new Error(`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`);
|
||||||
}
|
}
|
||||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${fileHash}`;
|
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${packageManager.id}-${fileHash}`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -123578,9 +123578,12 @@ class AdoptDistribution extends base_installer_1.JavaBase {
|
|||||||
downloadTool(javaRelease) {
|
downloadTool(javaRelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||||
const javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
|
||||||
|
}
|
||||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
||||||
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
||||||
@@ -123914,9 +123917,13 @@ class CorrettoDistribution extends base_installer_1.JavaBase {
|
|||||||
downloadTool(javaRelease) {
|
downloadTool(javaRelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||||
const javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, (0, util_1.getDownloadArchiveExtension)());
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
|
||||||
|
}
|
||||||
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
||||||
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
||||||
const version = this.getToolcacheVersionName(javaRelease.version);
|
const version = this.getToolcacheVersionName(javaRelease.version);
|
||||||
@@ -124050,6 +124057,7 @@ const installer_8 = __nccwpck_require__(34750);
|
|||||||
const installer_9 = __nccwpck_require__(64298);
|
const installer_9 = __nccwpck_require__(64298);
|
||||||
const installer_10 = __nccwpck_require__(16132);
|
const installer_10 = __nccwpck_require__(16132);
|
||||||
const installer_11 = __nccwpck_require__(52869);
|
const installer_11 = __nccwpck_require__(52869);
|
||||||
|
const installer_12 = __nccwpck_require__(55644);
|
||||||
var JavaDistribution;
|
var JavaDistribution;
|
||||||
(function (JavaDistribution) {
|
(function (JavaDistribution) {
|
||||||
JavaDistribution["Adopt"] = "adopt";
|
JavaDistribution["Adopt"] = "adopt";
|
||||||
@@ -124065,6 +124073,7 @@ var JavaDistribution;
|
|||||||
JavaDistribution["Oracle"] = "oracle";
|
JavaDistribution["Oracle"] = "oracle";
|
||||||
JavaDistribution["Dragonwell"] = "dragonwell";
|
JavaDistribution["Dragonwell"] = "dragonwell";
|
||||||
JavaDistribution["SapMachine"] = "sapmachine";
|
JavaDistribution["SapMachine"] = "sapmachine";
|
||||||
|
JavaDistribution["GraalVM"] = "graalvm";
|
||||||
})(JavaDistribution || (JavaDistribution = {}));
|
})(JavaDistribution || (JavaDistribution = {}));
|
||||||
function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||||
switch (distributionName) {
|
switch (distributionName) {
|
||||||
@@ -124093,6 +124102,8 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
|||||||
return new installer_10.DragonwellDistribution(installerOptions);
|
return new installer_10.DragonwellDistribution(installerOptions);
|
||||||
case JavaDistribution.SapMachine:
|
case JavaDistribution.SapMachine:
|
||||||
return new installer_11.SapMachineDistribution(installerOptions);
|
return new installer_11.SapMachineDistribution(installerOptions);
|
||||||
|
case JavaDistribution.GraalVM:
|
||||||
|
return new installer_12.GraalVMDistribution(installerOptions);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -124205,9 +124216,13 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
|
|||||||
downloadTool(javaRelease) {
|
downloadTool(javaRelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||||
const javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, (0, util_1.getDownloadArchiveExtension)());
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
|
||||||
|
}
|
||||||
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
||||||
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
||||||
const version = this.getToolcacheVersionName(javaRelease.version);
|
const version = this.getToolcacheVersionName(javaRelease.version);
|
||||||
@@ -124310,6 +124325,175 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
|
|||||||
exports.DragonwellDistribution = DragonwellDistribution;
|
exports.DragonwellDistribution = DragonwellDistribution;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 55644:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.GraalVMDistribution = void 0;
|
||||||
|
const core = __importStar(__nccwpck_require__(42186));
|
||||||
|
const tc = __importStar(__nccwpck_require__(27784));
|
||||||
|
const fs_1 = __importDefault(__nccwpck_require__(57147));
|
||||||
|
const path_1 = __importDefault(__nccwpck_require__(71017));
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
downloadTool(javaRelease) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||||
|
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||||
|
core.info(`Extracting Java archive...`);
|
||||||
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
|
||||||
|
}
|
||||||
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
||||||
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
|
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
||||||
|
const version = this.getToolcacheVersionName(javaRelease.version);
|
||||||
|
const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, version, this.architecture);
|
||||||
|
return { version: javaRelease.version, path: javaPath };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
findPackageForDownload(range) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const arch = this.distributionArchitecture();
|
||||||
|
if (arch !== 'x64' && arch !== 'aarch64') {
|
||||||
|
throw new Error(`Unsupported architecture: ${this.architecture}`);
|
||||||
|
}
|
||||||
|
if (!this.stable) {
|
||||||
|
return this.findEABuildDownloadUrl(`${range}-ea`);
|
||||||
|
}
|
||||||
|
if (this.packageType !== 'jdk') {
|
||||||
|
throw new Error('GraalVM provides only the `jdk` package type');
|
||||||
|
}
|
||||||
|
const platform = this.getPlatform();
|
||||||
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
|
let major;
|
||||||
|
let fileUrl;
|
||||||
|
if (range.includes('.')) {
|
||||||
|
major = range.split('.')[0];
|
||||||
|
fileUrl = `${GRAALVM_DL_BASE}/${major}/archive/graalvm-jdk-${range}_${platform}-${arch}_bin.${extension}`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
major = range;
|
||||||
|
fileUrl = `${GRAALVM_DL_BASE}/${range}/latest/graalvm-jdk-${range}_${platform}-${arch}_bin.${extension}`;
|
||||||
|
}
|
||||||
|
if (parseInt(major) < 17) {
|
||||||
|
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 for SemVer ${range}`);
|
||||||
|
}
|
||||||
|
if (response.message.statusCode !== http_client_1.HttpCodes.OK) {
|
||||||
|
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':
|
||||||
|
return 'macos';
|
||||||
|
case 'win32':
|
||||||
|
return 'windows';
|
||||||
|
case 'linux':
|
||||||
|
return 'linux';
|
||||||
|
default:
|
||||||
|
throw new Error(`Platform '${platform}' is not supported. Supported platforms: 'linux', 'macos', 'windows'`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.GraalVMDistribution = GraalVMDistribution;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 40883:
|
/***/ 40883:
|
||||||
@@ -124373,11 +124557,8 @@ class LibericaDistributions extends base_installer_1.JavaBase {
|
|||||||
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
if (process.platform === 'win32' &&
|
if (process.platform === 'win32') {
|
||||||
(this.architecture === 'arm64' || this.architecture === 'aarch64')) {
|
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
|
||||||
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
|
|
||||||
yield fs_1.default.renameSync(javaArchivePath, javaArchivePathRenamed);
|
|
||||||
javaArchivePath = javaArchivePathRenamed;
|
|
||||||
}
|
}
|
||||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
||||||
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
@@ -124659,19 +124840,11 @@ class MicrosoftDistributions extends base_installer_1.JavaBase {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||||
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||||
// Rename archive to add extension because after downloading
|
|
||||||
// archive does not contain extension type and it leads to some issues
|
|
||||||
// on Windows runners without PowerShell Core.
|
|
||||||
//
|
|
||||||
// For default PowerShell Windows it should contain extension type to unpack it.
|
|
||||||
if (process.platform === 'win32' &&
|
|
||||||
(this.architecture === 'arm64' || this.architecture === 'aarch64')) {
|
|
||||||
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
|
|
||||||
yield fs_1.default.renameSync(javaArchivePath, javaArchivePathRenamed);
|
|
||||||
javaArchivePath = javaArchivePathRenamed;
|
|
||||||
}
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
|
||||||
|
}
|
||||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
||||||
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
||||||
@@ -124808,9 +124981,12 @@ class OracleDistribution extends base_installer_1.JavaBase {
|
|||||||
downloadTool(javaRelease) {
|
downloadTool(javaRelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||||
const javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
|
||||||
|
}
|
||||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
||||||
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
||||||
@@ -124981,9 +125157,13 @@ class SapMachineDistribution extends base_installer_1.JavaBase {
|
|||||||
downloadTool(javaRelease) {
|
downloadTool(javaRelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||||
const javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, (0, util_1.getDownloadArchiveExtension)());
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
|
||||||
|
}
|
||||||
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
||||||
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
||||||
const version = this.getToolcacheVersionName(javaRelease.version);
|
const version = this.getToolcacheVersionName(javaRelease.version);
|
||||||
@@ -125200,9 +125380,12 @@ class SemeruDistribution extends base_installer_1.JavaBase {
|
|||||||
downloadTool(javaRelease) {
|
downloadTool(javaRelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||||
const javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
|
||||||
|
}
|
||||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
||||||
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
||||||
@@ -125376,9 +125559,12 @@ class TemurinDistribution extends base_installer_1.JavaBase {
|
|||||||
downloadTool(javaRelease) {
|
downloadTool(javaRelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||||
const javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
|
||||||
|
}
|
||||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
||||||
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
||||||
@@ -125554,11 +125740,8 @@ class ZuluDistribution extends base_installer_1.JavaBase {
|
|||||||
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
if (process.platform === 'win32' &&
|
if (process.platform === 'win32') {
|
||||||
(this.architecture === 'arm64' || this.architecture === 'aarch64')) {
|
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
|
||||||
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
|
|
||||||
yield fs_1.default.renameSync(javaArchivePath, javaArchivePathRenamed);
|
|
||||||
javaArchivePath = javaArchivePathRenamed;
|
|
||||||
}
|
}
|
||||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
||||||
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
@@ -126063,7 +126246,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.getGitHubHttpHeaders = exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
|
exports.renameWinArchive = exports.getGitHubHttpHeaders = exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
|
||||||
const os_1 = __importDefault(__nccwpck_require__(22037));
|
const os_1 = __importDefault(__nccwpck_require__(22037));
|
||||||
const path_1 = __importDefault(__nccwpck_require__(71017));
|
const path_1 = __importDefault(__nccwpck_require__(71017));
|
||||||
const fs = __importStar(__nccwpck_require__(57147));
|
const fs = __importStar(__nccwpck_require__(57147));
|
||||||
@@ -126145,7 +126328,11 @@ function isJobStatusSuccess() {
|
|||||||
exports.isJobStatusSuccess = isJobStatusSuccess;
|
exports.isJobStatusSuccess = isJobStatusSuccess;
|
||||||
function isGhes() {
|
function isGhes() {
|
||||||
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
||||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
||||||
|
const isGitHubHost = hostname === 'GITHUB.COM';
|
||||||
|
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
|
||||||
|
const isLocalHost = hostname.endsWith('.LOCALHOST');
|
||||||
|
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
||||||
}
|
}
|
||||||
exports.isGhes = isGhes;
|
exports.isGhes = isGhes;
|
||||||
function isCacheFeatureAvailable() {
|
function isCacheFeatureAvailable() {
|
||||||
@@ -126223,6 +126410,17 @@ function getGitHubHttpHeaders() {
|
|||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
|
exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
|
||||||
|
// Rename archive to add extension because after downloading
|
||||||
|
// archive does not contain extension type and it leads to some issues
|
||||||
|
// on Windows runners without PowerShell Core.
|
||||||
|
//
|
||||||
|
// For default PowerShell Windows it should contain extension type to unpack it.
|
||||||
|
function renameWinArchive(javaArchivePath) {
|
||||||
|
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
|
||||||
|
fs.renameSync(javaArchivePath, javaArchivePathRenamed);
|
||||||
|
return javaArchivePathRenamed;
|
||||||
|
}
|
||||||
|
exports.renameWinArchive = renameWinArchive;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
- [Oracle](#Oracle)
|
- [Oracle](#Oracle)
|
||||||
- [Alibaba Dragonwell](#Alibaba-Dragonwell)
|
- [Alibaba Dragonwell](#Alibaba-Dragonwell)
|
||||||
- [SapMachine](#SapMachine)
|
- [SapMachine](#SapMachine)
|
||||||
|
- [GraalVM](#GraalVM)
|
||||||
- [Installing custom Java package type](#Installing-custom-Java-package-type)
|
- [Installing custom Java package type](#Installing-custom-Java-package-type)
|
||||||
- [Installing custom Java architecture](#Installing-custom-Java-architecture)
|
- [Installing custom Java architecture](#Installing-custom-Java-architecture)
|
||||||
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
|
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
|
||||||
@@ -155,6 +156,21 @@ steps:
|
|||||||
- run: java -cp java HelloWorldApp
|
- run: java -cp java HelloWorldApp
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### GraalVM
|
||||||
|
**NOTE:** Oracle GraalVM is only available for JDK 17 and later.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'graalvm'
|
||||||
|
java-version: '21'
|
||||||
|
- run: |
|
||||||
|
java -cp java HelloWorldApp
|
||||||
|
native-image -cp java HelloWorldApp
|
||||||
|
```
|
||||||
|
|
||||||
## Installing custom Java package type
|
## Installing custom Java package type
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -4322,12 +4322,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/micromatch": {
|
"node_modules/micromatch": {
|
||||||
"version": "4.0.5",
|
"version": "4.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
|
||||||
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
|
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"braces": "^3.0.2",
|
"braces": "^3.0.3",
|
||||||
"picomatch": "^2.3.1"
|
"picomatch": "^2.3.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ async function computeCacheKey(
|
|||||||
`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`
|
`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${fileHash}`;
|
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${packageManager.id}-${fileHash}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ import {
|
|||||||
import {
|
import {
|
||||||
extractJdkFile,
|
extractJdkFile,
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
isVersionSatisfies
|
isVersionSatisfies,
|
||||||
|
renameWinArchive
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
|
|
||||||
export enum AdoptImplementation {
|
export enum AdoptImplementation {
|
||||||
@@ -73,11 +74,13 @@ export class AdoptDistribution extends JavaBase {
|
|||||||
core.info(
|
core.info(
|
||||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||||
);
|
);
|
||||||
const javaArchivePath = await tc.downloadTool(javaRelease.url);
|
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||||
|
}
|
||||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||||
|
|
||||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import path from 'path';
|
|||||||
import {
|
import {
|
||||||
extractJdkFile,
|
extractJdkFile,
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
convertVersionToSemver
|
convertVersionToSemver,
|
||||||
|
renameWinArchive
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
import {JavaBase} from '../base-installer';
|
import {JavaBase} from '../base-installer';
|
||||||
import {
|
import {
|
||||||
@@ -29,14 +30,14 @@ export class CorrettoDistribution extends JavaBase {
|
|||||||
core.info(
|
core.info(
|
||||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||||
);
|
);
|
||||||
const javaArchivePath = await tc.downloadTool(javaRelease.url);
|
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
|
const extension = getDownloadArchiveExtension();
|
||||||
const extractedJavaPath = await extractJdkFile(
|
if (process.platform === 'win32') {
|
||||||
javaArchivePath,
|
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||||
getDownloadArchiveExtension()
|
}
|
||||||
);
|
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||||
|
|
||||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path.join(extractedJavaPath, archiveName);
|
const archivePath = path.join(extractedJavaPath, archiveName);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {CorrettoDistribution} from './corretto/installer';
|
|||||||
import {OracleDistribution} from './oracle/installer';
|
import {OracleDistribution} from './oracle/installer';
|
||||||
import {DragonwellDistribution} from './dragonwell/installer';
|
import {DragonwellDistribution} from './dragonwell/installer';
|
||||||
import {SapMachineDistribution} from './sapmachine/installer';
|
import {SapMachineDistribution} from './sapmachine/installer';
|
||||||
|
import {GraalVMDistribution} from './graalvm/installer';
|
||||||
|
|
||||||
enum JavaDistribution {
|
enum JavaDistribution {
|
||||||
Adopt = 'adopt',
|
Adopt = 'adopt',
|
||||||
@@ -25,7 +26,8 @@ enum JavaDistribution {
|
|||||||
Corretto = 'corretto',
|
Corretto = 'corretto',
|
||||||
Oracle = 'oracle',
|
Oracle = 'oracle',
|
||||||
Dragonwell = 'dragonwell',
|
Dragonwell = 'dragonwell',
|
||||||
SapMachine = 'sapmachine'
|
SapMachine = 'sapmachine',
|
||||||
|
GraalVM = 'graalvm'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getJavaDistribution(
|
export function getJavaDistribution(
|
||||||
@@ -68,6 +70,8 @@ export function getJavaDistribution(
|
|||||||
return new DragonwellDistribution(installerOptions);
|
return new DragonwellDistribution(installerOptions);
|
||||||
case JavaDistribution.SapMachine:
|
case JavaDistribution.SapMachine:
|
||||||
return new SapMachineDistribution(installerOptions);
|
return new SapMachineDistribution(installerOptions);
|
||||||
|
case JavaDistribution.GraalVM:
|
||||||
|
return new GraalVMDistribution(installerOptions);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ import {
|
|||||||
extractJdkFile,
|
extractJdkFile,
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
getGitHubHttpHeaders,
|
getGitHubHttpHeaders,
|
||||||
isVersionSatisfies
|
isVersionSatisfies,
|
||||||
|
renameWinArchive
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
import {IDragonwellVersions, IDragonwellAllVersions} from './models';
|
import {IDragonwellVersions, IDragonwellAllVersions} from './models';
|
||||||
import {
|
import {
|
||||||
@@ -100,14 +101,14 @@ export class DragonwellDistribution extends JavaBase {
|
|||||||
core.info(
|
core.info(
|
||||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||||
);
|
);
|
||||||
const javaArchivePath = await tc.downloadTool(javaRelease.url);
|
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
|
const extension = getDownloadArchiveExtension();
|
||||||
const extractedJavaPath = await extractJdkFile(
|
if (process.platform === 'win32') {
|
||||||
javaArchivePath,
|
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||||
getDownloadArchiveExtension()
|
}
|
||||||
);
|
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||||
|
|
||||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path.join(extractedJavaPath, archiveName);
|
const archivePath = path.join(extractedJavaPath, archiveName);
|
||||||
|
|||||||
176
src/distributions/graalvm/installer.ts
Normal file
176
src/distributions/graalvm/installer.ts
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as tc from '@actions/tool-cache';
|
||||||
|
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
import {JavaBase} from '../base-installer';
|
||||||
|
import {
|
||||||
|
JavaDownloadRelease,
|
||||||
|
JavaInstallerOptions,
|
||||||
|
JavaInstallerResults
|
||||||
|
} from '../base-models';
|
||||||
|
import {
|
||||||
|
extractJdkFile,
|
||||||
|
getDownloadArchiveExtension,
|
||||||
|
getGitHubHttpHeaders,
|
||||||
|
renameWinArchive
|
||||||
|
} from '../../util';
|
||||||
|
import {HttpCodes} from '@actions/http-client';
|
||||||
|
import {GraalVMEAVersion} from './models';
|
||||||
|
|
||||||
|
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
||||||
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
|
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
||||||
|
|
||||||
|
export class GraalVMDistribution extends JavaBase {
|
||||||
|
constructor(installerOptions: JavaInstallerOptions) {
|
||||||
|
super('GraalVM', installerOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async downloadTool(
|
||||||
|
javaRelease: JavaDownloadRelease
|
||||||
|
): Promise<JavaInstallerResults> {
|
||||||
|
core.info(
|
||||||
|
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||||
|
);
|
||||||
|
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||||
|
|
||||||
|
core.info(`Extracting Java archive...`);
|
||||||
|
const extension = getDownloadArchiveExtension();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||||
|
}
|
||||||
|
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||||
|
|
||||||
|
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||||
|
const archivePath = path.join(extractedJavaPath, archiveName);
|
||||||
|
const version = this.getToolcacheVersionName(javaRelease.version);
|
||||||
|
|
||||||
|
const javaPath = await tc.cacheDir(
|
||||||
|
archivePath,
|
||||||
|
this.toolcacheFolderName,
|
||||||
|
version,
|
||||||
|
this.architecture
|
||||||
|
);
|
||||||
|
|
||||||
|
return {version: javaRelease.version, path: javaPath};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async findPackageForDownload(
|
||||||
|
range: string
|
||||||
|
): Promise<JavaDownloadRelease> {
|
||||||
|
const arch = this.distributionArchitecture();
|
||||||
|
if (arch !== 'x64' && arch !== 'aarch64') {
|
||||||
|
throw new Error(`Unsupported architecture: ${this.architecture}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.stable) {
|
||||||
|
return this.findEABuildDownloadUrl(`${range}-ea`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.packageType !== 'jdk') {
|
||||||
|
throw new Error('GraalVM provides only the `jdk` package type');
|
||||||
|
}
|
||||||
|
|
||||||
|
const platform = this.getPlatform();
|
||||||
|
const extension = getDownloadArchiveExtension();
|
||||||
|
let major;
|
||||||
|
let fileUrl;
|
||||||
|
if (range.includes('.')) {
|
||||||
|
major = range.split('.')[0];
|
||||||
|
fileUrl = `${GRAALVM_DL_BASE}/${major}/archive/graalvm-jdk-${range}_${platform}-${arch}_bin.${extension}`;
|
||||||
|
} else {
|
||||||
|
major = range;
|
||||||
|
fileUrl = `${GRAALVM_DL_BASE}/${range}/latest/graalvm-jdk-${range}_${platform}-${arch}_bin.${extension}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parseInt(major) < 17) {
|
||||||
|
throw new Error('GraalVM is only supported for JDK 17 and later');
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.http.head(fileUrl);
|
||||||
|
|
||||||
|
if (response.message.statusCode === HttpCodes.NotFound) {
|
||||||
|
throw new Error(`Could not find GraalVM for SemVer ${range}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.message.statusCode !== HttpCodes.OK) {
|
||||||
|
throw new Error(
|
||||||
|
`Http request for GraalVM failed with status code: ${response.message.statusCode}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {url: fileUrl, version: range};
|
||||||
|
}
|
||||||
|
|
||||||
|
private async findEABuildDownloadUrl(
|
||||||
|
javaEaVersion: string
|
||||||
|
): Promise<JavaDownloadRelease> {
|
||||||
|
const versions = await 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
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private async fetchEAJson(
|
||||||
|
javaEaVersion: string
|
||||||
|
): Promise<GraalVMEAVersion[]> {
|
||||||
|
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 = getGitHubHttpHeaders();
|
||||||
|
|
||||||
|
core.debug(
|
||||||
|
`Trying to fetch available version info for GraalVM EA builds from '${url}'`
|
||||||
|
);
|
||||||
|
let fetchedJson;
|
||||||
|
try {
|
||||||
|
fetchedJson = (await this.http.getJson<GraalVMEAVersion[]>(url, headers))
|
||||||
|
.result;
|
||||||
|
} catch (err) {
|
||||||
|
throw Error(
|
||||||
|
`Fetching version info for GraalVM EA builds from '${url}' failed with the error: ${
|
||||||
|
(err as Error).message
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (fetchedJson === null) {
|
||||||
|
throw Error(
|
||||||
|
`No GraalVM EA build found. Are you sure java-version: '${javaEaVersion}' is correct?`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return fetchedJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getPlatform(platform: NodeJS.Platform = process.platform): OsVersions {
|
||||||
|
switch (platform) {
|
||||||
|
case 'darwin':
|
||||||
|
return 'macos';
|
||||||
|
case 'win32':
|
||||||
|
return 'windows';
|
||||||
|
case 'linux':
|
||||||
|
return 'linux';
|
||||||
|
default:
|
||||||
|
throw new Error(
|
||||||
|
`Platform '${platform}' is not supported. Supported platforms: 'linux', 'macos', 'windows'`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/distributions/graalvm/models.ts
Normal file
14
src/distributions/graalvm/models.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
export type OsVersions = 'linux' | 'macos' | 'windows';
|
||||||
|
|
||||||
|
export interface GraalVMEAFile {
|
||||||
|
filename: string;
|
||||||
|
arch: 'aarch64' | 'x64';
|
||||||
|
platform: 'darwin' | 'linux' | 'windows';
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GraalVMEAVersion {
|
||||||
|
version: string;
|
||||||
|
latest?: boolean;
|
||||||
|
download_base_url: string;
|
||||||
|
files: GraalVMEAFile[];
|
||||||
|
}
|
||||||
@@ -8,7 +8,8 @@ import semver from 'semver';
|
|||||||
import {
|
import {
|
||||||
extractJdkFile,
|
extractJdkFile,
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
isVersionSatisfies
|
isVersionSatisfies,
|
||||||
|
renameWinArchive
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {ArchitectureOptions, LibericaVersion, OsVersions} from './models';
|
import {ArchitectureOptions, LibericaVersion, OsVersions} from './models';
|
||||||
@@ -35,13 +36,8 @@ export class LibericaDistributions extends JavaBase {
|
|||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
if (
|
if (process.platform === 'win32') {
|
||||||
process.platform === 'win32' &&
|
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||||
(this.architecture === 'arm64' || this.architecture === 'aarch64')
|
|
||||||
) {
|
|
||||||
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
|
|
||||||
await fs.renameSync(javaArchivePath, javaArchivePathRenamed);
|
|
||||||
javaArchivePath = javaArchivePathRenamed;
|
|
||||||
}
|
}
|
||||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import {
|
|||||||
import {
|
import {
|
||||||
extractJdkFile,
|
extractJdkFile,
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
getGitHubHttpHeaders
|
getGitHubHttpHeaders,
|
||||||
|
renameWinArchive
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
@@ -27,22 +28,12 @@ export class MicrosoftDistributions extends JavaBase {
|
|||||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||||
);
|
);
|
||||||
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||||
// Rename archive to add extension because after downloading
|
|
||||||
// archive does not contain extension type and it leads to some issues
|
|
||||||
// on Windows runners without PowerShell Core.
|
|
||||||
//
|
|
||||||
// For default PowerShell Windows it should contain extension type to unpack it.
|
|
||||||
if (
|
|
||||||
process.platform === 'win32' &&
|
|
||||||
(this.architecture === 'arm64' || this.architecture === 'aarch64')
|
|
||||||
) {
|
|
||||||
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
|
|
||||||
await fs.renameSync(javaArchivePath, javaArchivePathRenamed);
|
|
||||||
javaArchivePath = javaArchivePathRenamed;
|
|
||||||
}
|
|
||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||||
|
}
|
||||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||||
|
|
||||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ import {
|
|||||||
JavaInstallerOptions,
|
JavaInstallerOptions,
|
||||||
JavaInstallerResults
|
JavaInstallerResults
|
||||||
} from '../base-models';
|
} from '../base-models';
|
||||||
import {extractJdkFile, getDownloadArchiveExtension} from '../../util';
|
import {
|
||||||
|
extractJdkFile,
|
||||||
|
getDownloadArchiveExtension,
|
||||||
|
renameWinArchive
|
||||||
|
} from '../../util';
|
||||||
import {HttpCodes} from '@actions/http-client';
|
import {HttpCodes} from '@actions/http-client';
|
||||||
|
|
||||||
const ORACLE_DL_BASE = 'https://download.oracle.com/java';
|
const ORACLE_DL_BASE = 'https://download.oracle.com/java';
|
||||||
@@ -26,11 +30,13 @@ export class OracleDistribution extends JavaBase {
|
|||||||
core.info(
|
core.info(
|
||||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||||
);
|
);
|
||||||
const javaArchivePath = await tc.downloadTool(javaRelease.url);
|
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||||
|
}
|
||||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||||
|
|
||||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ import {
|
|||||||
extractJdkFile,
|
extractJdkFile,
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
getGitHubHttpHeaders,
|
getGitHubHttpHeaders,
|
||||||
isVersionSatisfies
|
isVersionSatisfies,
|
||||||
|
renameWinArchive
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
import {JavaBase} from '../base-installer';
|
import {JavaBase} from '../base-installer';
|
||||||
import {
|
import {
|
||||||
@@ -104,14 +105,14 @@ export class SapMachineDistribution extends JavaBase {
|
|||||||
core.info(
|
core.info(
|
||||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||||
);
|
);
|
||||||
const javaArchivePath = await tc.downloadTool(javaRelease.url);
|
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
|
const extension = getDownloadArchiveExtension();
|
||||||
const extractedJavaPath = await extractJdkFile(
|
if (process.platform === 'win32') {
|
||||||
javaArchivePath,
|
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||||
getDownloadArchiveExtension()
|
}
|
||||||
);
|
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||||
|
|
||||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path.join(extractedJavaPath, archiveName);
|
const archivePath = path.join(extractedJavaPath, archiveName);
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import semver from 'semver';
|
|||||||
import {
|
import {
|
||||||
extractJdkFile,
|
extractJdkFile,
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
isVersionSatisfies
|
isVersionSatisfies,
|
||||||
|
renameWinArchive
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
@@ -98,11 +99,13 @@ export class SemeruDistribution extends JavaBase {
|
|||||||
core.info(
|
core.info(
|
||||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||||
);
|
);
|
||||||
const javaArchivePath = await tc.downloadTool(javaRelease.url);
|
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||||
|
}
|
||||||
const extractedJavaPath: string = await extractJdkFile(
|
const extractedJavaPath: string = await extractJdkFile(
|
||||||
javaArchivePath,
|
javaArchivePath,
|
||||||
extension
|
extension
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ import {
|
|||||||
import {
|
import {
|
||||||
extractJdkFile,
|
extractJdkFile,
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
isVersionSatisfies
|
isVersionSatisfies,
|
||||||
|
renameWinArchive
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
|
|
||||||
export enum TemurinImplementation {
|
export enum TemurinImplementation {
|
||||||
@@ -76,11 +77,13 @@ export class TemurinDistribution extends JavaBase {
|
|||||||
core.info(
|
core.info(
|
||||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||||
);
|
);
|
||||||
const javaArchivePath = await tc.downloadTool(javaRelease.url);
|
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||||
|
}
|
||||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||||
|
|
||||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ import {
|
|||||||
extractJdkFile,
|
extractJdkFile,
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
convertVersionToSemver,
|
convertVersionToSemver,
|
||||||
isVersionSatisfies
|
isVersionSatisfies,
|
||||||
|
renameWinArchive
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
import {
|
import {
|
||||||
JavaDownloadRelease,
|
JavaDownloadRelease,
|
||||||
@@ -80,13 +81,8 @@ export class ZuluDistribution extends JavaBase {
|
|||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
if (
|
if (process.platform === 'win32') {
|
||||||
process.platform === 'win32' &&
|
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||||
(this.architecture === 'arm64' || this.architecture === 'aarch64')
|
|
||||||
) {
|
|
||||||
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
|
|
||||||
await fs.renameSync(javaArchivePath, javaArchivePathRenamed);
|
|
||||||
javaArchivePath = javaArchivePathRenamed;
|
|
||||||
}
|
}
|
||||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||||
|
|
||||||
|
|||||||
19
src/util.ts
19
src/util.ts
@@ -92,7 +92,13 @@ export function isGhes(): boolean {
|
|||||||
const ghUrl = new URL(
|
const ghUrl = new URL(
|
||||||
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||||
);
|
);
|
||||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
|
||||||
|
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
||||||
|
const isGitHubHost = hostname === 'GITHUB.COM';
|
||||||
|
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
|
||||||
|
const isLocalHost = hostname.endsWith('.LOCALHOST');
|
||||||
|
|
||||||
|
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCacheFeatureAvailable(): boolean {
|
export function isCacheFeatureAvailable(): boolean {
|
||||||
@@ -190,3 +196,14 @@ export function getGitHubHttpHeaders(): OutgoingHttpHeaders {
|
|||||||
}
|
}
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rename archive to add extension because after downloading
|
||||||
|
// archive does not contain extension type and it leads to some issues
|
||||||
|
// on Windows runners without PowerShell Core.
|
||||||
|
//
|
||||||
|
// For default PowerShell Windows it should contain extension type to unpack it.
|
||||||
|
export function renameWinArchive(javaArchivePath: string): string {
|
||||||
|
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
|
||||||
|
fs.renameSync(javaArchivePath, javaArchivePathRenamed);
|
||||||
|
return javaArchivePathRenamed;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user