From 83a06ff9d9aa70f76a8d73278e646c20b2bf1ae5 Mon Sep 17 00:00:00 2001 From: Priya Gupta <147705955+priyagupta108@users.noreply.github.com> Date: Fri, 11 Oct 2024 03:02:25 +0530 Subject: [PATCH 1/4] Fix Windows archives extraction issue (#689) --- dist/cleanup/index.js | 13 +++- dist/setup/index.js | 90 ++++++++++++++--------- package-lock.json | 8 +- src/distributions/adopt/installer.ts | 9 ++- src/distributions/corretto/installer.ts | 15 ++-- src/distributions/dragonwell/installer.ts | 15 ++-- src/distributions/graalvm/installer.ts | 9 ++- src/distributions/liberica/installer.ts | 12 +-- src/distributions/microsoft/installer.ts | 19 ++--- src/distributions/oracle/installer.ts | 12 ++- src/distributions/sapmachine/installer.ts | 15 ++-- src/distributions/semeru/installer.ts | 9 ++- src/distributions/temurin/installer.ts | 9 ++- src/distributions/zulu/installer.ts | 12 +-- src/util.ts | 11 +++ 15 files changed, 154 insertions(+), 104 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index f35edb9d..5a200909 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -88470,7 +88470,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getGitHubHttpHeaders = exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; +exports.renameWinArchive = exports.getGitHubHttpHeaders = exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; const os_1 = __importDefault(__nccwpck_require__(2037)); const path_1 = __importDefault(__nccwpck_require__(1017)); const fs = __importStar(__nccwpck_require__(7147)); @@ -88630,6 +88630,17 @@ function getGitHubHttpHeaders() { return headers; } exports.getGitHubHttpHeaders = getGitHubHttpHeaders; +// Rename archive to add extension because after downloading +// archive does not contain extension type and it leads to some issues +// on Windows runners without PowerShell Core. +// +// For default PowerShell Windows it should contain extension type to unpack it. +function renameWinArchive(javaArchivePath) { + const javaArchivePathRenamed = `${javaArchivePath}.zip`; + fs.renameSync(javaArchivePath, javaArchivePathRenamed); + return javaArchivePathRenamed; +} +exports.renameWinArchive = renameWinArchive; /***/ }), diff --git a/dist/setup/index.js b/dist/setup/index.js index 6dd09d3a..e96bb125 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -123578,9 +123578,12 @@ class AdoptDistribution extends base_installer_1.JavaBase { downloadTool(javaRelease) { return __awaiter(this, void 0, void 0, function* () { core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); + let javaArchivePath = yield tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = (0, util_1.getDownloadArchiveExtension)(); + if (process.platform === 'win32') { + javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath); + } const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archivePath = path_1.default.join(extractedJavaPath, archiveName); @@ -123914,9 +123917,13 @@ class CorrettoDistribution extends base_installer_1.JavaBase { downloadTool(javaRelease) { return __awaiter(this, void 0, void 0, function* () { core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); + let javaArchivePath = yield tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); - const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, (0, util_1.getDownloadArchiveExtension)()); + const extension = (0, util_1.getDownloadArchiveExtension)(); + if (process.platform === 'win32') { + javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath); + } + const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archivePath = path_1.default.join(extractedJavaPath, archiveName); const version = this.getToolcacheVersionName(javaRelease.version); @@ -124209,9 +124216,13 @@ class DragonwellDistribution extends base_installer_1.JavaBase { downloadTool(javaRelease) { return __awaiter(this, void 0, void 0, function* () { core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); + let javaArchivePath = yield tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); - const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, (0, util_1.getDownloadArchiveExtension)()); + const extension = (0, util_1.getDownloadArchiveExtension)(); + if (process.platform === 'win32') { + javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath); + } + const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archivePath = path_1.default.join(extractedJavaPath, archiveName); const version = this.getToolcacheVersionName(javaRelease.version); @@ -124375,9 +124386,12 @@ class GraalVMDistribution extends base_installer_1.JavaBase { downloadTool(javaRelease) { return __awaiter(this, void 0, void 0, function* () { core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); + let javaArchivePath = yield tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = (0, util_1.getDownloadArchiveExtension)(); + if (process.platform === 'win32') { + javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath); + } const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archivePath = path_1.default.join(extractedJavaPath, archiveName); @@ -124543,11 +124557,8 @@ class LibericaDistributions extends base_installer_1.JavaBase { let javaArchivePath = yield tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = (0, util_1.getDownloadArchiveExtension)(); - if (process.platform === 'win32' && - (this.architecture === 'arm64' || this.architecture === 'aarch64')) { - const javaArchivePathRenamed = `${javaArchivePath}.zip`; - yield fs_1.default.renameSync(javaArchivePath, javaArchivePathRenamed); - javaArchivePath = javaArchivePathRenamed; + if (process.platform === 'win32') { + javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath); } const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; @@ -124829,19 +124840,11 @@ class MicrosoftDistributions extends base_installer_1.JavaBase { return __awaiter(this, void 0, void 0, function* () { core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); let javaArchivePath = yield tc.downloadTool(javaRelease.url); - // Rename archive to add extension because after downloading - // archive does not contain extension type and it leads to some issues - // on Windows runners without PowerShell Core. - // - // For default PowerShell Windows it should contain extension type to unpack it. - if (process.platform === 'win32' && - (this.architecture === 'arm64' || this.architecture === 'aarch64')) { - const javaArchivePathRenamed = `${javaArchivePath}.zip`; - yield fs_1.default.renameSync(javaArchivePath, javaArchivePathRenamed); - javaArchivePath = javaArchivePathRenamed; - } core.info(`Extracting Java archive...`); const extension = (0, util_1.getDownloadArchiveExtension)(); + if (process.platform === 'win32') { + javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath); + } const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archivePath = path_1.default.join(extractedJavaPath, archiveName); @@ -124978,9 +124981,12 @@ class OracleDistribution extends base_installer_1.JavaBase { downloadTool(javaRelease) { return __awaiter(this, void 0, void 0, function* () { core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); + let javaArchivePath = yield tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = (0, util_1.getDownloadArchiveExtension)(); + if (process.platform === 'win32') { + javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath); + } const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archivePath = path_1.default.join(extractedJavaPath, archiveName); @@ -125151,9 +125157,13 @@ class SapMachineDistribution extends base_installer_1.JavaBase { downloadTool(javaRelease) { return __awaiter(this, void 0, void 0, function* () { core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); + let javaArchivePath = yield tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); - const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, (0, util_1.getDownloadArchiveExtension)()); + const extension = (0, util_1.getDownloadArchiveExtension)(); + if (process.platform === 'win32') { + javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath); + } + const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archivePath = path_1.default.join(extractedJavaPath, archiveName); const version = this.getToolcacheVersionName(javaRelease.version); @@ -125370,9 +125380,12 @@ class SemeruDistribution extends base_installer_1.JavaBase { downloadTool(javaRelease) { return __awaiter(this, void 0, void 0, function* () { core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); + let javaArchivePath = yield tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = (0, util_1.getDownloadArchiveExtension)(); + if (process.platform === 'win32') { + javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath); + } const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archivePath = path_1.default.join(extractedJavaPath, archiveName); @@ -125546,9 +125559,12 @@ class TemurinDistribution extends base_installer_1.JavaBase { downloadTool(javaRelease) { return __awaiter(this, void 0, void 0, function* () { core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); + let javaArchivePath = yield tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = (0, util_1.getDownloadArchiveExtension)(); + if (process.platform === 'win32') { + javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath); + } const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archivePath = path_1.default.join(extractedJavaPath, archiveName); @@ -125724,11 +125740,8 @@ class ZuluDistribution extends base_installer_1.JavaBase { let javaArchivePath = yield tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = (0, util_1.getDownloadArchiveExtension)(); - if (process.platform === 'win32' && - (this.architecture === 'arm64' || this.architecture === 'aarch64')) { - const javaArchivePathRenamed = `${javaArchivePath}.zip`; - yield fs_1.default.renameSync(javaArchivePath, javaArchivePathRenamed); - javaArchivePath = javaArchivePathRenamed; + if (process.platform === 'win32') { + javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath); } const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; @@ -126233,7 +126246,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getGitHubHttpHeaders = exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; +exports.renameWinArchive = exports.getGitHubHttpHeaders = exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; const os_1 = __importDefault(__nccwpck_require__(22037)); const path_1 = __importDefault(__nccwpck_require__(71017)); const fs = __importStar(__nccwpck_require__(57147)); @@ -126393,6 +126406,17 @@ function getGitHubHttpHeaders() { return headers; } exports.getGitHubHttpHeaders = getGitHubHttpHeaders; +// Rename archive to add extension because after downloading +// archive does not contain extension type and it leads to some issues +// on Windows runners without PowerShell Core. +// +// For default PowerShell Windows it should contain extension type to unpack it. +function renameWinArchive(javaArchivePath) { + const javaArchivePathRenamed = `${javaArchivePath}.zip`; + fs.renameSync(javaArchivePath, javaArchivePathRenamed); + return javaArchivePathRenamed; +} +exports.renameWinArchive = renameWinArchive; /***/ }), diff --git a/package-lock.json b/package-lock.json index cb1af442..0f806bc3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4322,12 +4322,12 @@ } }, "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "dependencies": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": { diff --git a/src/distributions/adopt/installer.ts b/src/distributions/adopt/installer.ts index 9887b789..850a4a0d 100644 --- a/src/distributions/adopt/installer.ts +++ b/src/distributions/adopt/installer.ts @@ -15,7 +15,8 @@ import { import { extractJdkFile, getDownloadArchiveExtension, - isVersionSatisfies + isVersionSatisfies, + renameWinArchive } from '../../util'; export enum AdoptImplementation { @@ -73,11 +74,13 @@ export class AdoptDistribution extends JavaBase { core.info( `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` ); - const javaArchivePath = await tc.downloadTool(javaRelease.url); + let javaArchivePath = await tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = getDownloadArchiveExtension(); - + if (process.platform === 'win32') { + javaArchivePath = renameWinArchive(javaArchivePath); + } const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const archiveName = fs.readdirSync(extractedJavaPath)[0]; diff --git a/src/distributions/corretto/installer.ts b/src/distributions/corretto/installer.ts index bc073edd..c2cc5f7c 100644 --- a/src/distributions/corretto/installer.ts +++ b/src/distributions/corretto/installer.ts @@ -5,7 +5,8 @@ import path from 'path'; import { extractJdkFile, getDownloadArchiveExtension, - convertVersionToSemver + convertVersionToSemver, + renameWinArchive } from '../../util'; import {JavaBase} from '../base-installer'; import { @@ -29,14 +30,14 @@ export class CorrettoDistribution extends JavaBase { core.info( `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` ); - const javaArchivePath = await tc.downloadTool(javaRelease.url); + let javaArchivePath = await tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); - - const extractedJavaPath = await extractJdkFile( - javaArchivePath, - getDownloadArchiveExtension() - ); + const extension = getDownloadArchiveExtension(); + if (process.platform === 'win32') { + javaArchivePath = renameWinArchive(javaArchivePath); + } + const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const archiveName = fs.readdirSync(extractedJavaPath)[0]; const archivePath = path.join(extractedJavaPath, archiveName); diff --git a/src/distributions/dragonwell/installer.ts b/src/distributions/dragonwell/installer.ts index 3e847577..480cdbdc 100644 --- a/src/distributions/dragonwell/installer.ts +++ b/src/distributions/dragonwell/installer.ts @@ -11,7 +11,8 @@ import { extractJdkFile, getDownloadArchiveExtension, getGitHubHttpHeaders, - isVersionSatisfies + isVersionSatisfies, + renameWinArchive } from '../../util'; import {IDragonwellVersions, IDragonwellAllVersions} from './models'; import { @@ -100,14 +101,14 @@ export class DragonwellDistribution extends JavaBase { core.info( `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` ); - const javaArchivePath = await tc.downloadTool(javaRelease.url); + let javaArchivePath = await tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); - - const extractedJavaPath = await extractJdkFile( - javaArchivePath, - getDownloadArchiveExtension() - ); + const extension = getDownloadArchiveExtension(); + if (process.platform === 'win32') { + javaArchivePath = renameWinArchive(javaArchivePath); + } + const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const archiveName = fs.readdirSync(extractedJavaPath)[0]; const archivePath = path.join(extractedJavaPath, archiveName); diff --git a/src/distributions/graalvm/installer.ts b/src/distributions/graalvm/installer.ts index 37dbe322..be14cee9 100644 --- a/src/distributions/graalvm/installer.ts +++ b/src/distributions/graalvm/installer.ts @@ -13,7 +13,8 @@ import { import { extractJdkFile, getDownloadArchiveExtension, - getGitHubHttpHeaders + getGitHubHttpHeaders, + renameWinArchive } from '../../util'; import {HttpCodes} from '@actions/http-client'; import {GraalVMEAVersion} from './models'; @@ -33,11 +34,13 @@ export class GraalVMDistribution extends JavaBase { core.info( `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` ); - const javaArchivePath = await tc.downloadTool(javaRelease.url); + let javaArchivePath = await tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = getDownloadArchiveExtension(); - + if (process.platform === 'win32') { + javaArchivePath = renameWinArchive(javaArchivePath); + } const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const archiveName = fs.readdirSync(extractedJavaPath)[0]; diff --git a/src/distributions/liberica/installer.ts b/src/distributions/liberica/installer.ts index 3ed9435a..444c46ce 100644 --- a/src/distributions/liberica/installer.ts +++ b/src/distributions/liberica/installer.ts @@ -8,7 +8,8 @@ import semver from 'semver'; import { extractJdkFile, getDownloadArchiveExtension, - isVersionSatisfies + isVersionSatisfies, + renameWinArchive } from '../../util'; import * as core from '@actions/core'; import {ArchitectureOptions, LibericaVersion, OsVersions} from './models'; @@ -35,13 +36,8 @@ export class LibericaDistributions extends JavaBase { core.info(`Extracting Java archive...`); const extension = getDownloadArchiveExtension(); - if ( - process.platform === 'win32' && - (this.architecture === 'arm64' || this.architecture === 'aarch64') - ) { - const javaArchivePathRenamed = `${javaArchivePath}.zip`; - await fs.renameSync(javaArchivePath, javaArchivePathRenamed); - javaArchivePath = javaArchivePathRenamed; + if (process.platform === 'win32') { + javaArchivePath = renameWinArchive(javaArchivePath); } const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); diff --git a/src/distributions/microsoft/installer.ts b/src/distributions/microsoft/installer.ts index d20e55da..63c5b0d2 100644 --- a/src/distributions/microsoft/installer.ts +++ b/src/distributions/microsoft/installer.ts @@ -7,7 +7,8 @@ import { import { extractJdkFile, getDownloadArchiveExtension, - getGitHubHttpHeaders + getGitHubHttpHeaders, + renameWinArchive } from '../../util'; import * as core from '@actions/core'; import * as tc from '@actions/tool-cache'; @@ -27,22 +28,12 @@ export class MicrosoftDistributions extends JavaBase { `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` ); let javaArchivePath = await tc.downloadTool(javaRelease.url); - // Rename archive to add extension because after downloading - // archive does not contain extension type and it leads to some issues - // on Windows runners without PowerShell Core. - // - // For default PowerShell Windows it should contain extension type to unpack it. - if ( - process.platform === 'win32' && - (this.architecture === 'arm64' || this.architecture === 'aarch64') - ) { - const javaArchivePathRenamed = `${javaArchivePath}.zip`; - await fs.renameSync(javaArchivePath, javaArchivePathRenamed); - javaArchivePath = javaArchivePathRenamed; - } core.info(`Extracting Java archive...`); const extension = getDownloadArchiveExtension(); + if (process.platform === 'win32') { + javaArchivePath = renameWinArchive(javaArchivePath); + } const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const archiveName = fs.readdirSync(extractedJavaPath)[0]; diff --git a/src/distributions/oracle/installer.ts b/src/distributions/oracle/installer.ts index ec0ab215..5a492ad1 100644 --- a/src/distributions/oracle/installer.ts +++ b/src/distributions/oracle/installer.ts @@ -10,7 +10,11 @@ import { JavaInstallerOptions, JavaInstallerResults } from '../base-models'; -import {extractJdkFile, getDownloadArchiveExtension} from '../../util'; +import { + extractJdkFile, + getDownloadArchiveExtension, + renameWinArchive +} from '../../util'; import {HttpCodes} from '@actions/http-client'; const ORACLE_DL_BASE = 'https://download.oracle.com/java'; @@ -26,11 +30,13 @@ export class OracleDistribution extends JavaBase { core.info( `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` ); - const javaArchivePath = await tc.downloadTool(javaRelease.url); + let javaArchivePath = await tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = getDownloadArchiveExtension(); - + if (process.platform === 'win32') { + javaArchivePath = renameWinArchive(javaArchivePath); + } const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const archiveName = fs.readdirSync(extractedJavaPath)[0]; diff --git a/src/distributions/sapmachine/installer.ts b/src/distributions/sapmachine/installer.ts index 8bce553c..dfe32e16 100644 --- a/src/distributions/sapmachine/installer.ts +++ b/src/distributions/sapmachine/installer.ts @@ -9,7 +9,8 @@ import { extractJdkFile, getDownloadArchiveExtension, getGitHubHttpHeaders, - isVersionSatisfies + isVersionSatisfies, + renameWinArchive } from '../../util'; import {JavaBase} from '../base-installer'; import { @@ -104,14 +105,14 @@ export class SapMachineDistribution extends JavaBase { core.info( `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` ); - const javaArchivePath = await tc.downloadTool(javaRelease.url); + let javaArchivePath = await tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); - - const extractedJavaPath = await extractJdkFile( - javaArchivePath, - getDownloadArchiveExtension() - ); + const extension = getDownloadArchiveExtension(); + if (process.platform === 'win32') { + javaArchivePath = renameWinArchive(javaArchivePath); + } + const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const archiveName = fs.readdirSync(extractedJavaPath)[0]; const archivePath = path.join(extractedJavaPath, archiveName); diff --git a/src/distributions/semeru/installer.ts b/src/distributions/semeru/installer.ts index 5e3e2faf..e66708ec 100644 --- a/src/distributions/semeru/installer.ts +++ b/src/distributions/semeru/installer.ts @@ -8,7 +8,8 @@ import semver from 'semver'; import { extractJdkFile, getDownloadArchiveExtension, - isVersionSatisfies + isVersionSatisfies, + renameWinArchive } from '../../util'; import * as core from '@actions/core'; import * as tc from '@actions/tool-cache'; @@ -98,11 +99,13 @@ export class SemeruDistribution extends JavaBase { core.info( `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` ); - const javaArchivePath = await tc.downloadTool(javaRelease.url); + let javaArchivePath = await tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = getDownloadArchiveExtension(); - + if (process.platform === 'win32') { + javaArchivePath = renameWinArchive(javaArchivePath); + } const extractedJavaPath: string = await extractJdkFile( javaArchivePath, extension diff --git a/src/distributions/temurin/installer.ts b/src/distributions/temurin/installer.ts index 4a1989bc..1a69652a 100644 --- a/src/distributions/temurin/installer.ts +++ b/src/distributions/temurin/installer.ts @@ -15,7 +15,8 @@ import { import { extractJdkFile, getDownloadArchiveExtension, - isVersionSatisfies + isVersionSatisfies, + renameWinArchive } from '../../util'; export enum TemurinImplementation { @@ -76,11 +77,13 @@ export class TemurinDistribution extends JavaBase { core.info( `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` ); - const javaArchivePath = await tc.downloadTool(javaRelease.url); + let javaArchivePath = await tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = getDownloadArchiveExtension(); - + if (process.platform === 'win32') { + javaArchivePath = renameWinArchive(javaArchivePath); + } const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const archiveName = fs.readdirSync(extractedJavaPath)[0]; diff --git a/src/distributions/zulu/installer.ts b/src/distributions/zulu/installer.ts index e406c6b6..124789b8 100644 --- a/src/distributions/zulu/installer.ts +++ b/src/distributions/zulu/installer.ts @@ -11,7 +11,8 @@ import { extractJdkFile, getDownloadArchiveExtension, convertVersionToSemver, - isVersionSatisfies + isVersionSatisfies, + renameWinArchive } from '../../util'; import { JavaDownloadRelease, @@ -80,13 +81,8 @@ export class ZuluDistribution extends JavaBase { core.info(`Extracting Java archive...`); const extension = getDownloadArchiveExtension(); - if ( - process.platform === 'win32' && - (this.architecture === 'arm64' || this.architecture === 'aarch64') - ) { - const javaArchivePathRenamed = `${javaArchivePath}.zip`; - await fs.renameSync(javaArchivePath, javaArchivePathRenamed); - javaArchivePath = javaArchivePathRenamed; + if (process.platform === 'win32') { + javaArchivePath = renameWinArchive(javaArchivePath); } const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); diff --git a/src/util.ts b/src/util.ts index 034fc83d..c0166ef1 100644 --- a/src/util.ts +++ b/src/util.ts @@ -190,3 +190,14 @@ export function getGitHubHttpHeaders(): OutgoingHttpHeaders { } return headers; } + +// Rename archive to add extension because after downloading +// archive does not contain extension type and it leads to some issues +// on Windows runners without PowerShell Core. +// +// For default PowerShell Windows it should contain extension type to unpack it. +export function renameWinArchive(javaArchivePath: string): string { + const javaArchivePathRenamed = `${javaArchivePath}.zip`; + fs.renameSync(javaArchivePath, javaArchivePathRenamed); + return javaArchivePathRenamed; +} From 870c199c48d3d764226001e5f61002b15289795e Mon Sep 17 00:00:00 2001 From: mahabaleshwars <147705296+mahabaleshwars@users.noreply.github.com> Date: Mon, 21 Oct 2024 22:13:20 +0530 Subject: [PATCH 2/4] Update workflows for GraalVM and Version Enhancements (#699) * workflow update graalvm version * updated workflow for publish action version update --- .github/workflows/e2e-versions.yml | 2 +- .github/workflows/release-new-action-version.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml index 045dee15..bdf85d14 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -51,7 +51,7 @@ jobs: version: 21 - distribution: graalvm os: macos-latest - version: 17 + version: 17.0.12 - distribution: graalvm os: windows-latest version: 21 diff --git a/.github/workflows/release-new-action-version.yml b/.github/workflows/release-new-action-version.yml index e584e46f..e58e9063 100644 --- a/.github/workflows/release-new-action-version.yml +++ b/.github/workflows/release-new-action-version.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Update the ${{ env.TAG_NAME }} tag id: update-major-tag - uses: actions/publish-action@v0.2.2 + uses: actions/publish-action@v0.3.0 with: source-tag: ${{ env.TAG_NAME }} slack-webhook: ${{ secrets.SLACK_WEBHOOK }} From 8df1039502a15bceb9433410b1a100fbe190c53b Mon Sep 17 00:00:00 2001 From: John Wesley Walker III <81404201+jww3@users.noreply.github.com> Date: Mon, 21 Oct 2024 19:57:52 +0200 Subject: [PATCH 3/4] Refine `isGhes` logic (#697) --- __tests__/util.test.ts | 41 ++++++++++++++++++++++++++++++++++++++++- dist/cleanup/index.js | 6 +++++- dist/setup/index.js | 6 +++++- src/util.ts | 8 +++++++- 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/__tests__/util.test.ts b/__tests__/util.test.ts index bb7560dc..9c943c2f 100644 --- a/__tests__/util.test.ts +++ b/__tests__/util.test.ts @@ -3,7 +3,8 @@ import * as core from '@actions/core'; import { convertVersionToSemver, isVersionSatisfies, - isCacheFeatureAvailable + isCacheFeatureAvailable, + isGhes } from '../src/util'; jest.mock('@actions/cache'); @@ -80,3 +81,41 @@ describe('convertVersionToSemver', () => { expect(actual).toBe(expected); }); }); + +describe('isGhes', () => { + const pristineEnv = process.env; + + beforeEach(() => { + jest.resetModules(); + process.env = {...pristineEnv}; + }); + + afterAll(() => { + process.env = pristineEnv; + }); + + it('returns false when the GITHUB_SERVER_URL environment variable is not defined', async () => { + delete process.env['GITHUB_SERVER_URL']; + expect(isGhes()).toBeFalsy(); + }); + + it('returns false when the GITHUB_SERVER_URL environment variable is set to github.com', async () => { + process.env['GITHUB_SERVER_URL'] = 'https://github.com'; + expect(isGhes()).toBeFalsy(); + }); + + it('returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL', async () => { + process.env['GITHUB_SERVER_URL'] = 'https://contoso.ghe.com'; + expect(isGhes()).toBeFalsy(); + }); + + it('returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix', async () => { + process.env['GITHUB_SERVER_URL'] = 'https://mock-github.localhost'; + expect(isGhes()).toBeFalsy(); + }); + + it('returns true when the GITHUB_SERVER_URL environment variable is set to some other URL', async () => { + process.env['GITHUB_SERVER_URL'] = 'https://src.onpremise.fabrikam.com'; + expect(isGhes()).toBeTruthy(); + }); +}); diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 5a200909..6c44aa45 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -88552,7 +88552,11 @@ function isJobStatusSuccess() { exports.isJobStatusSuccess = isJobStatusSuccess; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; + const hostname = ghUrl.hostname.trimEnd().toUpperCase(); + const isGitHubHost = hostname === 'GITHUB.COM'; + const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); + const isLocalHost = hostname.endsWith('.LOCALHOST'); + return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isCacheFeatureAvailable() { diff --git a/dist/setup/index.js b/dist/setup/index.js index e96bb125..9dc658d8 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -126328,7 +126328,11 @@ function isJobStatusSuccess() { exports.isJobStatusSuccess = isJobStatusSuccess; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; + const hostname = ghUrl.hostname.trimEnd().toUpperCase(); + const isGitHubHost = hostname === 'GITHUB.COM'; + const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); + const isLocalHost = hostname.endsWith('.LOCALHOST'); + return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isCacheFeatureAvailable() { diff --git a/src/util.ts b/src/util.ts index c0166ef1..af75aaac 100644 --- a/src/util.ts +++ b/src/util.ts @@ -92,7 +92,13 @@ export function isGhes(): boolean { const ghUrl = new URL( process.env['GITHUB_SERVER_URL'] || 'https://github.com' ); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; + + const hostname = ghUrl.hostname.trimEnd().toUpperCase(); + const isGitHubHost = hostname === 'GITHUB.COM'; + const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); + const isLocalHost = hostname.endsWith('.LOCALHOST'); + + return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } export function isCacheFeatureAvailable(): boolean { From 7136edc5e8145b3c0b6bae8f4e62706c74e76538 Mon Sep 17 00:00:00 2001 From: mahabaleshwars <147705296+mahabaleshwars@users.noreply.github.com> Date: Wed, 11 Dec 2024 09:34:58 +0530 Subject: [PATCH 4/4] Fix sbt and x86 CI failures on Ubuntu-24 (#693) * updated workflows with ubuntu 24.04 runner * added workflow_dispatch to test workflows * updated workflow to ubnutu 22.04 * Updated workflows for PR * workflows updated to ubuntu-latest * Audit fixes --- .github/workflows/e2e-cache.yml | 4 ++-- .github/workflows/e2e-versions.yml | 2 +- package-lock.json | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e-cache.yml b/.github/workflows/e2e-cache.yml index 95031dbb..bc685ec0 100644 --- a/.github/workflows/e2e-cache.yml +++ b/.github/workflows/e2e-cache.yml @@ -121,7 +121,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-13, windows-latest, ubuntu-latest] + os: [macos-13, windows-latest, ubuntu-22.04] steps: - name: Checkout uses: actions/checkout@v4 @@ -170,7 +170,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-13, windows-latest, ubuntu-latest] + os: [macos-13, windows-latest, ubuntu-22.04] needs: sbt-save steps: - name: Checkout diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml index bdf85d14..d80b1c07 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -305,7 +305,7 @@ jobs: fail-fast: false matrix: # x86 is not supported on macOS - os: [windows-latest, ubuntu-latest] + os: [windows-latest, ubuntu-22.04] distribution: ['liberica', 'zulu', 'corretto'] version: ['11'] steps: diff --git a/package-lock.json b/package-lock.json index 0f806bc3..fd4dfc6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2495,10 +2495,11 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, + "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0",