mirror of
https://github.com/actions/setup-go.git
synced 2025-12-28 17:28:17 +00:00
support go 1.26rc1
This commit is contained in:
parent
4aaadf4266
commit
389daec209
3 changed files with 79 additions and 4 deletions
|
|
@ -265,6 +265,33 @@ describe('setup-go', () => {
|
||||||
expect(fileName).toBe('go1.14rc1.linux-amd64.tar.gz');
|
expect(fileName).toBe('go1.14rc1.linux-amd64.tar.gz');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('finds unstable pre-release version using Go-style version format', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// User specifies "1.14rc1" (Go-style) instead of "1.14.0-rc.1" (semver-style)
|
||||||
|
// This should match go1.14rc1
|
||||||
|
const match: im.IGoVersion | undefined = await im.findMatch('1.14rc1');
|
||||||
|
expect(match).toBeDefined();
|
||||||
|
const version: string = match ? match.version : '';
|
||||||
|
expect(version).toBe('go1.14rc1');
|
||||||
|
const fileName = match ? match.files[0].filename : '';
|
||||||
|
expect(fileName).toBe('go1.14rc1.linux-amd64.tar.gz');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('finds latest version matching caret range with Go-style prerelease', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// spec: ^1.13beta1 should match go1.13.7 (latest 1.13.x)
|
||||||
|
const match: im.IGoVersion | undefined = await im.findMatch('^1.13beta1');
|
||||||
|
expect(match).toBeDefined();
|
||||||
|
const version: string = match ? match.version : '';
|
||||||
|
expect(version).toBe('go1.13.7');
|
||||||
|
const fileName = match ? match.files[0].filename : '';
|
||||||
|
expect(fileName).toBe('go1.13.7.linux-amd64.tar.gz');
|
||||||
|
});
|
||||||
|
|
||||||
it('evaluates to stable with input as true', async () => {
|
it('evaluates to stable with input as true', async () => {
|
||||||
inputs['go-version'] = '1.13.0';
|
inputs['go-version'] = '1.13.0';
|
||||||
inputs.stable = 'true';
|
inputs.stable = 'true';
|
||||||
|
|
|
||||||
26
dist/setup/index.js
vendored
26
dist/setup/index.js
vendored
|
|
@ -94474,6 +94474,7 @@ exports.getManifest = getManifest;
|
||||||
exports.getInfoFromManifest = getInfoFromManifest;
|
exports.getInfoFromManifest = getInfoFromManifest;
|
||||||
exports.findMatch = findMatch;
|
exports.findMatch = findMatch;
|
||||||
exports.getVersionsDist = getVersionsDist;
|
exports.getVersionsDist = getVersionsDist;
|
||||||
|
exports.normalizeVersionSpec = normalizeVersionSpec;
|
||||||
exports.makeSemver = makeSemver;
|
exports.makeSemver = makeSemver;
|
||||||
exports.parseGoVersionFile = parseGoVersionFile;
|
exports.parseGoVersionFile = parseGoVersionFile;
|
||||||
exports.resolveStableVersionInput = resolveStableVersionInput;
|
exports.resolveStableVersionInput = resolveStableVersionInput;
|
||||||
|
|
@ -94758,12 +94759,13 @@ function findMatch(versionSpec_1) {
|
||||||
if (!candidates) {
|
if (!candidates) {
|
||||||
throw new Error(`golang download url did not return results`);
|
throw new Error(`golang download url did not return results`);
|
||||||
}
|
}
|
||||||
|
const normalizedVersionSpec = normalizeVersionSpec(versionSpec);
|
||||||
let goFile;
|
let goFile;
|
||||||
for (let i = 0; i < candidates.length; i++) {
|
for (let i = 0; i < candidates.length; i++) {
|
||||||
const candidate = candidates[i];
|
const candidate = candidates[i];
|
||||||
const version = makeSemver(candidate.version);
|
const version = makeSemver(candidate.version);
|
||||||
core.debug(`check ${version} satisfies ${versionSpec}`);
|
core.debug(`check ${version} satisfies ${normalizedVersionSpec}`);
|
||||||
if (semver.satisfies(version, versionSpec)) {
|
if (semver.satisfies(version, normalizedVersionSpec)) {
|
||||||
goFile = candidate.files.find(file => {
|
goFile = candidate.files.find(file => {
|
||||||
core.debug(`${file.arch}===${archFilter} && ${file.os}===${platFilter}`);
|
core.debug(`${file.arch}===${archFilter} && ${file.os}===${platFilter}`);
|
||||||
return file.arch === archFilter && file.os === platFilter;
|
return file.arch === archFilter && file.os === platFilter;
|
||||||
|
|
@ -94794,6 +94796,26 @@ function getVersionsDist(dlUrl) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
// Normalize user-provided version spec for semver matching
|
||||||
|
// Converts Go-style prerelease versions while preserving range semantics
|
||||||
|
// 1.13 => 1.13 (preserved for range matching)
|
||||||
|
// 1.14rc1 => 1.14.0-rc.1
|
||||||
|
// ^1.14rc1 => ^1.14.0-rc.1
|
||||||
|
// ~1.14beta1 => ~1.14.0-beta.1
|
||||||
|
function normalizeVersionSpec(versionSpec) {
|
||||||
|
var _a;
|
||||||
|
const rangePrefix = ((_a = versionSpec.match(/^[~^]/)) === null || _a === void 0 ? void 0 : _a[0]) || '';
|
||||||
|
const version = versionSpec.replace(/^[~^]/, '');
|
||||||
|
// Only convert if it has Go-style prerelease (rc/beta without hyphen prefix)
|
||||||
|
const hasGoStylePrerelease = (version.includes('rc') || version.includes('beta')) &&
|
||||||
|
!version.includes('-rc.') &&
|
||||||
|
!version.includes('-beta.');
|
||||||
|
if (!hasGoStylePrerelease) {
|
||||||
|
return versionSpec;
|
||||||
|
}
|
||||||
|
return rangePrefix + makeSemver(version);
|
||||||
|
}
|
||||||
|
//
|
||||||
// Convert the go version syntax into semver for semver matching
|
// Convert the go version syntax into semver for semver matching
|
||||||
// 1.13.1 => 1.13.1
|
// 1.13.1 => 1.13.1
|
||||||
// 1.13 => 1.13.0
|
// 1.13 => 1.13.0
|
||||||
|
|
|
||||||
|
|
@ -417,13 +417,15 @@ export async function findMatch(
|
||||||
throw new Error(`golang download url did not return results`);
|
throw new Error(`golang download url did not return results`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const normalizedVersionSpec = normalizeVersionSpec(versionSpec);
|
||||||
|
|
||||||
let goFile: IGoVersionFile | undefined;
|
let goFile: IGoVersionFile | undefined;
|
||||||
for (let i = 0; i < candidates.length; i++) {
|
for (let i = 0; i < candidates.length; i++) {
|
||||||
const candidate: IGoVersion = candidates[i];
|
const candidate: IGoVersion = candidates[i];
|
||||||
const version = makeSemver(candidate.version);
|
const version = makeSemver(candidate.version);
|
||||||
|
|
||||||
core.debug(`check ${version} satisfies ${versionSpec}`);
|
core.debug(`check ${version} satisfies ${normalizedVersionSpec}`);
|
||||||
if (semver.satisfies(version, versionSpec)) {
|
if (semver.satisfies(version, normalizedVersionSpec)) {
|
||||||
goFile = candidate.files.find(file => {
|
goFile = candidate.files.find(file => {
|
||||||
core.debug(
|
core.debug(
|
||||||
`${file.arch}===${archFilter} && ${file.os}===${platFilter}`
|
`${file.arch}===${archFilter} && ${file.os}===${platFilter}`
|
||||||
|
|
@ -459,6 +461,30 @@ export async function getVersionsDist(
|
||||||
return (await http.getJson<IGoVersion[]>(dlUrl)).result;
|
return (await http.getJson<IGoVersion[]>(dlUrl)).result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize user-provided version spec for semver matching
|
||||||
|
// Converts Go-style prerelease versions while preserving range semantics
|
||||||
|
// 1.13 => 1.13 (preserved for range matching)
|
||||||
|
// 1.14rc1 => 1.14.0-rc.1
|
||||||
|
// ^1.14rc1 => ^1.14.0-rc.1
|
||||||
|
// ~1.14beta1 => ~1.14.0-beta.1
|
||||||
|
export function normalizeVersionSpec(versionSpec: string): string {
|
||||||
|
const rangePrefix = versionSpec.match(/^[~^]/)?.[0] || '';
|
||||||
|
const version = versionSpec.replace(/^[~^]/, '');
|
||||||
|
|
||||||
|
// Only convert if it has Go-style prerelease (rc/beta without hyphen prefix)
|
||||||
|
const hasGoStylePrerelease =
|
||||||
|
(version.includes('rc') || version.includes('beta')) &&
|
||||||
|
!version.includes('-rc.') &&
|
||||||
|
!version.includes('-beta.');
|
||||||
|
|
||||||
|
if (!hasGoStylePrerelease) {
|
||||||
|
return versionSpec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rangePrefix + makeSemver(version);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Convert the go version syntax into semver for semver matching
|
// Convert the go version syntax into semver for semver matching
|
||||||
// 1.13.1 => 1.13.1
|
// 1.13.1 => 1.13.1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue