mirror of
https://github.com/actions/setup-java.git
synced 2024-12-25 08:22:16 -05:00
Corretto toolcache folder name fix (#480)
This commit is contained in:
parent
404e5db3a1
commit
ddb82ce8a6
7 changed files with 62 additions and 49 deletions
|
@ -227,22 +227,3 @@ describe('findPackageForDownload', () => {
|
|||
).rejects.toThrow(/Could not find satisfied version for semver */);
|
||||
});
|
||||
});
|
||||
|
||||
describe('convertVersionToSemver', () => {
|
||||
it.each([
|
||||
[[12], '12'],
|
||||
[[12, 0], '12.0'],
|
||||
[[12, 0, 2], '12.0.2'],
|
||||
[[12, 0, 2, 1], '12.0.2+1'],
|
||||
[[12, 0, 2, 1, 3], '12.0.2+1']
|
||||
])('%s -> %s', (input: number[], expected: string) => {
|
||||
const distribution = new ZuluDistribution({
|
||||
version: '18',
|
||||
architecture: 'x86',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
const actual = distribution['convertVersionToSemver'](input);
|
||||
expect(actual).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import * as cache from '@actions/cache';
|
||||
import * as core from '@actions/core';
|
||||
import {isVersionSatisfies, isCacheFeatureAvailable} from '../src/util';
|
||||
import {
|
||||
convertVersionToSemver,
|
||||
isVersionSatisfies,
|
||||
isCacheFeatureAvailable
|
||||
} from '../src/util';
|
||||
|
||||
jest.mock('@actions/cache');
|
||||
jest.mock('@actions/core');
|
||||
|
@ -63,3 +67,16 @@ describe('isCacheFeatureAvailable', () => {
|
|||
expect(isCacheFeatureAvailable()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('convertVersionToSemver', () => {
|
||||
it.each([
|
||||
['12', '12'],
|
||||
['12.0', '12.0'],
|
||||
['12.0.2', '12.0.2'],
|
||||
['12.0.2.1', '12.0.2+1'],
|
||||
['12.0.2.1.0', '12.0.2+1.0']
|
||||
])('%s -> %s', (input: string, expected: string) => {
|
||||
const actual = convertVersionToSemver(input);
|
||||
expect(actual).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
|
12
dist/cleanup/index.js
vendored
12
dist/cleanup/index.js
vendored
|
@ -68786,7 +68786,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
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.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));
|
||||
|
@ -68913,6 +68913,16 @@ exports.getVersionFromFileContent = getVersionFromFileContent;
|
|||
function avoidOldNotation(content) {
|
||||
return content.startsWith('1.') ? content.substring(2) : content;
|
||||
}
|
||||
function convertVersionToSemver(version) {
|
||||
// Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1)
|
||||
const versionArray = Array.isArray(version) ? version : version.split('.');
|
||||
const mainVersion = versionArray.slice(0, 3).join('.');
|
||||
if (versionArray.length > 3) {
|
||||
return `${mainVersion}+${versionArray.slice(3).join('.')}`;
|
||||
}
|
||||
return mainVersion;
|
||||
}
|
||||
exports.convertVersionToSemver = convertVersionToSemver;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
|
27
dist/setup/index.js
vendored
27
dist/setup/index.js
vendored
|
@ -104209,7 +104209,7 @@ class CorrettoDistribution extends base_installer_1.JavaBase {
|
|||
.filter(item => item.version == version)
|
||||
.map(item => {
|
||||
return {
|
||||
version: item.correttoVersion,
|
||||
version: util_1.convertVersionToSemver(item.correttoVersion),
|
||||
url: item.downloadLink
|
||||
};
|
||||
});
|
||||
|
@ -105310,9 +105310,9 @@ class ZuluDistribution extends base_installer_1.JavaBase {
|
|||
const availableVersionsRaw = yield this.getAvailableVersions();
|
||||
const availableVersions = availableVersionsRaw.map(item => {
|
||||
return {
|
||||
version: this.convertVersionToSemver(item.jdk_version),
|
||||
version: util_1.convertVersionToSemver(item.jdk_version),
|
||||
url: item.url,
|
||||
zuluVersion: this.convertVersionToSemver(item.zulu_version)
|
||||
zuluVersion: util_1.convertVersionToSemver(item.zulu_version)
|
||||
};
|
||||
});
|
||||
const satisfiedVersions = availableVersions
|
||||
|
@ -105419,15 +105419,6 @@ class ZuluDistribution extends base_installer_1.JavaBase {
|
|||
return process.platform;
|
||||
}
|
||||
}
|
||||
// Azul API returns jdk_version as array of digits like [11, 0, 2, 1]
|
||||
convertVersionToSemver(version_array) {
|
||||
const mainVersion = version_array.slice(0, 3).join('.');
|
||||
if (version_array.length > 3) {
|
||||
// intentionally ignore more than 4 numbers because it is invalid semver
|
||||
return `${mainVersion}+${version_array[3]}`;
|
||||
}
|
||||
return mainVersion;
|
||||
}
|
||||
}
|
||||
exports.ZuluDistribution = ZuluDistribution;
|
||||
|
||||
|
@ -105843,7 +105834,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
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.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));
|
||||
|
@ -105970,6 +105961,16 @@ exports.getVersionFromFileContent = getVersionFromFileContent;
|
|||
function avoidOldNotation(content) {
|
||||
return content.startsWith('1.') ? content.substring(2) : content;
|
||||
}
|
||||
function convertVersionToSemver(version) {
|
||||
// Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1)
|
||||
const versionArray = Array.isArray(version) ? version : version.split('.');
|
||||
const mainVersion = versionArray.slice(0, 3).join('.');
|
||||
if (versionArray.length > 3) {
|
||||
return `${mainVersion}+${versionArray.slice(3).join('.')}`;
|
||||
}
|
||||
return mainVersion;
|
||||
}
|
||||
exports.convertVersionToSemver = convertVersionToSemver;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
|
|
@ -2,7 +2,11 @@ import * as core from '@actions/core';
|
|||
import * as tc from '@actions/tool-cache';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import {extractJdkFile, getDownloadArchiveExtension} from '../../util';
|
||||
import {
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
convertVersionToSemver
|
||||
} from '../../util';
|
||||
import {JavaBase} from '../base-installer';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
|
@ -62,7 +66,7 @@ export class CorrettoDistribution extends JavaBase {
|
|||
.filter(item => item.version == version)
|
||||
.map(item => {
|
||||
return {
|
||||
version: item.correttoVersion,
|
||||
version: convertVersionToSemver(item.correttoVersion),
|
||||
url: item.downloadLink
|
||||
} as JavaDownloadRelease;
|
||||
});
|
||||
|
|
|
@ -10,6 +10,7 @@ import {IZuluVersions} from './models';
|
|||
import {
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
convertVersionToSemver,
|
||||
isVersionSatisfies
|
||||
} from '../../util';
|
||||
import {
|
||||
|
@ -29,9 +30,9 @@ export class ZuluDistribution extends JavaBase {
|
|||
const availableVersionsRaw = await this.getAvailableVersions();
|
||||
const availableVersions = availableVersionsRaw.map(item => {
|
||||
return {
|
||||
version: this.convertVersionToSemver(item.jdk_version),
|
||||
version: convertVersionToSemver(item.jdk_version),
|
||||
url: item.url,
|
||||
zuluVersion: this.convertVersionToSemver(item.zulu_version)
|
||||
zuluVersion: convertVersionToSemver(item.zulu_version)
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -172,15 +173,4 @@ export class ZuluDistribution extends JavaBase {
|
|||
return process.platform;
|
||||
}
|
||||
}
|
||||
|
||||
// Azul API returns jdk_version as array of digits like [11, 0, 2, 1]
|
||||
private convertVersionToSemver(version_array: number[]) {
|
||||
const mainVersion = version_array.slice(0, 3).join('.');
|
||||
if (version_array.length > 3) {
|
||||
// intentionally ignore more than 4 numbers because it is invalid semver
|
||||
return `${mainVersion}+${version_array[3]}`;
|
||||
}
|
||||
|
||||
return mainVersion;
|
||||
}
|
||||
}
|
||||
|
|
10
src/util.ts
10
src/util.ts
|
@ -151,3 +151,13 @@ export function getVersionFromFileContent(
|
|||
function avoidOldNotation(content: string): string {
|
||||
return content.startsWith('1.') ? content.substring(2) : content;
|
||||
}
|
||||
|
||||
export function convertVersionToSemver(version: number[] | string) {
|
||||
// Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1)
|
||||
const versionArray = Array.isArray(version) ? version : version.split('.');
|
||||
const mainVersion = versionArray.slice(0, 3).join('.');
|
||||
if (versionArray.length > 3) {
|
||||
return `${mainVersion}+${versionArray.slice(3).join('.')}`;
|
||||
}
|
||||
return mainVersion;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue