mirror of
https://github.com/actions/setup-go.git
synced 2025-06-29 12:43:45 +00:00
Move condition to the installer
This commit is contained in:
parent
18c62c8dd3
commit
17fabf6bf1
5 changed files with 36 additions and 21 deletions
|
@ -5,7 +5,7 @@ import * as semver from 'semver';
|
|||
import * as httpm from '@actions/http-client';
|
||||
import * as sys from './system';
|
||||
import fs from 'fs';
|
||||
import os, {arch} from 'os';
|
||||
import os from 'os';
|
||||
import {StableReleaseAlias} from './utils';
|
||||
|
||||
type InstallationType = 'dist' | 'manifest';
|
||||
|
@ -56,6 +56,18 @@ export async function getGo(
|
|||
}
|
||||
}
|
||||
|
||||
if (
|
||||
versionSpec === StableReleaseAlias.Stable ||
|
||||
versionSpec === StableReleaseAlias.OldStable
|
||||
) {
|
||||
versionSpec = await resolveStableVersionInput(
|
||||
versionSpec,
|
||||
auth,
|
||||
arch,
|
||||
manifest
|
||||
);
|
||||
}
|
||||
|
||||
// check cache
|
||||
let toolPath: string;
|
||||
toolPath = tc.find('go', versionSpec, arch);
|
||||
|
|
20
src/main.ts
20
src/main.ts
|
@ -8,7 +8,7 @@ import {isCacheFeatureAvailable} from './cache-utils';
|
|||
import cp from 'child_process';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import {StableReleaseAlias} from './utils';
|
||||
import {IS_WINDOWS} from './utils';
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
|
@ -35,18 +35,6 @@ export async function run() {
|
|||
|
||||
const checkLatest = core.getBooleanInput('check-latest');
|
||||
|
||||
if (
|
||||
versionSpec === StableReleaseAlias.Stable ||
|
||||
versionSpec === StableReleaseAlias.OldStable
|
||||
) {
|
||||
versionSpec = await installer.resolveStableVersionInput(
|
||||
versionSpec,
|
||||
auth,
|
||||
arch,
|
||||
manifest
|
||||
);
|
||||
}
|
||||
|
||||
const installDir = await installer.getGo(
|
||||
versionSpec,
|
||||
checkLatest,
|
||||
|
@ -55,6 +43,12 @@ export async function run() {
|
|||
manifest
|
||||
);
|
||||
|
||||
if (IS_WINDOWS) {
|
||||
versionSpec = installDir.split('\\').reverse()[1];
|
||||
} else {
|
||||
versionSpec = installDir.split('/').reverse()[1];
|
||||
}
|
||||
|
||||
core.addPath(path.join(installDir, 'bin'));
|
||||
core.info('Added go to the path');
|
||||
|
||||
|
|
|
@ -2,3 +2,5 @@ export enum StableReleaseAlias {
|
|||
Stable = 'stable',
|
||||
OldStable = 'oldstable'
|
||||
}
|
||||
|
||||
export const IS_WINDOWS = process.platform === 'win32';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue