diff --git a/__tests__/graalvm.test.ts b/__tests__/graalvm.test.ts index 226c420..61fd01e 100644 --- a/__tests__/graalvm.test.ts +++ b/__tests__/graalvm.test.ts @@ -1,7 +1,7 @@ import * as path from 'path' import * as graalvm from '../src/graalvm' import {expect, test} from '@jest/globals' -import {getLatestRelease} from '../src/utils' +import {getTaggedRelease} from '../src/utils' import {findGraalVMVersion, findHighestJavaVersion} from '../src/graalvm' import {GRAALVM_RELEASES_REPO} from '../src/constants' @@ -31,7 +31,10 @@ test('request invalid version/javaVersion', async () => { }) test('find version/javaVersion', async () => { - const latestRelease = await getLatestRelease(GRAALVM_RELEASES_REPO) + const latestRelease = await getTaggedRelease( + GRAALVM_RELEASES_REPO, + 'vm-22.3.1' + ) const latestVersion = findGraalVMVersion(latestRelease) expect(latestVersion).not.toBe('') const latestJavaVersion = findHighestJavaVersion(latestRelease, latestVersion) @@ -43,7 +46,7 @@ test('find version/javaVersion', async () => { findGraalVMVersion(invalidRelease) } catch (err) { if (!(err instanceof Error)) { - fail(`Unexpected non-Erro: ${err}`) + fail(`Unexpected non-Error: ${err}`) } error = err } diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 3e81177..d3a90a8 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -70461,7 +70461,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.createPRComment = exports.isPREvent = exports.toSemVer = exports.calculateSHA256 = exports.downloadExtractAndCacheJDK = exports.downloadAndExtractJDK = exports.getLatestRelease = exports.exec = void 0; +exports.createPRComment = exports.isPREvent = exports.toSemVer = exports.calculateSHA256 = exports.downloadExtractAndCacheJDK = exports.downloadAndExtractJDK = exports.getTaggedRelease = exports.getLatestRelease = exports.exec = void 0; const c = __importStar(__nccwpck_require__(9042)); const core = __importStar(__nccwpck_require__(2186)); const github = __importStar(__nccwpck_require__(5438)); @@ -70503,6 +70503,19 @@ function getLatestRelease(repo) { }); } exports.getLatestRelease = getLatestRelease; +function getTaggedRelease(repo, tag) { + return __awaiter(this, void 0, void 0, function* () { + const githubToken = getGitHubToken(); + const options = githubToken.length > 0 ? { auth: githubToken } : {}; + const octokit = new GitHubDotCom(options); + return (yield octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', { + owner: c.GRAALVM_GH_USER, + repo, + tag + })).data; + }); +} +exports.getTaggedRelease = getTaggedRelease; function downloadAndExtractJDK(downloadUrl) { return __awaiter(this, void 0, void 0, function* () { return findJavaHomeInSubfolder(yield extract(yield tc.downloadTool(downloadUrl))); diff --git a/dist/main/index.js b/dist/main/index.js index 6209cc7..d539477 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -70141,7 +70141,7 @@ function checkForUpdates(graalVMVersion, javaVersion) { core.notice('Please consider upgrading your project to Java 17+. GraalVM 22.3.X releases are the last to support JDK11: https://github.com/oracle/graal/issues/5063'); return; } - const latestRelease = yield (0, utils_1.getLatestRelease)(constants_1.GRAALVM_RELEASES_REPO); + const latestRelease = yield (0, utils_1.getTaggedRelease)(constants_1.GRAALVM_RELEASES_REPO, 'vm-22.3.1'); const latestGraalVMVersion = (0, graalvm_1.findGraalVMVersion)(latestRelease); const selectedVersion = (0, utils_1.toSemVer)(graalVMVersion); const latestVersion = (0, utils_1.toSemVer)(latestGraalVMVersion); @@ -70778,10 +70778,11 @@ const GRAALVM_REPO_DEV_BUILDS = 'graalvm-ce-dev-builds'; const GRAALVM_TAG_PREFIX = 'vm-'; function setUpGraalVMLatest(gdsToken, javaVersion) { return __awaiter(this, void 0, void 0, function* () { + const lockedVersion = '22.3.1'; if (gdsToken.length > 0) { - return setUpGraalVMRelease(gdsToken, c.VERSION_LATEST, javaVersion); + return setUpGraalVMRelease(gdsToken, lockedVersion, javaVersion); } - const latestRelease = yield (0, utils_1.getLatestRelease)(c.GRAALVM_RELEASES_REPO); + const latestRelease = yield (0, utils_1.getTaggedRelease)(c.GRAALVM_RELEASES_REPO, GRAALVM_TAG_PREFIX + lockedVersion); const version = findGraalVMVersion(latestRelease); return setUpGraalVMRelease(gdsToken, version, javaVersion); }); @@ -71292,7 +71293,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.createPRComment = exports.isPREvent = exports.toSemVer = exports.calculateSHA256 = exports.downloadExtractAndCacheJDK = exports.downloadAndExtractJDK = exports.getLatestRelease = exports.exec = void 0; +exports.createPRComment = exports.isPREvent = exports.toSemVer = exports.calculateSHA256 = exports.downloadExtractAndCacheJDK = exports.downloadAndExtractJDK = exports.getTaggedRelease = exports.getLatestRelease = exports.exec = void 0; const c = __importStar(__nccwpck_require__(9042)); const core = __importStar(__nccwpck_require__(2186)); const github = __importStar(__nccwpck_require__(5438)); @@ -71334,6 +71335,19 @@ function getLatestRelease(repo) { }); } exports.getLatestRelease = getLatestRelease; +function getTaggedRelease(repo, tag) { + return __awaiter(this, void 0, void 0, function* () { + const githubToken = getGitHubToken(); + const options = githubToken.length > 0 ? { auth: githubToken } : {}; + const octokit = new GitHubDotCom(options); + return (yield octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', { + owner: c.GRAALVM_GH_USER, + repo, + tag + })).data; + }); +} +exports.getTaggedRelease = getTaggedRelease; function downloadAndExtractJDK(downloadUrl) { return __awaiter(this, void 0, void 0, function* () { return findJavaHomeInSubfolder(yield extract(yield tc.downloadTool(downloadUrl))); diff --git a/src/features/check-for-updates.ts b/src/features/check-for-updates.ts index 609d67c..a10395a 100644 --- a/src/features/check-for-updates.ts +++ b/src/features/check-for-updates.ts @@ -1,5 +1,5 @@ import * as core from '@actions/core' -import {getLatestRelease, toSemVer} from '../utils' +import {getTaggedRelease, toSemVer} from '../utils' import {lt, major, minor, valid} from 'semver' import {findGraalVMVersion} from '../graalvm' import {GRAALVM_RELEASES_REPO} from '../constants' @@ -15,7 +15,10 @@ export async function checkForUpdates( return } - const latestRelease = await getLatestRelease(GRAALVM_RELEASES_REPO) + const latestRelease = await getTaggedRelease( + GRAALVM_RELEASES_REPO, + 'vm-22.3.1' + ) const latestGraalVMVersion = findGraalVMVersion(latestRelease) const selectedVersion = toSemVer(graalVMVersion) const latestVersion = toSemVer(latestGraalVMVersion) diff --git a/src/graalvm.ts b/src/graalvm.ts index 50b0114..df092df 100644 --- a/src/graalvm.ts +++ b/src/graalvm.ts @@ -2,7 +2,8 @@ import * as c from './constants' import { downloadAndExtractJDK, downloadExtractAndCacheJDK, - getLatestRelease + getLatestRelease, + getTaggedRelease } from './utils' import {downloadGraalVMEE} from './gds' import {downloadTool} from '@actions/tool-cache' @@ -15,10 +16,14 @@ export async function setUpGraalVMLatest( gdsToken: string, javaVersion: string ): Promise { + const lockedVersion = '22.3.1' if (gdsToken.length > 0) { - return setUpGraalVMRelease(gdsToken, c.VERSION_LATEST, javaVersion) + return setUpGraalVMRelease(gdsToken, lockedVersion, javaVersion) } - const latestRelease = await getLatestRelease(c.GRAALVM_RELEASES_REPO) + const latestRelease = await getTaggedRelease( + c.GRAALVM_RELEASES_REPO, + GRAALVM_TAG_PREFIX + lockedVersion + ) const version = findGraalVMVersion(latestRelease) return setUpGraalVMRelease(gdsToken, version, javaVersion) } diff --git a/src/utils.ts b/src/utils.ts index ba1d77d..88f2b76 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -47,6 +47,22 @@ export async function getLatestRelease( ).data } +export async function getTaggedRelease( + repo: string, + tag: string +): Promise { + const githubToken = getGitHubToken() + const options = githubToken.length > 0 ? {auth: githubToken} : {} + const octokit = new GitHubDotCom(options) + return ( + await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', { + owner: c.GRAALVM_GH_USER, + repo, + tag + }) + ).data +} + export async function downloadAndExtractJDK( downloadUrl: string ): Promise {