diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 9cbc4f3..93c8561 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -92869,6 +92869,7 @@ const c = __importStar(__nccwpck_require__(9042)); const core = __importStar(__nccwpck_require__(2186)); const github = __importStar(__nccwpck_require__(5438)); const httpClient = __importStar(__nccwpck_require__(6255)); +const semver = __importStar(__nccwpck_require__(1383)); const tc = __importStar(__nccwpck_require__(7784)); const exec_1 = __nccwpck_require__(1514); const fs_1 = __nccwpck_require__(7147); @@ -92999,17 +93000,22 @@ function findJavaHomeInSubfolder(searchPath) { throw new Error(`Unexpected amount of directory items found: ${baseContents.length}`); } } -/** - * This helper turns GraalVM version numbers (e.g., `22.0.0.2`) into valid - * semver.org versions (e.g., `22.0.0-2`), which is needed because - * @actions/tool-cache uses `semver` to validate versions. - */ function toSemVer(version) { const parts = version.split('.'); - const major = parts[0]; - const minor = parts.length > 1 ? parts[1] : '0'; - const patch = parts.length > 2 ? parts.slice(2).join('-') : '0'; - return `${major}.${minor}.${patch}`; + if (parts.length === 4) { + /** + * Turn legacy GraalVM version numbers (e.g., `22.0.0.2`) into valid + * semver.org versions (e.g., `22.0.0-2`). + */ + return `${parts[0]}.${parts[1]}.${parts.slice(2).join('-')}`; + } + const versionParts = version.split('-', 2); + const suffix = versionParts.length === 2 ? '-' + versionParts[1] : ''; + const validVersion = semver.valid(semver.coerce(versionParts[0]) + suffix); + if (!validVersion) { + throw new Error(`Unable to convert '${version}' to semantic version. ${c.ERROR_HINT}`); + } + return validVersion; } exports.toSemVer = toSemVer; function isPREvent() { diff --git a/dist/main/index.js b/dist/main/index.js index d756017..b6a5550 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -93945,7 +93945,7 @@ function findLatestGraalVMJDKCEJavaVersion(majorJavaVersion) { } exports.findLatestGraalVMJDKCEJavaVersion = findLatestGraalVMJDKCEJavaVersion; function determineToolName(javaVersion, isCommunity) { - return `graalvm${isCommunity ? '-community' : ''}-jdk-${javaVersion}_${c.JDK_PLATFORM}-${c.JDK_ARCH}_bin`; + return `graalvm${isCommunity ? '-community' : ''}-jdk-${(0, utils_1.toSemVer)(javaVersion)}_${c.JDK_PLATFORM}-${c.JDK_ARCH}_bin`; } function downloadGraalVMJDK(downloadUrl, javaVersion) { return __awaiter(this, void 0, void 0, function* () { @@ -94644,6 +94644,7 @@ const c = __importStar(__nccwpck_require__(9042)); const core = __importStar(__nccwpck_require__(2186)); const github = __importStar(__nccwpck_require__(5438)); const httpClient = __importStar(__nccwpck_require__(6255)); +const semver = __importStar(__nccwpck_require__(1383)); const tc = __importStar(__nccwpck_require__(7784)); const exec_1 = __nccwpck_require__(1514); const fs_1 = __nccwpck_require__(7147); @@ -94774,17 +94775,22 @@ function findJavaHomeInSubfolder(searchPath) { throw new Error(`Unexpected amount of directory items found: ${baseContents.length}`); } } -/** - * This helper turns GraalVM version numbers (e.g., `22.0.0.2`) into valid - * semver.org versions (e.g., `22.0.0-2`), which is needed because - * @actions/tool-cache uses `semver` to validate versions. - */ function toSemVer(version) { const parts = version.split('.'); - const major = parts[0]; - const minor = parts.length > 1 ? parts[1] : '0'; - const patch = parts.length > 2 ? parts.slice(2).join('-') : '0'; - return `${major}.${minor}.${patch}`; + if (parts.length === 4) { + /** + * Turn legacy GraalVM version numbers (e.g., `22.0.0.2`) into valid + * semver.org versions (e.g., `22.0.0-2`). + */ + return `${parts[0]}.${parts[1]}.${parts.slice(2).join('-')}`; + } + const versionParts = version.split('-', 2); + const suffix = versionParts.length === 2 ? '-' + versionParts[1] : ''; + const validVersion = semver.valid(semver.coerce(versionParts[0]) + suffix); + if (!validVersion) { + throw new Error(`Unable to convert '${version}' to semantic version. ${c.ERROR_HINT}`); + } + return validVersion; } exports.toSemVer = toSemVer; function isPREvent() { diff --git a/src/graalvm.ts b/src/graalvm.ts index 1d8d437..2b12414 100644 --- a/src/graalvm.ts +++ b/src/graalvm.ts @@ -6,7 +6,8 @@ import { getLatestPrerelease, getLatestRelease, getMatchingTags, - getTaggedRelease + getTaggedRelease, + toSemVer } from './utils' import {downloadGraalVMEELegacy} from './gds' import {downloadTool} from '@actions/tool-cache' @@ -125,7 +126,7 @@ export async function findLatestGraalVMJDKCEJavaVersion( } function determineToolName(javaVersion: string, isCommunity: boolean) { - return `graalvm${isCommunity ? '-community' : ''}-jdk-${javaVersion}_${ + return `graalvm${isCommunity ? '-community' : ''}-jdk-${toSemVer(javaVersion)}_${ c.JDK_PLATFORM }-${c.JDK_ARCH}_bin` }