mirror of
https://github.com/actions/setup-go.git
synced 2025-06-30 05:03:43 +00:00
more .x handling
This commit is contained in:
parent
79642a476b
commit
1d577b5f50
3 changed files with 84 additions and 14 deletions
|
@ -44,7 +44,10 @@ if (!tempDirectory) {
|
|||
}
|
||||
function getGo(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
version = yield determineVersion(version);
|
||||
const selected = yield determineVersion(version);
|
||||
if (selected) {
|
||||
version = selected;
|
||||
}
|
||||
// check cache
|
||||
let toolPath;
|
||||
toolPath = tc.find('go', normalizeVersion(version));
|
||||
|
@ -129,7 +132,7 @@ function normalizeVersion(version) {
|
|||
//append minor and patch version if not available
|
||||
return version.concat('.0.0');
|
||||
}
|
||||
else if (versionPart[2] == null) {
|
||||
else {
|
||||
// handle beta and rc: 1.10beta1 => 1.10.0-beta1, 1.10rc1 => 1.10.0-rc1
|
||||
if (versionPart[1].includes('beta') || versionPart[1].includes('rc')) {
|
||||
versionPart[1] = versionPart[1]
|
||||
|
@ -137,15 +140,32 @@ function normalizeVersion(version) {
|
|||
.replace('rc', '.0-rc');
|
||||
return versionPart.join('.');
|
||||
}
|
||||
}
|
||||
if (versionPart[2] == null) {
|
||||
//append patch version if not available
|
||||
return version.concat('.0');
|
||||
}
|
||||
else {
|
||||
// handle beta and rc: 1.8.5beta1 => 1.8.5-beta1, 1.8.5rc1 => 1.8.5-rc1
|
||||
if (versionPart[2].includes('beta') || versionPart[2].includes('rc')) {
|
||||
versionPart[2] = versionPart[2]
|
||||
.replace('beta', '-beta')
|
||||
.replace('rc', '-rc');
|
||||
return versionPart.join('.');
|
||||
}
|
||||
}
|
||||
return version;
|
||||
}
|
||||
function determineVersion(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!version.endsWith('.x')) {
|
||||
return version;
|
||||
const versionPart = version.split('.');
|
||||
if (versionPart[1] == null || versionPart[2] == null) {
|
||||
return yield getLatestVersion(version.concat('.x'));
|
||||
}
|
||||
else {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
return yield getLatestVersion(version);
|
||||
});
|
||||
|
@ -157,8 +177,7 @@ function getLatestVersion(version) {
|
|||
const versions = yield getPossibleVersions(trimmedVersion);
|
||||
core.debug(`evaluating ${versions.length} versions`);
|
||||
if (version.length === 0) {
|
||||
core.debug('match not found');
|
||||
return trimmedVersion;
|
||||
throw new Error('unable to get latest version');
|
||||
}
|
||||
core.debug(`matched: ${versions[0]}`);
|
||||
return versions[0];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue