Skip to content

Commit

Permalink
Fix Windows archives extraction issue (#689)
Browse files Browse the repository at this point in the history
  • Loading branch information
priyagupta108 authored Oct 10, 2024
1 parent 292cc14 commit 83a06ff
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 104 deletions.
13 changes: 12 additions & 1 deletion dist/cleanup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;


/***/ }),
Expand Down
90 changes: 57 additions & 33 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;


/***/ }),
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions src/distributions/adopt/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
import {
extractJdkFile,
getDownloadArchiveExtension,
isVersionSatisfies
isVersionSatisfies,
renameWinArchive
} from '../../util';

export enum AdoptImplementation {
Expand Down Expand Up @@ -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];
Expand Down
15 changes: 8 additions & 7 deletions src/distributions/corretto/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import path from 'path';
import {
extractJdkFile,
getDownloadArchiveExtension,
convertVersionToSemver
convertVersionToSemver,
renameWinArchive
} from '../../util';
import {JavaBase} from '../base-installer';
import {
Expand All @@ -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);
Expand Down
15 changes: 8 additions & 7 deletions src/distributions/dragonwell/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
extractJdkFile,
getDownloadArchiveExtension,
getGitHubHttpHeaders,
isVersionSatisfies
isVersionSatisfies,
renameWinArchive
} from '../../util';
import {IDragonwellVersions, IDragonwellAllVersions} from './models';
import {
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 83a06ff

Please sign in to comment.