mirror of
https://github.com/actions/setup-java.git
synced 2025-11-26 17:09:09 +08:00
Compare commits
1 Commits
dependabot
...
222160f41c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
222160f41c |
18
.github/workflows/e2e-cache.yml
vendored
18
.github/workflows/e2e-cache.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
@@ -46,7 +46,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
needs: gradle-save
|
needs: gradle-save
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -70,7 +70,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
@@ -93,7 +93,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
needs: maven-save
|
needs: maven-save
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -121,7 +121,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
os: [macos-13, windows-latest, ubuntu-22.04]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
@@ -133,7 +133,7 @@ jobs:
|
|||||||
java-version: '11'
|
java-version: '11'
|
||||||
cache: sbt
|
cache: sbt
|
||||||
- name: Setup SBT
|
- name: Setup SBT
|
||||||
if: matrix.os == 'macos-15-intel'
|
if: matrix.os == 'macos-13'
|
||||||
run: |
|
run: |
|
||||||
echo ""Installing SBT...""
|
echo ""Installing SBT...""
|
||||||
brew install sbt
|
brew install sbt
|
||||||
@@ -141,7 +141,7 @@ jobs:
|
|||||||
run: sbt update
|
run: sbt update
|
||||||
|
|
||||||
- name: Check files to cache on macos-latest
|
- name: Check files to cache on macos-latest
|
||||||
if: matrix.os == 'macos-15-intel'
|
if: matrix.os == 'macos-13'
|
||||||
run: |
|
run: |
|
||||||
if [ ! -d ~/Library/Caches/Coursier ]; then
|
if [ ! -d ~/Library/Caches/Coursier ]; then
|
||||||
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
|
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
|
||||||
@@ -170,7 +170,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
os: [macos-13, windows-latest, ubuntu-22.04]
|
||||||
needs: sbt-save
|
needs: sbt-save
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -184,7 +184,7 @@ jobs:
|
|||||||
cache: sbt
|
cache: sbt
|
||||||
|
|
||||||
- name: Confirm that ~/Library/Caches/Coursier directory has been made
|
- name: Confirm that ~/Library/Caches/Coursier directory has been made
|
||||||
if: matrix.os == 'macos-15-intel'
|
if: matrix.os == 'macos-13'
|
||||||
run: |
|
run: |
|
||||||
if [ ! -d ~/Library/Caches/Coursier ]; then
|
if [ ! -d ~/Library/Caches/Coursier ]; then
|
||||||
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
|
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
|
||||||
|
|||||||
19
.github/workflows/e2e-versions.yml
vendored
19
.github/workflows/e2e-versions.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
distribution: [
|
distribution: [
|
||||||
'temurin',
|
'temurin',
|
||||||
'adopt',
|
'adopt',
|
||||||
@@ -39,19 +39,10 @@ jobs:
|
|||||||
- distribution: microsoft
|
- distribution: microsoft
|
||||||
version: 8
|
version: 8
|
||||||
- distribution: dragonwell
|
- distribution: dragonwell
|
||||||
os: macos-15-intel
|
os: macos-13
|
||||||
include:
|
include:
|
||||||
- distribution: microsoft
|
|
||||||
os: windows-latest
|
|
||||||
version: 25
|
|
||||||
- distribution: microsoft
|
|
||||||
os: ubuntu-latest
|
|
||||||
version: 25
|
|
||||||
- distribution: microsoft
|
|
||||||
os: macos-latest
|
|
||||||
version: 25
|
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: macos-15-intel
|
os: macos-13
|
||||||
version: 17
|
version: 17
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
@@ -229,7 +220,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
version: ['17-ea', '15.0.0-ea.14']
|
version: ['17-ea', '15.0.0-ea.14']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -295,7 +286,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
distribution:
|
distribution:
|
||||||
['temurin', 'zulu', 'liberica', 'semeru', 'sapmachine', 'jetbrains']
|
['temurin', 'zulu', 'liberica', 'semeru', 'sapmachine', 'jetbrains']
|
||||||
java-package: ['jre']
|
java-package: ['jre']
|
||||||
|
|||||||
@@ -1,47 +1,4 @@
|
|||||||
[
|
[
|
||||||
{
|
|
||||||
"version": "25.0.0",
|
|
||||||
"stable": true,
|
|
||||||
"release_url": "https://aka.ms/download-jdk",
|
|
||||||
"files": [
|
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-25.0.0-macos-x64.tar.gz",
|
|
||||||
"arch": "x64",
|
|
||||||
"platform": "darwin",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-25.0.0-macos-x64.tar.gz"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-25.0.0-linux-x64.tar.gz",
|
|
||||||
"arch": "x64",
|
|
||||||
"platform": "linux",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-25.0.0-linux-x64.tar.gz"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-25.0.0-windows-x64.zip",
|
|
||||||
"arch": "x64",
|
|
||||||
"platform": "win32",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-25.0.0-windows-x64.zip"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-25.0.0-macos-aarch64.tar.gz",
|
|
||||||
"arch": "aarch64",
|
|
||||||
"platform": "darwin",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-25.0.0-macos-aarch64.tar.gz"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-25.0.0-linux-aarch64.tar.gz",
|
|
||||||
"arch": "aarch64",
|
|
||||||
"platform": "linux",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-25.0.0-linux-aarch64.tar.gz"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-25.0.0-windows-aarch64.zip",
|
|
||||||
"arch": "aarch64",
|
|
||||||
"platform": "win32",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-25.0.0-windows-aarch64.zip"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"version": "21.0.0",
|
"version": "21.0.0",
|
||||||
"stable": true,
|
"stable": true,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -29,11 +29,6 @@ describe('findPackageForDownload', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
|
||||||
'25.x',
|
|
||||||
'25.0.0',
|
|
||||||
'https://aka.ms/download-jdk/microsoft-jdk-25.0.0-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
'21.x',
|
'21.x',
|
||||||
'21.0.0',
|
'21.0.0',
|
||||||
|
|||||||
4
dist/cleanup/index.js
vendored
4
dist/cleanup/index.js
vendored
@@ -94747,8 +94747,8 @@ function convertVersionToSemver(version) {
|
|||||||
}
|
}
|
||||||
exports.convertVersionToSemver = convertVersionToSemver;
|
exports.convertVersionToSemver = convertVersionToSemver;
|
||||||
function getGitHubHttpHeaders() {
|
function getGitHubHttpHeaders() {
|
||||||
const resolvedToken = core.getInput('token') || process.env.GITHUB_TOKEN;
|
const token = core.getInput('token');
|
||||||
const auth = !resolvedToken ? undefined : `token ${resolvedToken}`;
|
const auth = !token ? undefined : `token ${token}`;
|
||||||
const headers = {
|
const headers = {
|
||||||
accept: 'application/vnd.github.VERSION.raw'
|
accept: 'application/vnd.github.VERSION.raw'
|
||||||
};
|
};
|
||||||
|
|||||||
219
dist/setup/index.js
vendored
219
dist/setup/index.js
vendored
@@ -129856,7 +129856,6 @@ class JavaBase {
|
|||||||
this.checkLatest = installerOptions.checkLatest;
|
this.checkLatest = installerOptions.checkLatest;
|
||||||
}
|
}
|
||||||
setupJava() {
|
setupJava() {
|
||||||
var _a, _b;
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let foundJava = this.findInToolcache();
|
let foundJava = this.findInToolcache();
|
||||||
if (foundJava && !this.checkLatest) {
|
if (foundJava && !this.checkLatest) {
|
||||||
@@ -129864,22 +129863,7 @@ class JavaBase {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info('Trying to resolve the latest version from remote');
|
core.info('Trying to resolve the latest version from remote');
|
||||||
const MAX_RETRIES = 4;
|
|
||||||
const RETRY_DELAY_MS = 2000;
|
|
||||||
const retryableCodes = [
|
|
||||||
'ETIMEDOUT',
|
|
||||||
'ECONNRESET',
|
|
||||||
'ENOTFOUND',
|
|
||||||
'ECONNREFUSED'
|
|
||||||
];
|
|
||||||
let retries = MAX_RETRIES;
|
|
||||||
while (retries > 0) {
|
|
||||||
try {
|
try {
|
||||||
// Clear console timers before each attempt to prevent conflicts
|
|
||||||
if (retries < MAX_RETRIES && core.isDebug()) {
|
|
||||||
const consoleAny = console;
|
|
||||||
(_b = (_a = consoleAny._times) === null || _a === void 0 ? void 0 : _a.clear) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
||||||
}
|
|
||||||
const javaRelease = yield this.findPackageForDownload(this.version);
|
const javaRelease = yield this.findPackageForDownload(this.version);
|
||||||
core.info(`Resolved latest version as ${javaRelease.version}`);
|
core.info(`Resolved latest version as ${javaRelease.version}`);
|
||||||
if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) === javaRelease.version) {
|
if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) === javaRelease.version) {
|
||||||
@@ -129890,23 +129874,8 @@ class JavaBase {
|
|||||||
foundJava = yield this.downloadTool(javaRelease);
|
foundJava = yield this.downloadTool(javaRelease);
|
||||||
core.info(`Java ${foundJava.version} was downloaded`);
|
core.info(`Java ${foundJava.version} was downloaded`);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
retries--;
|
|
||||||
// Check if error is retryable (including aggregate errors)
|
|
||||||
const isRetryable = (error instanceof tc.HTTPError &&
|
|
||||||
error.httpStatusCode &&
|
|
||||||
[429, 502, 503, 504].includes(error.httpStatusCode)) ||
|
|
||||||
retryableCodes.includes(error === null || error === void 0 ? void 0 : error.code) ||
|
|
||||||
((error === null || error === void 0 ? void 0 : error.errors) &&
|
|
||||||
Array.isArray(error.errors) &&
|
|
||||||
error.errors.some((err) => retryableCodes.includes(err === null || err === void 0 ? void 0 : err.code)));
|
|
||||||
if (retries > 0 && isRetryable) {
|
|
||||||
core.debug(`Attempt failed due to network or timeout issues, initiating retry... (${retries} attempts left)`);
|
|
||||||
yield new Promise(r => setTimeout(r, RETRY_DELAY_MS));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (error instanceof tc.HTTPError) {
|
if (error instanceof tc.HTTPError) {
|
||||||
if (error.httpStatusCode === 403) {
|
if (error.httpStatusCode === 403) {
|
||||||
core.error('HTTP 403: Permission denied or access restricted.');
|
core.error('HTTP 403: Permission denied or access restricted.');
|
||||||
@@ -129918,52 +129887,16 @@ class JavaBase {
|
|||||||
core.error(`HTTP ${error.httpStatusCode}: ${error.message}`);
|
core.error(`HTTP ${error.httpStatusCode}: ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (error && error.errors && Array.isArray(error.errors)) {
|
else {
|
||||||
core.error(`Java setup failed due to network or configuration error(s)`);
|
const message = error instanceof Error ? error.message : JSON.stringify(error);
|
||||||
|
core.error(`Java setup failed due to network issue or timeout: ${message}`);
|
||||||
|
}
|
||||||
if (error instanceof Error && error.stack) {
|
if (error instanceof Error && error.stack) {
|
||||||
core.debug(error.stack);
|
core.debug(error.stack);
|
||||||
}
|
}
|
||||||
for (const err of error.errors) {
|
|
||||||
const endpoint = (err === null || err === void 0 ? void 0 : err.address) || (err === null || err === void 0 ? void 0 : err.hostname) || '';
|
|
||||||
const port = (err === null || err === void 0 ? void 0 : err.port) ? `:${err.port}` : '';
|
|
||||||
const message = (err === null || err === void 0 ? void 0 : err.message) || 'Aggregate error';
|
|
||||||
const endpointInfo = !message.includes(endpoint)
|
|
||||||
? ` ${endpoint}${port}`
|
|
||||||
: '';
|
|
||||||
const localInfo = err.localAddress && err.localPort
|
|
||||||
? ` - Local (${err.localAddress}:${err.localPort})`
|
|
||||||
: '';
|
|
||||||
const logMessage = `${message}${endpointInfo}${localInfo}`;
|
|
||||||
core.error(logMessage);
|
|
||||||
core.debug(`${err.stack || err.message}`);
|
|
||||||
Object.entries(err).forEach(([key, value]) => {
|
|
||||||
core.debug(`"${key}": ${JSON.stringify(value)}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const message = error instanceof Error ? error.message : JSON.stringify(error);
|
|
||||||
core.error(`Java setup process failed due to: ${message}`);
|
|
||||||
if (typeof (error === null || error === void 0 ? void 0 : error.code) === 'string') {
|
|
||||||
core.debug(error.stack);
|
|
||||||
}
|
|
||||||
const errorDetails = Object.assign({ name: error.name, message: error.message }, Object.getOwnPropertyNames(error)
|
|
||||||
.filter(prop => !['name', 'message', 'stack'].includes(prop))
|
|
||||||
.reduce((acc, prop) => {
|
|
||||||
acc[prop] = error[prop];
|
|
||||||
return acc;
|
|
||||||
}, {}));
|
|
||||||
Object.entries(errorDetails).forEach(([key, value]) => {
|
|
||||||
core.debug(`"${key}": ${JSON.stringify(value)}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!foundJava) {
|
|
||||||
throw new Error('Failed to resolve Java version');
|
|
||||||
}
|
|
||||||
// JDK folder may contain postfix "Contents/Home" on macOS
|
// JDK folder may contain postfix "Contents/Home" on macOS
|
||||||
const macOSPostfixPath = path_1.default.join(foundJava.path, constants_1.MACOS_JAVA_CONTENT_POSTFIX);
|
const macOSPostfixPath = path_1.default.join(foundJava.path, constants_1.MACOS_JAVA_CONTENT_POSTFIX);
|
||||||
if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) {
|
if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) {
|
||||||
@@ -130592,56 +130525,37 @@ const tc = __importStar(__nccwpck_require__(27784));
|
|||||||
const fs_1 = __importDefault(__nccwpck_require__(57147));
|
const fs_1 = __importDefault(__nccwpck_require__(57147));
|
||||||
const path_1 = __importDefault(__nccwpck_require__(71017));
|
const path_1 = __importDefault(__nccwpck_require__(71017));
|
||||||
const base_installer_1 = __nccwpck_require__(59741);
|
const base_installer_1 = __nccwpck_require__(59741);
|
||||||
const http_client_1 = __nccwpck_require__(96255);
|
|
||||||
const util_1 = __nccwpck_require__(92629);
|
const util_1 = __nccwpck_require__(92629);
|
||||||
|
const http_client_1 = __nccwpck_require__(96255);
|
||||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
||||||
const GRAALVM_MIN_VERSION = 17;
|
|
||||||
const SUPPORTED_ARCHITECTURES = ['x64', 'aarch64'];
|
|
||||||
class GraalVMDistribution extends base_installer_1.JavaBase {
|
class GraalVMDistribution extends base_installer_1.JavaBase {
|
||||||
constructor(installerOptions) {
|
constructor(installerOptions) {
|
||||||
super('GraalVM', installerOptions);
|
super('GraalVM', installerOptions);
|
||||||
}
|
}
|
||||||
downloadTool(javaRelease) {
|
downloadTool(javaRelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
|
||||||
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);
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
if (IS_WINDOWS) {
|
if (process.platform === 'win32') {
|
||||||
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
|
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
|
||||||
}
|
}
|
||||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
||||||
// Add validation for extracted path
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
if (!fs_1.default.existsSync(extractedJavaPath)) {
|
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
||||||
throw new Error(`Extraction failed: path ${extractedJavaPath} does not exist`);
|
|
||||||
}
|
|
||||||
const dirContents = fs_1.default.readdirSync(extractedJavaPath);
|
|
||||||
if (dirContents.length === 0) {
|
|
||||||
throw new Error('Extraction failed: no files found in extracted directory');
|
|
||||||
}
|
|
||||||
const archivePath = path_1.default.join(extractedJavaPath, dirContents[0]);
|
|
||||||
const version = this.getToolcacheVersionName(javaRelease.version);
|
const version = this.getToolcacheVersionName(javaRelease.version);
|
||||||
const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, version, this.architecture);
|
const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, version, this.architecture);
|
||||||
return { version: javaRelease.version, path: javaPath };
|
return { version: javaRelease.version, path: javaPath };
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
core.error(`Failed to download and extract GraalVM: ${error}`);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
findPackageForDownload(range) {
|
findPackageForDownload(range) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// Add input validation
|
|
||||||
if (!range || typeof range !== 'string') {
|
|
||||||
throw new Error('Version range is required and must be a string');
|
|
||||||
}
|
|
||||||
const arch = this.distributionArchitecture();
|
const arch = this.distributionArchitecture();
|
||||||
if (!SUPPORTED_ARCHITECTURES.includes(arch)) {
|
if (arch !== 'x64' && arch !== 'aarch64') {
|
||||||
throw new Error(`Unsupported architecture: ${this.architecture}. Supported architectures are: ${SUPPORTED_ARCHITECTURES.join(', ')}`);
|
throw new Error(`Unsupported architecture: ${this.architecture}`);
|
||||||
}
|
}
|
||||||
if (!this.stable) {
|
if (!this.stable) {
|
||||||
return this.findEABuildDownloadUrl(`${range}-ea`);
|
return this.findEABuildDownloadUrl(`${range}-ea`);
|
||||||
@@ -130651,104 +130565,81 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
|
|||||||
}
|
}
|
||||||
const platform = this.getPlatform();
|
const platform = this.getPlatform();
|
||||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
const major = range.includes('.') ? range.split('.')[0] : range;
|
let major;
|
||||||
const majorVersion = parseInt(major);
|
let fileUrl;
|
||||||
if (isNaN(majorVersion)) {
|
if (range.includes('.')) {
|
||||||
throw new Error(`Invalid version format: ${range}`);
|
major = range.split('.')[0];
|
||||||
|
fileUrl = `${GRAALVM_DL_BASE}/${major}/archive/graalvm-jdk-${range}_${platform}-${arch}_bin.${extension}`;
|
||||||
}
|
}
|
||||||
if (majorVersion < GRAALVM_MIN_VERSION) {
|
else {
|
||||||
throw new Error(`GraalVM is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`);
|
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 fileUrl = this.constructFileUrl(range, major, platform, arch, extension);
|
|
||||||
const response = yield this.http.head(fileUrl);
|
const response = yield this.http.head(fileUrl);
|
||||||
this.handleHttpResponse(response, range);
|
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 };
|
return { url: fileUrl, version: range };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
constructFileUrl(range, major, platform, arch, extension) {
|
|
||||||
return range.includes('.')
|
|
||||||
? `${GRAALVM_DL_BASE}/${major}/archive/graalvm-jdk-${range}_${platform}-${arch}_bin.${extension}`
|
|
||||||
: `${GRAALVM_DL_BASE}/${range}/latest/graalvm-jdk-${range}_${platform}-${arch}_bin.${extension}`;
|
|
||||||
}
|
|
||||||
handleHttpResponse(response, range) {
|
|
||||||
const statusCode = response.message.statusCode;
|
|
||||||
if (statusCode === http_client_1.HttpCodes.NotFound) {
|
|
||||||
throw new Error(`Could not find GraalVM for SemVer ${range}. Please check if this version is available at ${GRAALVM_DL_BASE}`);
|
|
||||||
}
|
|
||||||
if (statusCode === http_client_1.HttpCodes.Unauthorized ||
|
|
||||||
statusCode === http_client_1.HttpCodes.Forbidden) {
|
|
||||||
throw new Error(`Access denied when downloading GraalVM. Status code: ${statusCode}. Please check your credentials or permissions.`);
|
|
||||||
}
|
|
||||||
if (statusCode !== http_client_1.HttpCodes.OK) {
|
|
||||||
throw new Error(`HTTP request for GraalVM failed with status code: ${statusCode} (${response.message.statusMessage || 'Unknown error'})`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
findEABuildDownloadUrl(javaEaVersion) {
|
findEABuildDownloadUrl(javaEaVersion) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.debug(`Searching for EA build: ${javaEaVersion}`);
|
|
||||||
const versions = yield this.fetchEAJson(javaEaVersion);
|
const versions = yield this.fetchEAJson(javaEaVersion);
|
||||||
core.debug(`Found ${versions.length} EA versions`);
|
|
||||||
const latestVersion = versions.find(v => v.latest);
|
const latestVersion = versions.find(v => v.latest);
|
||||||
if (!latestVersion) {
|
if (!latestVersion) {
|
||||||
core.error(`Available versions: ${versions.map(v => v.version).join(', ')}`);
|
|
||||||
throw new Error(`Unable to find latest version for '${javaEaVersion}'`);
|
throw new Error(`Unable to find latest version for '${javaEaVersion}'`);
|
||||||
}
|
}
|
||||||
core.debug(`Latest version found: ${latestVersion.version}`);
|
|
||||||
const arch = this.distributionArchitecture();
|
const arch = this.distributionArchitecture();
|
||||||
const file = latestVersion.files.find(f => f.arch === arch && f.platform === GRAALVM_PLATFORM);
|
const file = latestVersion.files.find(f => f.arch === arch && f.platform === GRAALVM_PLATFORM);
|
||||||
if (!file) {
|
if (!file || !file.filename.startsWith('graalvm-jdk-')) {
|
||||||
core.error(`Available files for architecture ${arch}: ${JSON.stringify(latestVersion.files)}`);
|
throw new Error(`Unable to find file metadata for '${javaEaVersion}'`);
|
||||||
throw new Error(`Unable to find file for architecture '${arch}' and platform '${GRAALVM_PLATFORM}'`);
|
|
||||||
}
|
}
|
||||||
if (!file.filename.startsWith('graalvm-jdk-')) {
|
|
||||||
throw new Error(`Invalid filename format: ${file.filename}. Expected to start with 'graalvm-jdk-'`);
|
|
||||||
}
|
|
||||||
const downloadUrl = `${latestVersion.download_base_url}${file.filename}`;
|
|
||||||
core.debug(`Download URL: ${downloadUrl}`);
|
|
||||||
return {
|
return {
|
||||||
url: downloadUrl,
|
url: `${latestVersion.download_base_url}${file.filename}`,
|
||||||
version: latestVersion.version
|
version: latestVersion.version
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
fetchEAJson(javaEaVersion) {
|
fetchEAJson(javaEaVersion) {
|
||||||
var _a;
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const url = `https://api.github.com/repos/graalvm/oracle-graalvm-ea-builds/contents/versions/${javaEaVersion}.json?ref=main`;
|
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)();
|
const headers = (0, util_1.getGitHubHttpHeaders)();
|
||||||
core.debug(`Trying to fetch available version info for GraalVM EA builds from '${url}'`);
|
core.debug(`Trying to fetch available version info for GraalVM EA builds from '${url}'`);
|
||||||
|
let fetchedJson;
|
||||||
try {
|
try {
|
||||||
const response = yield this.http.getJson(url, headers);
|
fetchedJson = (yield this.http.getJson(url, headers))
|
||||||
if (!response.result) {
|
.result;
|
||||||
throw new Error(`No GraalVM EA build found for version '${javaEaVersion}'. Please check if the version is correct.`);
|
|
||||||
}
|
}
|
||||||
return response.result;
|
catch (err) {
|
||||||
|
throw Error(`Fetching version info for GraalVM EA builds from '${url}' failed with the error: ${err.message}`);
|
||||||
}
|
}
|
||||||
catch (error) {
|
if (fetchedJson === null) {
|
||||||
if (error instanceof Error) {
|
throw Error(`No GraalVM EA build found. Are you sure java-version: '${javaEaVersion}' is correct?`);
|
||||||
// Check if it's a 404 error (file not found)
|
|
||||||
if ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('404')) {
|
|
||||||
throw new Error(`GraalVM EA version '${javaEaVersion}' not found. Please verify the version exists in the EA builds repository.`);
|
|
||||||
}
|
|
||||||
// Re-throw with more context
|
|
||||||
throw new Error(`Failed to fetch GraalVM EA version information for '${javaEaVersion}': ${error.message}`);
|
|
||||||
}
|
|
||||||
// If it's not an Error instance, throw a generic error
|
|
||||||
throw new Error(`Failed to fetch GraalVM EA version information for '${javaEaVersion}'`);
|
|
||||||
}
|
}
|
||||||
|
return fetchedJson;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getPlatform(platform = process.platform) {
|
getPlatform(platform = process.platform) {
|
||||||
const platformMap = {
|
switch (platform) {
|
||||||
darwin: 'macos',
|
case 'darwin':
|
||||||
win32: 'windows',
|
return 'macos';
|
||||||
linux: 'linux'
|
case 'win32':
|
||||||
};
|
return 'windows';
|
||||||
const result = platformMap[platform];
|
case 'linux':
|
||||||
if (!result) {
|
return 'linux';
|
||||||
|
default:
|
||||||
throw new Error(`Platform '${platform}' is not supported. Supported platforms: 'linux', 'macos', 'windows'`);
|
throw new Error(`Platform '${platform}' is not supported. Supported platforms: 'linux', 'macos', 'windows'`);
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.GraalVMDistribution = GraalVMDistribution;
|
exports.GraalVMDistribution = GraalVMDistribution;
|
||||||
@@ -131629,9 +131520,9 @@ class SapMachineDistribution extends base_installer_1.JavaBase {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const platform = this.getPlatformOption();
|
const platform = this.getPlatformOption();
|
||||||
const arch = this.distributionArchitecture();
|
const arch = this.distributionArchitecture();
|
||||||
let fetchedReleasesJson = yield this.fetchReleasesFromUrl('https://sapmachine.io/assets/data/sapmachine-releases-all.json');
|
let fetchedReleasesJson = yield this.fetchReleasesFromUrl('https://sap.github.io/SapMachine/assets/data/sapmachine-releases-all.json');
|
||||||
if (!fetchedReleasesJson) {
|
if (!fetchedReleasesJson) {
|
||||||
fetchedReleasesJson = yield this.fetchReleasesFromUrl('https://sap.github.io/SapMachine/assets/data/sapmachine-releases-all.json');
|
fetchedReleasesJson = yield this.fetchReleasesFromUrl('https://api.github.com/repos/SAP/SapMachine/contents/assets/data/sapmachine-releases-all.json?ref=gh-pages', (0, util_1.getGitHubHttpHeaders)());
|
||||||
}
|
}
|
||||||
if (!fetchedReleasesJson) {
|
if (!fetchedReleasesJson) {
|
||||||
throw new Error(`Couldn't fetch SapMachine versions information from both primary and backup urls`);
|
throw new Error(`Couldn't fetch SapMachine versions information from both primary and backup urls`);
|
||||||
@@ -132891,8 +132782,8 @@ function convertVersionToSemver(version) {
|
|||||||
}
|
}
|
||||||
exports.convertVersionToSemver = convertVersionToSemver;
|
exports.convertVersionToSemver = convertVersionToSemver;
|
||||||
function getGitHubHttpHeaders() {
|
function getGitHubHttpHeaders() {
|
||||||
const resolvedToken = core.getInput('token') || process.env.GITHUB_TOKEN;
|
const token = core.getInput('token');
|
||||||
const auth = !resolvedToken ? undefined : `token ${resolvedToken}`;
|
const auth = !token ? undefined : `token ${token}`;
|
||||||
const headers = {
|
const headers = {
|
||||||
accept: 'application/vnd.github.VERSION.raw'
|
accept: 'application/vnd.github.VERSION.raw'
|
||||||
};
|
};
|
||||||
|
|||||||
780
package-lock.json
generated
780
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -44,9 +44,9 @@
|
|||||||
"@types/node": "^24.1.0",
|
"@types/node": "^24.1.0",
|
||||||
"@types/semver": "^7.5.8",
|
"@types/semver": "^7.5.8",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.35.1",
|
"@typescript-eslint/eslint-plugin": "^8.35.1",
|
||||||
"@typescript-eslint/parser": "^8.35.1",
|
"@typescript-eslint/parser": "^8.46.2",
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"eslint": "^9.39.1",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-prettier": "^8.6.0",
|
"eslint-config-prettier": "^8.6.0",
|
||||||
"eslint-plugin-jest": "^29.0.1",
|
"eslint-plugin-jest": "^29.0.1",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
|
|||||||
@@ -51,22 +51,7 @@ export abstract class JavaBase {
|
|||||||
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
||||||
} else {
|
} else {
|
||||||
core.info('Trying to resolve the latest version from remote');
|
core.info('Trying to resolve the latest version from remote');
|
||||||
const MAX_RETRIES = 4;
|
|
||||||
const RETRY_DELAY_MS = 2000;
|
|
||||||
const retryableCodes = [
|
|
||||||
'ETIMEDOUT',
|
|
||||||
'ECONNRESET',
|
|
||||||
'ENOTFOUND',
|
|
||||||
'ECONNREFUSED'
|
|
||||||
];
|
|
||||||
let retries = MAX_RETRIES;
|
|
||||||
while (retries > 0) {
|
|
||||||
try {
|
try {
|
||||||
// Clear console timers before each attempt to prevent conflicts
|
|
||||||
if (retries < MAX_RETRIES && core.isDebug()) {
|
|
||||||
const consoleAny = console as any;
|
|
||||||
consoleAny._times?.clear?.();
|
|
||||||
}
|
|
||||||
const javaRelease = await this.findPackageForDownload(this.version);
|
const javaRelease = await this.findPackageForDownload(this.version);
|
||||||
core.info(`Resolved latest version as ${javaRelease.version}`);
|
core.info(`Resolved latest version as ${javaRelease.version}`);
|
||||||
if (foundJava?.version === javaRelease.version) {
|
if (foundJava?.version === javaRelease.version) {
|
||||||
@@ -76,90 +61,29 @@ export abstract class JavaBase {
|
|||||||
foundJava = await this.downloadTool(javaRelease);
|
foundJava = await this.downloadTool(javaRelease);
|
||||||
core.info(`Java ${foundJava.version} was downloaded`);
|
core.info(`Java ${foundJava.version} was downloaded`);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
retries--;
|
|
||||||
// Check if error is retryable (including aggregate errors)
|
|
||||||
const isRetryable =
|
|
||||||
(error instanceof tc.HTTPError &&
|
|
||||||
error.httpStatusCode &&
|
|
||||||
[429, 502, 503, 504].includes(error.httpStatusCode)) ||
|
|
||||||
retryableCodes.includes(error?.code) ||
|
|
||||||
(error?.errors &&
|
|
||||||
Array.isArray(error.errors) &&
|
|
||||||
error.errors.some((err: any) =>
|
|
||||||
retryableCodes.includes(err?.code)
|
|
||||||
));
|
|
||||||
if (retries > 0 && isRetryable) {
|
|
||||||
core.debug(
|
|
||||||
`Attempt failed due to network or timeout issues, initiating retry... (${retries} attempts left)`
|
|
||||||
);
|
|
||||||
await new Promise(r => setTimeout(r, RETRY_DELAY_MS));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (error instanceof tc.HTTPError) {
|
if (error instanceof tc.HTTPError) {
|
||||||
if (error.httpStatusCode === 403) {
|
if (error.httpStatusCode === 403) {
|
||||||
core.error('HTTP 403: Permission denied or access restricted.');
|
core.error('HTTP 403: Permission denied or access restricted.');
|
||||||
} else if (error.httpStatusCode === 429) {
|
} else if (error.httpStatusCode === 429) {
|
||||||
core.warning(
|
core.warning('HTTP 429: Rate limit exceeded. Please retry later.');
|
||||||
'HTTP 429: Rate limit exceeded. Please retry later.'
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
core.error(`HTTP ${error.httpStatusCode}: ${error.message}`);
|
core.error(`HTTP ${error.httpStatusCode}: ${error.message}`);
|
||||||
}
|
}
|
||||||
} else if (error && error.errors && Array.isArray(error.errors)) {
|
|
||||||
core.error(
|
|
||||||
`Java setup failed due to network or configuration error(s)`
|
|
||||||
);
|
|
||||||
if (error instanceof Error && error.stack) {
|
|
||||||
core.debug(error.stack);
|
|
||||||
}
|
|
||||||
for (const err of error.errors) {
|
|
||||||
const endpoint = err?.address || err?.hostname || '';
|
|
||||||
const port = err?.port ? `:${err.port}` : '';
|
|
||||||
const message = err?.message || 'Aggregate error';
|
|
||||||
const endpointInfo = !message.includes(endpoint)
|
|
||||||
? ` ${endpoint}${port}`
|
|
||||||
: '';
|
|
||||||
const localInfo =
|
|
||||||
err.localAddress && err.localPort
|
|
||||||
? ` - Local (${err.localAddress}:${err.localPort})`
|
|
||||||
: '';
|
|
||||||
const logMessage = `${message}${endpointInfo}${localInfo}`;
|
|
||||||
core.error(logMessage);
|
|
||||||
core.debug(`${err.stack || err.message}`);
|
|
||||||
Object.entries(err).forEach(([key, value]) => {
|
|
||||||
core.debug(`"${key}": ${JSON.stringify(value)}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const message =
|
const message =
|
||||||
error instanceof Error ? error.message : JSON.stringify(error);
|
error instanceof Error ? error.message : JSON.stringify(error);
|
||||||
core.error(`Java setup process failed due to: ${message}`);
|
core.error(
|
||||||
if (typeof error?.code === 'string') {
|
`Java setup failed due to network issue or timeout: ${message}`
|
||||||
core.debug(error.stack);
|
);
|
||||||
}
|
}
|
||||||
const errorDetails = {
|
if (error instanceof Error && error.stack) {
|
||||||
name: error.name,
|
core.debug(error.stack);
|
||||||
message: error.message,
|
|
||||||
...Object.getOwnPropertyNames(error)
|
|
||||||
.filter(prop => !['name', 'message', 'stack'].includes(prop))
|
|
||||||
.reduce<{[key: string]: any}>((acc, prop) => {
|
|
||||||
acc[prop] = error[prop];
|
|
||||||
return acc;
|
|
||||||
}, {})
|
|
||||||
};
|
|
||||||
Object.entries(errorDetails).forEach(([key, value]) => {
|
|
||||||
core.debug(`"${key}": ${JSON.stringify(value)}`);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!foundJava) {
|
|
||||||
throw new Error('Failed to resolve Java version');
|
|
||||||
}
|
|
||||||
// JDK folder may contain postfix "Contents/Home" on macOS
|
// JDK folder may contain postfix "Contents/Home" on macOS
|
||||||
const macOSPostfixPath = path.join(
|
const macOSPostfixPath = path.join(
|
||||||
foundJava.path,
|
foundJava.path,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
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';
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import {JavaBase} from '../base-installer';
|
import {JavaBase} from '../base-installer';
|
||||||
import {HttpCodes} from '@actions/http-client';
|
|
||||||
import {GraalVMEAVersion} from './models';
|
|
||||||
import {
|
import {
|
||||||
JavaDownloadRelease,
|
JavaDownloadRelease,
|
||||||
JavaInstallerOptions,
|
JavaInstallerOptions,
|
||||||
@@ -16,14 +16,12 @@ import {
|
|||||||
getGitHubHttpHeaders,
|
getGitHubHttpHeaders,
|
||||||
renameWinArchive
|
renameWinArchive
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
|
import {HttpCodes} from '@actions/http-client';
|
||||||
|
import {GraalVMEAVersion} from './models';
|
||||||
|
|
||||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
||||||
const GRAALVM_MIN_VERSION = 17;
|
|
||||||
const SUPPORTED_ARCHITECTURES = ['x64', 'aarch64'] as const;
|
|
||||||
type SupportedArchitecture = (typeof SUPPORTED_ARCHITECTURES)[number];
|
|
||||||
type OsVersions = 'linux' | 'macos' | 'windows';
|
|
||||||
|
|
||||||
export class GraalVMDistribution extends JavaBase {
|
export class GraalVMDistribution extends JavaBase {
|
||||||
constructor(installerOptions: JavaInstallerOptions) {
|
constructor(installerOptions: JavaInstallerOptions) {
|
||||||
@@ -33,7 +31,6 @@ export class GraalVMDistribution extends JavaBase {
|
|||||||
protected async downloadTool(
|
protected async downloadTool(
|
||||||
javaRelease: JavaDownloadRelease
|
javaRelease: JavaDownloadRelease
|
||||||
): Promise<JavaInstallerResults> {
|
): Promise<JavaInstallerResults> {
|
||||||
try {
|
|
||||||
core.info(
|
core.info(
|
||||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||||
);
|
);
|
||||||
@@ -41,30 +38,13 @@ export class GraalVMDistribution extends JavaBase {
|
|||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
if (IS_WINDOWS) {
|
if (process.platform === 'win32') {
|
||||||
javaArchivePath = renameWinArchive(javaArchivePath);
|
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||||
}
|
}
|
||||||
|
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||||
|
|
||||||
const extractedJavaPath = await extractJdkFile(
|
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||||
javaArchivePath,
|
const archivePath = path.join(extractedJavaPath, archiveName);
|
||||||
extension
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add validation for extracted path
|
|
||||||
if (!fs.existsSync(extractedJavaPath)) {
|
|
||||||
throw new Error(
|
|
||||||
`Extraction failed: path ${extractedJavaPath} does not exist`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const dirContents = fs.readdirSync(extractedJavaPath);
|
|
||||||
if (dirContents.length === 0) {
|
|
||||||
throw new Error(
|
|
||||||
'Extraction failed: no files found in extracted directory'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const archivePath = path.join(extractedJavaPath, dirContents[0]);
|
|
||||||
const version = this.getToolcacheVersionName(javaRelease.version);
|
const version = this.getToolcacheVersionName(javaRelease.version);
|
||||||
|
|
||||||
const javaPath = await tc.cacheDir(
|
const javaPath = await tc.cacheDir(
|
||||||
@@ -75,25 +55,14 @@ export class GraalVMDistribution extends JavaBase {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return {version: javaRelease.version, path: javaPath};
|
return {version: javaRelease.version, path: javaPath};
|
||||||
} catch (error) {
|
|
||||||
core.error(`Failed to download and extract GraalVM: ${error}`);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async findPackageForDownload(
|
protected async findPackageForDownload(
|
||||||
range: string
|
range: string
|
||||||
): Promise<JavaDownloadRelease> {
|
): Promise<JavaDownloadRelease> {
|
||||||
// Add input validation
|
|
||||||
if (!range || typeof range !== 'string') {
|
|
||||||
throw new Error('Version range is required and must be a string');
|
|
||||||
}
|
|
||||||
|
|
||||||
const arch = this.distributionArchitecture();
|
const arch = this.distributionArchitecture();
|
||||||
if (!SUPPORTED_ARCHITECTURES.includes(arch as SupportedArchitecture)) {
|
if (arch !== 'x64' && arch !== 'aarch64') {
|
||||||
throw new Error(
|
throw new Error(`Unsupported architecture: ${this.architecture}`);
|
||||||
`Unsupported architecture: ${this.architecture}. Supported architectures are: ${SUPPORTED_ARCHITECTURES.join(', ')}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.stable) {
|
if (!this.stable) {
|
||||||
@@ -106,113 +75,52 @@ export class GraalVMDistribution extends JavaBase {
|
|||||||
|
|
||||||
const platform = this.getPlatform();
|
const platform = this.getPlatform();
|
||||||
const extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
const major = range.includes('.') ? range.split('.')[0] : range;
|
let major;
|
||||||
const majorVersion = parseInt(major);
|
let fileUrl;
|
||||||
|
if (range.includes('.')) {
|
||||||
if (isNaN(majorVersion)) {
|
major = range.split('.')[0];
|
||||||
throw new Error(`Invalid version format: ${range}`);
|
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 (majorVersion < GRAALVM_MIN_VERSION) {
|
if (parseInt(major) < 17) {
|
||||||
throw new Error(
|
throw new Error('GraalVM is only supported for JDK 17 and later');
|
||||||
`GraalVM is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileUrl = this.constructFileUrl(
|
|
||||||
range,
|
|
||||||
major,
|
|
||||||
platform,
|
|
||||||
arch,
|
|
||||||
extension
|
|
||||||
);
|
|
||||||
|
|
||||||
const response = await this.http.head(fileUrl);
|
const response = await this.http.head(fileUrl);
|
||||||
this.handleHttpResponse(response, range);
|
|
||||||
|
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};
|
return {url: fileUrl, version: range};
|
||||||
}
|
}
|
||||||
|
|
||||||
private constructFileUrl(
|
|
||||||
range: string,
|
|
||||||
major: string,
|
|
||||||
platform: string,
|
|
||||||
arch: string,
|
|
||||||
extension: string
|
|
||||||
): string {
|
|
||||||
return range.includes('.')
|
|
||||||
? `${GRAALVM_DL_BASE}/${major}/archive/graalvm-jdk-${range}_${platform}-${arch}_bin.${extension}`
|
|
||||||
: `${GRAALVM_DL_BASE}/${range}/latest/graalvm-jdk-${range}_${platform}-${arch}_bin.${extension}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
private handleHttpResponse(response: any, range: string): void {
|
|
||||||
const statusCode = response.message.statusCode;
|
|
||||||
|
|
||||||
if (statusCode === HttpCodes.NotFound) {
|
|
||||||
throw new Error(
|
|
||||||
`Could not find GraalVM for SemVer ${range}. Please check if this version is available at ${GRAALVM_DL_BASE}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
statusCode === HttpCodes.Unauthorized ||
|
|
||||||
statusCode === HttpCodes.Forbidden
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Access denied when downloading GraalVM. Status code: ${statusCode}. Please check your credentials or permissions.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (statusCode !== HttpCodes.OK) {
|
|
||||||
throw new Error(
|
|
||||||
`HTTP request for GraalVM failed with status code: ${statusCode} (${response.message.statusMessage || 'Unknown error'})`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async findEABuildDownloadUrl(
|
private async findEABuildDownloadUrl(
|
||||||
javaEaVersion: string
|
javaEaVersion: string
|
||||||
): Promise<JavaDownloadRelease> {
|
): Promise<JavaDownloadRelease> {
|
||||||
core.debug(`Searching for EA build: ${javaEaVersion}`);
|
|
||||||
|
|
||||||
const versions = await this.fetchEAJson(javaEaVersion);
|
const versions = await this.fetchEAJson(javaEaVersion);
|
||||||
core.debug(`Found ${versions.length} EA versions`);
|
|
||||||
|
|
||||||
const latestVersion = versions.find(v => v.latest);
|
const latestVersion = versions.find(v => v.latest);
|
||||||
if (!latestVersion) {
|
if (!latestVersion) {
|
||||||
core.error(
|
|
||||||
`Available versions: ${versions.map(v => v.version).join(', ')}`
|
|
||||||
);
|
|
||||||
throw new Error(`Unable to find latest version for '${javaEaVersion}'`);
|
throw new Error(`Unable to find latest version for '${javaEaVersion}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
core.debug(`Latest version found: ${latestVersion.version}`);
|
|
||||||
|
|
||||||
const arch = this.distributionArchitecture();
|
const arch = this.distributionArchitecture();
|
||||||
const file = latestVersion.files.find(
|
const file = latestVersion.files.find(
|
||||||
f => f.arch === arch && f.platform === GRAALVM_PLATFORM
|
f => f.arch === arch && f.platform === GRAALVM_PLATFORM
|
||||||
);
|
);
|
||||||
|
if (!file || !file.filename.startsWith('graalvm-jdk-')) {
|
||||||
if (!file) {
|
throw new Error(`Unable to find file metadata for '${javaEaVersion}'`);
|
||||||
core.error(
|
|
||||||
`Available files for architecture ${arch}: ${JSON.stringify(latestVersion.files)}`
|
|
||||||
);
|
|
||||||
throw new Error(
|
|
||||||
`Unable to find file for architecture '${arch}' and platform '${GRAALVM_PLATFORM}'`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file.filename.startsWith('graalvm-jdk-')) {
|
|
||||||
throw new Error(
|
|
||||||
`Invalid filename format: ${file.filename}. Expected to start with 'graalvm-jdk-'`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const downloadUrl = `${latestVersion.download_base_url}${file.filename}`;
|
|
||||||
core.debug(`Download URL: ${downloadUrl}`);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: downloadUrl,
|
url: `${latestVersion.download_base_url}${file.filename}`,
|
||||||
version: latestVersion.version
|
version: latestVersion.version
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -220,59 +128,49 @@ export class GraalVMDistribution extends JavaBase {
|
|||||||
private async fetchEAJson(
|
private async fetchEAJson(
|
||||||
javaEaVersion: string
|
javaEaVersion: string
|
||||||
): Promise<GraalVMEAVersion[]> {
|
): Promise<GraalVMEAVersion[]> {
|
||||||
const url = `https://api.github.com/repos/graalvm/oracle-graalvm-ea-builds/contents/versions/${javaEaVersion}.json?ref=main`;
|
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();
|
const headers = getGitHubHttpHeaders();
|
||||||
|
|
||||||
core.debug(
|
core.debug(
|
||||||
`Trying to fetch available version info for GraalVM EA builds from '${url}'`
|
`Trying to fetch available version info for GraalVM EA builds from '${url}'`
|
||||||
);
|
);
|
||||||
|
let fetchedJson;
|
||||||
try {
|
try {
|
||||||
const response = await this.http.getJson<GraalVMEAVersion[]>(
|
fetchedJson = (await this.http.getJson<GraalVMEAVersion[]>(url, headers))
|
||||||
url,
|
.result;
|
||||||
headers
|
} catch (err) {
|
||||||
);
|
throw Error(
|
||||||
|
`Fetching version info for GraalVM EA builds from '${url}' failed with the error: ${
|
||||||
if (!response.result) {
|
(err as Error).message
|
||||||
throw new Error(
|
}`
|
||||||
`No GraalVM EA build found for version '${javaEaVersion}'. Please check if the version is correct.`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (fetchedJson === null) {
|
||||||
return response.result;
|
throw Error(
|
||||||
} catch (error) {
|
`No GraalVM EA build found. Are you sure java-version: '${javaEaVersion}' is correct?`
|
||||||
if (error instanceof Error) {
|
|
||||||
// Check if it's a 404 error (file not found)
|
|
||||||
if (error.message?.includes('404')) {
|
|
||||||
throw new Error(
|
|
||||||
`GraalVM EA version '${javaEaVersion}' not found. Please verify the version exists in the EA builds repository.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Re-throw with more context
|
|
||||||
throw new Error(
|
|
||||||
`Failed to fetch GraalVM EA version information for '${javaEaVersion}': ${error.message}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// If it's not an Error instance, throw a generic error
|
|
||||||
throw new Error(
|
|
||||||
`Failed to fetch GraalVM EA version information for '${javaEaVersion}'`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
return fetchedJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPlatform(platform: NodeJS.Platform = process.platform): OsVersions {
|
public getPlatform(platform: NodeJS.Platform = process.platform): OsVersions {
|
||||||
const platformMap: Record<string, OsVersions> = {
|
switch (platform) {
|
||||||
darwin: 'macos',
|
case 'darwin':
|
||||||
win32: 'windows',
|
return 'macos';
|
||||||
linux: 'linux'
|
case 'win32':
|
||||||
};
|
return 'windows';
|
||||||
|
case 'linux':
|
||||||
const result = platformMap[platform];
|
return 'linux';
|
||||||
if (!result) {
|
default:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Platform '${platform}' is not supported. Supported platforms: 'linux', 'macos', 'windows'`
|
`Platform '${platform}' is not supported. Supported platforms: 'linux', 'macos', 'windows'`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +1,4 @@
|
|||||||
[
|
[
|
||||||
{
|
|
||||||
"version": "25.0.0",
|
|
||||||
"stable": true,
|
|
||||||
"release_url": "https://aka.ms/download-jdk",
|
|
||||||
"files": [
|
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-25.0.0-macos-x64.tar.gz",
|
|
||||||
"arch": "x64",
|
|
||||||
"platform": "darwin",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-25.0.0-macos-x64.tar.gz"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-25.0.0-linux-x64.tar.gz",
|
|
||||||
"arch": "x64",
|
|
||||||
"platform": "linux",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-25.0.0-linux-x64.tar.gz"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-25.0.0-windows-x64.zip",
|
|
||||||
"arch": "x64",
|
|
||||||
"platform": "win32",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-25.0.0-windows-x64.zip"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-25.0.0-macos-aarch64.tar.gz",
|
|
||||||
"arch": "aarch64",
|
|
||||||
"platform": "darwin",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-25.0.0-macos-aarch64.tar.gz"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-25.0.0-linux-aarch64.tar.gz",
|
|
||||||
"arch": "aarch64",
|
|
||||||
"platform": "linux",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-25.0.0-linux-aarch64.tar.gz"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-25.0.0-windows-aarch64.zip",
|
|
||||||
"arch": "aarch64",
|
|
||||||
"platform": "win32",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-25.0.0-windows-aarch64.zip"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"version": "21.0.2",
|
"version": "21.0.2",
|
||||||
"stable": true,
|
"stable": true,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
convertVersionToSemver,
|
convertVersionToSemver,
|
||||||
extractJdkFile,
|
extractJdkFile,
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
|
getGitHubHttpHeaders,
|
||||||
isVersionSatisfies,
|
isVersionSatisfies,
|
||||||
renameWinArchive
|
renameWinArchive
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
@@ -63,12 +64,13 @@ export class SapMachineDistribution extends JavaBase {
|
|||||||
const arch = this.distributionArchitecture();
|
const arch = this.distributionArchitecture();
|
||||||
|
|
||||||
let fetchedReleasesJson = await this.fetchReleasesFromUrl(
|
let fetchedReleasesJson = await this.fetchReleasesFromUrl(
|
||||||
'https://sapmachine.io/assets/data/sapmachine-releases-all.json'
|
'https://sap.github.io/SapMachine/assets/data/sapmachine-releases-all.json'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!fetchedReleasesJson) {
|
if (!fetchedReleasesJson) {
|
||||||
fetchedReleasesJson = await this.fetchReleasesFromUrl(
|
fetchedReleasesJson = await this.fetchReleasesFromUrl(
|
||||||
'https://sap.github.io/SapMachine/assets/data/sapmachine-releases-all.json'
|
'https://api.github.com/repos/SAP/SapMachine/contents/assets/data/sapmachine-releases-all.json?ref=gh-pages',
|
||||||
|
getGitHubHttpHeaders()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -184,8 +184,8 @@ export function convertVersionToSemver(version: number[] | string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getGitHubHttpHeaders(): OutgoingHttpHeaders {
|
export function getGitHubHttpHeaders(): OutgoingHttpHeaders {
|
||||||
const resolvedToken = core.getInput('token') || process.env.GITHUB_TOKEN;
|
const token = core.getInput('token');
|
||||||
const auth = !resolvedToken ? undefined : `token ${resolvedToken}`;
|
const auth = !token ? undefined : `token ${token}`;
|
||||||
|
|
||||||
const headers: OutgoingHttpHeaders = {
|
const headers: OutgoingHttpHeaders = {
|
||||||
accept: 'application/vnd.github.VERSION.raw'
|
accept: 'application/vnd.github.VERSION.raw'
|
||||||
|
|||||||
Reference in New Issue
Block a user