Add stable and oldstable aliases

pull/299/head
panticmilos 2 years ago
parent e983b65a44
commit 546aac70e3

@ -12,6 +12,38 @@ on:
- cron: 0 0 * * * - cron: 0 0 * * *
jobs: jobs:
stable:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- name: Setup Go and check latest
uses: ./
with:
go-version: stable
architecture: x64
- name: Verify Go
run: go version
oldstable:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- name: Setup Go and check latest
uses: ./
with:
go-version: oldstable
architecture: x64
- name: Verify Go
run: go version
local-cache: local-cache:
name: Setup local-cache version name: Setup local-cache version
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}

4
.gitignore vendored

@ -89,3 +89,7 @@ typings/
# DynamoDB Local files # DynamoDB Local files
.dynamodb/ .dynamodb/
.vscode
release.txt

File diff suppressed because it is too large Load Diff

1662
dist/setup/index.js vendored

File diff suppressed because it is too large Load Diff

@ -114,7 +114,7 @@ export async function getGo(
return downloadPath; return downloadPath;
} }
async function resolveVersionFromManifest( export async function resolveVersionFromManifest(
versionSpec: string, versionSpec: string,
stable: boolean, stable: boolean,
auth: string | undefined, auth: string | undefined,
@ -188,7 +188,14 @@ export async function getInfoFromManifest(
'main' 'main'
); );
core.info(`matching ${versionSpec}...`); core.info(`matching ${versionSpec}...`);
const rel = await tc.findFromManifest(versionSpec, stable, releases, arch);
let rel: tc.IToolRelease | undefined;
if (versionSpec === 'stable') {
rel = releases[0];
} else {
rel = await tc.findFromManifest(versionSpec, stable, releases, arch);
}
if (rel && rel.files.length > 0) { if (rel && rel.files.length > 0) {
info = <IGoVersionInfo>{}; info = <IGoVersionInfo>{};

@ -15,7 +15,7 @@ export async function run() {
// versionSpec is optional. If supplied, install / use from the tool cache // versionSpec is optional. If supplied, install / use from the tool cache
// If not supplied then problem matchers will still be setup. Useful for self-hosted. // If not supplied then problem matchers will still be setup. Useful for self-hosted.
// //
const versionSpec = resolveVersionInput(); let versionSpec = resolveVersionInput();
const cache = core.getBooleanInput('cache'); const cache = core.getBooleanInput('cache');
core.info(`Setup go version spec ${versionSpec}`); core.info(`Setup go version spec ${versionSpec}`);
@ -31,6 +31,11 @@ export async function run() {
let auth = !token ? undefined : `token ${token}`; let auth = !token ? undefined : `token ${token}`;
const checkLatest = core.getBooleanInput('check-latest'); const checkLatest = core.getBooleanInput('check-latest');
if (versionSpec === 'stable' || versionSpec === 'oldstable') {
versionSpec = await resolveStableVersionInput(versionSpec, auth, arch);
}
const installDir = await installer.getGo( const installDir = await installer.getGo(
versionSpec, versionSpec,
checkLatest, checkLatest,
@ -143,3 +148,37 @@ function resolveVersionInput(): string {
return version; return version;
} }
async function resolveStableVersionInput(
versionSpec: string,
auth: string | undefined,
arch = os.arch()
): Promise<string> {
let resolvedVersion = await installer.resolveVersionFromManifest(
'stable',
true,
auth,
arch
);
core.info(`Stable version resolved as ${resolvedVersion}`);
if (versionSpec === 'oldstable') {
if (resolvedVersion) {
const minorVersion = semver.minor(resolvedVersion);
const semverExpression = `<${semver.major(
resolvedVersion
)}.${minorVersion}.0`;
resolvedVersion = await installer.resolveVersionFromManifest(
semverExpression,
true,
auth,
arch
);
core.info(`Oldstable version resolved as ${resolvedVersion}`);
}
}
return resolvedVersion ? resolvedVersion : versionSpec;
}

Loading…
Cancel
Save