mirror of
https://github.com/actions/setup-go.git
synced 2025-04-24 01:50:52 +00:00
Add support for major release selection
This commit adds 'latest' version alias that resolves to the latest available release. The getPossibleVersions function filters available releases using startsWith(version), so calling getLatestVersion(version) with an empty string will return the latest release. Closes #31
This commit is contained in:
parent
9fbc767707
commit
dcc74252e8
2 changed files with 17 additions and 1 deletions
|
@ -89,6 +89,18 @@ describe('installer tests', () => {
|
|||
expect(fs.existsSync(path.join(goDir, 'bin', 'go'))).toBe(true);
|
||||
}
|
||||
}, 100000);
|
||||
|
||||
it('Acquires latest release version of go if using latest and matching version is installed', async () => {
|
||||
await installer.getGo('latest');
|
||||
const goDir = path.join(toolDir, 'go', '1.13.0', os.arch());
|
||||
|
||||
expect(fs.existsSync(`${goDir}.complete`)).toBe(true);
|
||||
if (IS_WINDOWS) {
|
||||
expect(fs.existsSync(path.join(goDir, 'bin', 'go.exe'))).toBe(true);
|
||||
} else {
|
||||
expect(fs.existsSync(path.join(goDir, 'bin', 'go'))).toBe(true);
|
||||
}
|
||||
}, 100000);
|
||||
});
|
||||
|
||||
it('Throws if no location contains correct go version', async () => {
|
||||
|
|
|
@ -167,6 +167,10 @@ function normalizeVersion(version: string): string {
|
|||
}
|
||||
|
||||
async function determineVersion(version: string): Promise<string> {
|
||||
if (version == 'latest') {
|
||||
return await getLatestVersion('');
|
||||
}
|
||||
|
||||
if (!version.endsWith('.x')) {
|
||||
const versionPart = version.split('.');
|
||||
|
||||
|
@ -188,7 +192,7 @@ async function getLatestVersion(version: string): Promise<string> {
|
|||
|
||||
core.debug(`evaluating ${versions.length} versions`);
|
||||
|
||||
if (version.length === 0) {
|
||||
if (versions.length === 0) {
|
||||
throw new Error('unable to get latest version');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue