mirror of
https://github.com/actions/setup-java.git
synced 2026-07-09 00:30:46 +03:00
Address Copilot review feedback for Kona distribution
- Sort matching releases by semver descending so range versions (e.g. >=17) resolve to the newest matching Kona JDK instead of the lowest - Rename downloaded archive on Windows before extraction (renameWinArchive) to avoid extraction failures - Import semver for version sorting Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Vendored
+10
-4
@@ -79652,6 +79652,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|||||||
exports.KonaDistribution = void 0;
|
exports.KonaDistribution = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(37484));
|
const core = __importStar(__nccwpck_require__(37484));
|
||||||
const tc = __importStar(__nccwpck_require__(33472));
|
const tc = __importStar(__nccwpck_require__(33472));
|
||||||
|
const semver_1 = __importDefault(__nccwpck_require__(62088));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(79896));
|
const fs_1 = __importDefault(__nccwpck_require__(79896));
|
||||||
const path_1 = __importDefault(__nccwpck_require__(16928));
|
const path_1 = __importDefault(__nccwpck_require__(16928));
|
||||||
const base_installer_1 = __nccwpck_require__(79935);
|
const base_installer_1 = __nccwpck_require__(79935);
|
||||||
@@ -79666,11 +79667,14 @@ class KonaDistribution extends base_installer_1.JavaBase {
|
|||||||
const javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
const 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)();
|
||||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
const archivePath = process.platform === 'win32'
|
||||||
|
? (0, util_1.renameWinArchive)(javaArchivePath)
|
||||||
|
: javaArchivePath;
|
||||||
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(archivePath, 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 jdkDirectory = path_1.default.join(extractedJavaPath, archiveName);
|
||||||
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(jdkDirectory, this.toolcacheFolderName, version, this.architecture);
|
||||||
return { version: javaRelease.version, path: javaPath };
|
return { version: javaRelease.version, path: javaPath };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -79692,7 +79696,8 @@ class KonaDistribution extends base_installer_1.JavaBase {
|
|||||||
version: item.version,
|
version: item.version,
|
||||||
url: item.downloadUrl
|
url: item.downloadUrl
|
||||||
};
|
};
|
||||||
});
|
})
|
||||||
|
.sort((a, b) => -semver_1.default.compareBuild(a.version, b.version));
|
||||||
if (!releases.length) {
|
if (!releases.length) {
|
||||||
throw new Error(`No Kona release for the specified version "${version}" on OS "${this.getOs()}" and arch "${this.getArch()}".`);
|
throw new Error(`No Kona release for the specified version "${version}" on OS "${this.getOs()}" and arch "${this.getArch()}".`);
|
||||||
}
|
}
|
||||||
@@ -79711,6 +79716,7 @@ class KonaDistribution extends base_installer_1.JavaBase {
|
|||||||
const availableReleases = this.chooseReleases(this.getOs(), this.getArch(), releaseInfo);
|
const availableReleases = this.chooseReleases(this.getOs(), this.getArch(), releaseInfo);
|
||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
core.startGroup('Print information about available releases');
|
core.startGroup('Print information about available releases');
|
||||||
|
console.timeEnd('Retrieving available releases for Kona took'); // eslint-disable-line no-console
|
||||||
core.debug(availableReleases.map(item => item.version).join(', '));
|
core.debug(availableReleases.map(item => item.version).join(', '));
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
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 semver from 'semver';
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@@ -14,7 +15,8 @@ import {
|
|||||||
import {
|
import {
|
||||||
extractJdkFile,
|
extractJdkFile,
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
isVersionSatisfies
|
isVersionSatisfies,
|
||||||
|
renameWinArchive
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
|
|
||||||
export class KonaDistribution extends JavaBase {
|
export class KonaDistribution extends JavaBase {
|
||||||
@@ -33,14 +35,18 @@ export class KonaDistribution extends JavaBase {
|
|||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
|
|
||||||
const extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
const archivePath =
|
||||||
|
process.platform === 'win32'
|
||||||
|
? renameWinArchive(javaArchivePath)
|
||||||
|
: javaArchivePath;
|
||||||
|
const extractedJavaPath = await extractJdkFile(archivePath, extension);
|
||||||
|
|
||||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path.join(extractedJavaPath, archiveName);
|
const jdkDirectory = path.join(extractedJavaPath, archiveName);
|
||||||
const version = this.getToolcacheVersionName(javaRelease.version);
|
const version = this.getToolcacheVersionName(javaRelease.version);
|
||||||
|
|
||||||
const javaPath = await tc.cacheDir(
|
const javaPath = await tc.cacheDir(
|
||||||
archivePath,
|
jdkDirectory,
|
||||||
this.toolcacheFolderName,
|
this.toolcacheFolderName,
|
||||||
version,
|
version,
|
||||||
this.architecture
|
this.architecture
|
||||||
@@ -70,7 +76,8 @@ export class KonaDistribution extends JavaBase {
|
|||||||
version: item.version,
|
version: item.version,
|
||||||
url: item.downloadUrl
|
url: item.downloadUrl
|
||||||
} as JavaDownloadRelease;
|
} as JavaDownloadRelease;
|
||||||
});
|
})
|
||||||
|
.sort((a, b) => -semver.compareBuild(a.version, b.version));
|
||||||
|
|
||||||
if (!releases.length) {
|
if (!releases.length) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
Reference in New Issue
Block a user