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:
Bruno Borges
2026-07-07 10:14:58 -04:00
parent e8aa5c4d23
commit 9051c81518
2 changed files with 22 additions and 9 deletions
+10 -4
View File
@@ -79652,6 +79652,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.KonaDistribution = void 0;
const core = __importStar(__nccwpck_require__(37484));
const tc = __importStar(__nccwpck_require__(33472));
const semver_1 = __importDefault(__nccwpck_require__(62088));
const fs_1 = __importDefault(__nccwpck_require__(79896));
const path_1 = __importDefault(__nccwpck_require__(16928));
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);
core.info(`Extracting Java archive...`);
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 archivePath = path_1.default.join(extractedJavaPath, archiveName);
const jdkDirectory = path_1.default.join(extractedJavaPath, archiveName);
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 };
});
}
@@ -79692,7 +79696,8 @@ class KonaDistribution extends base_installer_1.JavaBase {
version: item.version,
url: item.downloadUrl
};
});
})
.sort((a, b) => -semver_1.default.compareBuild(a.version, b.version));
if (!releases.length) {
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);
if (core.isDebug()) {
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.endGroup();
}