From f3b981e1234dc25604c785dae51062c769618e7c Mon Sep 17 00:00:00 2001 From: Ivan Zosimov Date: Tue, 12 Sep 2023 14:44:28 +0200 Subject: [PATCH] build: rebuild action --- dist/setup/index.js | 57 ++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 17b44c04..d6ebb511 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -104409,6 +104409,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.DragonwellDistribution = void 0; const core = __importStar(__nccwpck_require__(2186)); const tc = __importStar(__nccwpck_require__(7784)); +const semver_1 = __importDefault(__nccwpck_require__(1383)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const path_1 = __importDefault(__nccwpck_require__(1017)); const base_installer_1 = __nccwpck_require__(9741); @@ -104422,16 +104423,11 @@ class DragonwellDistribution extends base_installer_1.JavaBase { if (!this.stable) { throw new Error('Early access versions are not supported'); } - let majorVersion = version; - if (version.includes('.')) { - const splits = version.split('.'); - majorVersion = splits[0]; - version = splits.length >= 3 ? splits.slice(0, 3).join('.') : version; - } - const edition = majorVersion == '17' ? 'Standard' : 'Extended'; const availableVersions = yield this.getAvailableVersions(); const matchedVersions = availableVersions - .filter(item => item.jdk_version == version && item.edition == edition) + .filter(item => { + return util_1.isVersionSatisfies(version, item.jdk_version); + }) .map(item => { return { version: item.jdk_version, @@ -104446,17 +104442,16 @@ class DragonwellDistribution extends base_installer_1.JavaBase { }); } getAvailableVersions() { - var _a; return __awaiter(this, void 0, void 0, function* () { const platform = this.getPlatformOption(); const arch = this.distributionArchitecture(); const availableVersionsUrl = 'https://raw.githubusercontent.com/dragonwell-releng/dragonwell-setup-java/main/releases.json'; - const fetchedDragonwellVersions = (_a = (yield this.http.getJson(availableVersionsUrl)) - .result) !== null && _a !== void 0 ? _a : {}; - if (Object.keys(fetchedDragonwellVersions).length == 0) { - throw Error(`Couldn't fetch any dragonwell versions from ${availableVersionsUrl}`); + const fetchedDragonwellVersions = (yield this.http.getJson(availableVersionsUrl)) + .result; + if (!fetchedDragonwellVersions) { + throw new Error(`Couldn't fetch any dragonwell versions from ${availableVersionsUrl}`); } - const availableVersions = this.getEligibleAvailableVersions(platform, arch, fetchedDragonwellVersions); + const availableVersions = this.parseVersions(platform, arch, fetchedDragonwellVersions); if (core.isDebug()) { core.startGroup('Print information about available versions'); core.debug(availableVersions.map(item => item.jdk_version).join(', ')); @@ -104478,7 +104473,8 @@ class DragonwellDistribution extends base_installer_1.JavaBase { return { version: javaRelease.version, path: javaPath }; }); } - getEligibleAvailableVersions(platform, arch, dragonwellVersions) { + parseVersions(platform, arch, dragonwellVersions) { + var _a; const eligibleVersions = []; for (const majorVersion in dragonwellVersions) { const majorVersionMap = dragonwellVersions[majorVersion]; @@ -104493,27 +104489,44 @@ class DragonwellDistribution extends base_installer_1.JavaBase { } const archMap = platformMap[arch]; if (jdkVersion === 'latest') { - jdkVersion = majorVersion; + continue; } - if (jdkVersion.includes('.')) { - const splits = jdkVersion.split('.'); - jdkVersion = - splits.length >= 3 ? splits.slice(0, 3).join('.') : jdkVersion; + if (jdkVersion.split(".").length > 3) { + jdkVersion = this.transformToSemver(jdkVersion); } for (const edition in archMap) { eligibleVersions.push({ os: platform, architecture: arch, jdk_version: jdkVersion, - checksum: archMap[edition].sha256, + checksum: (_a = archMap[edition].sha256) !== null && _a !== void 0 ? _a : "", download_link: archMap[edition].download_url, edition: edition, image_type: 'jdk' }); + break; // Get the first available link to the JDK. In most cases it should point to the Extended version of JDK, in rare cases like with v17 it points to the Standard version (the only available). } } } - return eligibleVersions; + const sortedEligibleVersions = this.sortParsedVersions(eligibleVersions); // сортирует версии в порядке убивания + return sortedEligibleVersions; + } + // Sorts versions in descending order as by default data in JSON isn't sorted + sortParsedVersions(eligibleVersions) { + const sortedVersions = eligibleVersions.sort((versionObj1, versionObj2) => { + const version1 = versionObj1.jdk_version; + const version2 = versionObj2.jdk_version; + return semver_1.default.compareBuild(version1, version2); + }); + return sortedVersions.reverse(); + } + // Some version of Dragonwell JDK are numerated with help of non-semver notation (more then 3 digits). + // Common practice is to transform excess digits to the so-called semver build part, which is prefixed with the plus sign, to be able to operate with them using semver tools. + transformToSemver(version) { + const splits = version.split('.'); + const versionMainPart = splits.slice(0, 3).join("."); + const versionBuildPart = splits.slice(3).join("."); + return `${versionMainPart}+${versionBuildPart}`; } getPlatformOption() { switch (process.platform) {