From 2fb264a6b0fa15708e018ba0677643c49616c44b Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Tue, 19 Sep 2023 16:17:51 +0200 Subject: [PATCH] Fix upgrade notice for JDK 20 users. --- dist/main/index.js | 48 ++++++++++++++----------------- src/features/check-for-updates.ts | 6 ++-- src/main.ts | 9 +++++- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/dist/main/index.js b/dist/main/index.js index 9707c15..96d2a92 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -70308,36 +70308,25 @@ var __importStar = (this && this.__importStar) || function (mod) { __setModuleDefault(result, mod); return result; }; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.checkForUpdates = void 0; const core = __importStar(__nccwpck_require__(2186)); function checkForUpdates(graalVMVersion, javaVersion) { - return __awaiter(this, void 0, void 0, function* () { - if (javaVersion === '20') { - core.notice('A new GraalVM release is available! Please consider upgrading to GraalVM for JDK 21: https://medium.com/p/ee01177dd12d'); - return; - } - if (graalVMVersion.length > 0 && - (javaVersion === '17' || javaVersion === '19')) { - const recommendedJDK = javaVersion === '17' ? '17' : '21'; - core.notice(`A new GraalVM release is available! Please consider upgrading to GraalVM for JDK ${recommendedJDK}. Instructions: https://github.com/graalvm/setup-graalvm#migrating-from-graalvm-223-or-earlier-to-the-new-graalvm-for-jdk-17-and-later`); - return; - } - if (graalVMVersion.startsWith('22.3.') && javaVersion === '11') { - 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; - } - // TODO: add support for JDK-specific update checks (e.g., 17.0.X) - }); + if (javaVersion === '20') { + core.notice('A new GraalVM release is available! Please consider upgrading to GraalVM for JDK 21: https://medium.com/graalvm/graalvm-for-jdk-21-is-here-ee01177dd12d'); + return; + } + if (graalVMVersion.length > 0 && + (javaVersion === '17' || javaVersion === '19')) { + const recommendedJDK = javaVersion === '17' ? '17' : '21'; + core.notice(`A new GraalVM release is available! Please consider upgrading to GraalVM for JDK ${recommendedJDK}. Instructions: https://github.com/graalvm/setup-graalvm#migrating-from-graalvm-223-or-earlier-to-the-new-graalvm-for-jdk-17-and-later`); + return; + } + if (graalVMVersion.startsWith('22.3.') && javaVersion === '11') { + 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; + } + // TODO: add support for JDK-specific update checks (e.g., 17.0.X) } exports.checkForUpdates = checkForUpdates; @@ -71388,6 +71377,11 @@ function run() { const isGraalVMforJDK17OrLater = distribution.length > 0 || graalVMVersion.length == 0; let graalVMHome; if (isGraalVMforJDK17OrLater) { + if (enableCheckForUpdates && + (distribution === c.DISTRIBUTION_GRAALVM || + distribution === c.DISTRIBUTION_GRAALVM_COMMUNITY)) { + (0, check_for_updates_1.checkForUpdates)(graalVMVersion, javaVersion); + } switch (distribution) { case c.DISTRIBUTION_GRAALVM: graalVMHome = yield graalvm.setUpGraalVMJDK(javaVersion); @@ -71449,7 +71443,7 @@ function run() { } else { if (enableCheckForUpdates) { - yield (0, check_for_updates_1.checkForUpdates)(graalVMVersion, javaVersion); + (0, check_for_updates_1.checkForUpdates)(graalVMVersion, javaVersion); } graalVMHome = yield graalvm.setUpGraalVMRelease(gdsToken, graalVMVersion, javaVersion); } diff --git a/src/features/check-for-updates.ts b/src/features/check-for-updates.ts index af882c1..02bcada 100644 --- a/src/features/check-for-updates.ts +++ b/src/features/check-for-updates.ts @@ -1,12 +1,12 @@ import * as core from '@actions/core' -export async function checkForUpdates( +export function checkForUpdates( graalVMVersion: string, javaVersion: string -): Promise { +): void { if (javaVersion === '20') { core.notice( - 'A new GraalVM release is available! Please consider upgrading to GraalVM for JDK 21: https://medium.com/p/ee01177dd12d' + 'A new GraalVM release is available! Please consider upgrading to GraalVM for JDK 21: https://medium.com/graalvm/graalvm-for-jdk-21-is-here-ee01177dd12d' ) return } diff --git a/src/main.ts b/src/main.ts index 7775671..4f6c107 100644 --- a/src/main.ts +++ b/src/main.ts @@ -43,6 +43,13 @@ async function run(): Promise { distribution.length > 0 || graalVMVersion.length == 0 let graalVMHome if (isGraalVMforJDK17OrLater) { + if ( + enableCheckForUpdates && + (distribution === c.DISTRIBUTION_GRAALVM || + distribution === c.DISTRIBUTION_GRAALVM_COMMUNITY) + ) { + checkForUpdates(graalVMVersion, javaVersion) + } switch (distribution) { case c.DISTRIBUTION_GRAALVM: graalVMHome = await graalvm.setUpGraalVMJDK(javaVersion) @@ -117,7 +124,7 @@ async function run(): Promise { graalVMHome = await setUpMandrel(graalVMVersion, javaVersion) } else { if (enableCheckForUpdates) { - await checkForUpdates(graalVMVersion, javaVersion) + checkForUpdates(graalVMVersion, javaVersion) } graalVMHome = await graalvm.setUpGraalVMRelease( gdsToken,