mirror of
https://github.com/actions/setup-java.git
synced 2025-04-20 09:56:46 +00:00
update version splitter
This commit is contained in:
parent
4a04cfa3c7
commit
d0a3b38995
2 changed files with 24 additions and 37 deletions
28
dist/setup/index.js
vendored
28
dist/setup/index.js
vendored
|
@ -105044,7 +105044,6 @@ const constants = __importStar(__nccwpck_require__(9042));
|
||||||
const cache_1 = __nccwpck_require__(4810);
|
const cache_1 = __nccwpck_require__(4810);
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
const distribution_factory_1 = __nccwpck_require__(924);
|
const distribution_factory_1 = __nccwpck_require__(924);
|
||||||
const semver = __importStar(__nccwpck_require__(1383));
|
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
|
@ -105064,28 +105063,21 @@ function run() {
|
||||||
core.debug("JAVA_VERSION input is empty, looking for .java-version file");
|
core.debug("JAVA_VERSION input is empty, looking for .java-version file");
|
||||||
const versionFileName = '.java-version';
|
const versionFileName = '.java-version';
|
||||||
const contents = fs_1.default.readFileSync(versionFileName).toString().trim();
|
const contents = fs_1.default.readFileSync(versionFileName).toString().trim();
|
||||||
const semverRegExp = /(\d+\.\d+\.\d+|\d+\.\d+|\d+$)/;
|
const semverRegExp = /(\d+\.\d+\.\d+.*ea.*$|\d+\.\d+\.\d+\+\d*$|\d+\.\d+\.\d+|\d+\.\d+|\d+\-ea$|\d+$)/;
|
||||||
const version = semverRegExp.test(contents) ? RegExp.$1 : "";
|
let version = semverRegExp.test(contents) ? RegExp.$1 : "";
|
||||||
const coercedVer = semver.coerce(version);
|
let installed = false;
|
||||||
const validVer = semver.valid(coercedVer);
|
while (!installed && version != "") {
|
||||||
if (validVer === null) {
|
|
||||||
throw new Error("No version found");
|
|
||||||
}
|
|
||||||
const stringVersion = validVer;
|
|
||||||
try {
|
try {
|
||||||
yield installVersion(stringVersion);
|
yield installVersion(version);
|
||||||
|
installed = true;
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.debug(`${error.toString()}`);
|
core.debug(`${error.toString()}`);
|
||||||
const majorMinorVersion = getHigherVersion(stringVersion);
|
version = getHigherVersion(version);
|
||||||
try {
|
|
||||||
yield installVersion(majorMinorVersion);
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
|
||||||
core.debug(`${error.toString()}`);
|
|
||||||
const majorVersion = getHigherVersion(majorMinorVersion);
|
|
||||||
yield installVersion(majorVersion);
|
|
||||||
}
|
}
|
||||||
|
if (!installed) {
|
||||||
|
throw new Error("Сan't install appropriate version from .java-version file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const [index, version] of versions.entries()) {
|
for (const [index, version] of versions.entries()) {
|
||||||
|
@ -105121,7 +105113,7 @@ function run() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getHigherVersion(version) {
|
function getHigherVersion(version) {
|
||||||
return version.substring(0, version.lastIndexOf("."));
|
return version.split("-")[0] === version ? version.substring(0, version.lastIndexOf(".")) : version.split("-")[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
|
@ -31,27 +31,21 @@ async function run() {
|
||||||
core.debug("JAVA_VERSION input is empty, looking for .java-version file")
|
core.debug("JAVA_VERSION input is empty, looking for .java-version file")
|
||||||
const versionFileName = '.java-version'
|
const versionFileName = '.java-version'
|
||||||
const contents = fs.readFileSync(versionFileName).toString().trim();
|
const contents = fs.readFileSync(versionFileName).toString().trim();
|
||||||
const semverRegExp = /(\d+\.\d+\.\d+|\d+\.\d+|\d+$)/
|
const semverRegExp = /(\d+\.\d+\.\d+.*ea.*$|\d+\.\d+\.\d+\+\d*$|\d+\.\d+\.\d+|\d+\.\d+|\d+\-ea$|\d+$)/
|
||||||
const version = semverRegExp.test(contents) ? RegExp.$1 : "";
|
let version = semverRegExp.test(contents) ? RegExp.$1 : "";
|
||||||
const coercedVer = semver.coerce(version)
|
let installed = false;
|
||||||
const validVer = semver.valid(coercedVer)
|
while (!installed && version != "") {
|
||||||
if (validVer === null) {
|
|
||||||
throw new Error("No version found")
|
|
||||||
}
|
|
||||||
const stringVersion = validVer as string;
|
|
||||||
try {
|
try {
|
||||||
await installVersion(stringVersion)
|
await installVersion(version)
|
||||||
|
installed = true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.debug(`${error.toString()}`)
|
core.debug(`${error.toString()}`);
|
||||||
const majorMinorVersion = getHigherVersion(stringVersion)
|
version = getHigherVersion(version)
|
||||||
try {
|
|
||||||
await installVersion(majorMinorVersion)
|
|
||||||
} catch (error) {
|
|
||||||
core.debug(`${error.toString()}`)
|
|
||||||
const majorVersion = getHigherVersion(majorMinorVersion)
|
|
||||||
await installVersion(majorVersion)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!installed) {
|
||||||
|
throw new Error("Сan't install appropriate version from .java-version file")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [index, version] of versions.entries()) {
|
for (const [index, version] of versions.entries()) {
|
||||||
|
@ -96,8 +90,9 @@ async function run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHigherVersion(version: string) {
|
function getHigherVersion(version: string) {
|
||||||
return version.substring(0, version.lastIndexOf("."))
|
return version.split("-")[0] === version ? version.substring(0, version.lastIndexOf(".")) : version.split("-")[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue