mirror of
https://code.forgejo.org/actions/setup-go
synced 2025-06-10 20:42:22 +02:00
Add stable and oldstable aliases
This commit is contained in:
parent
e983b65a44
commit
546aac70e3
6 changed files with 1419 additions and 2042 deletions
32
.github/workflows/versions.yml
vendored
32
.github/workflows/versions.yml
vendored
|
@ -12,6 +12,38 @@ on:
|
|||
- cron: 0 0 * * *
|
||||
|
||||
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:
|
||||
name: Setup local-cache version
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -89,3 +89,7 @@ typings/
|
|||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
.vscode
|
||||
|
||||
release.txt
|
1671
dist/cache-save/index.js
vendored
1671
dist/cache-save/index.js
vendored
File diff suppressed because it is too large
Load diff
1702
dist/setup/index.js
vendored
1702
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;
|
||||
}
|
||||
|
||||
async function resolveVersionFromManifest(
|
||||
export async function resolveVersionFromManifest(
|
||||
versionSpec: string,
|
||||
stable: boolean,
|
||||
auth: string | undefined,
|
||||
|
@ -188,7 +188,14 @@ export async function getInfoFromManifest(
|
|||
'main'
|
||||
);
|
||||
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) {
|
||||
info = <IGoVersionInfo>{};
|
||||
|
|
41
src/main.ts
41
src/main.ts
|
@ -15,7 +15,7 @@ export async function run() {
|
|||
// 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.
|
||||
//
|
||||
const versionSpec = resolveVersionInput();
|
||||
let versionSpec = resolveVersionInput();
|
||||
|
||||
const cache = core.getBooleanInput('cache');
|
||||
core.info(`Setup go version spec ${versionSpec}`);
|
||||
|
@ -31,6 +31,11 @@ export async function run() {
|
|||
let auth = !token ? undefined : `token ${token}`;
|
||||
|
||||
const checkLatest = core.getBooleanInput('check-latest');
|
||||
|
||||
if (versionSpec === 'stable' || versionSpec === 'oldstable') {
|
||||
versionSpec = await resolveStableVersionInput(versionSpec, auth, arch);
|
||||
}
|
||||
|
||||
const installDir = await installer.getGo(
|
||||
versionSpec,
|
||||
checkLatest,
|
||||
|
@ -143,3 +148,37 @@ function resolveVersionInput(): string {
|
|||
|
||||
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…
Add table
Add a link
Reference in a new issue