mirror of
https://code.forgejo.org/actions/setup-go
synced 2025-06-14 14:24:11 +02:00
Move condition to the installer
This commit is contained in:
parent
18c62c8dd3
commit
17fabf6bf1
5 changed files with 36 additions and 21 deletions
|
@ -702,7 +702,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
findSpy.mockImplementation(() => '');
|
findSpy.mockImplementation(() => '');
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
const toolPath = path.normalize('/cache/go/1.17.5/x64');
|
const toolPath = path.normalize('/cache/go/1.17.6/x64');
|
||||||
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
@ -722,7 +722,7 @@ describe('setup-go', () => {
|
||||||
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
|
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
|
||||||
expect(logSpy).toHaveBeenCalledWith('Added go to the path');
|
expect(logSpy).toHaveBeenCalledWith('Added go to the path');
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
`Successfully set up Go version ${versionSpec}`
|
`Successfully set up Go version ${patchVersion}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
17
dist/setup/index.js
vendored
17
dist/setup/index.js
vendored
|
@ -63237,6 +63237,10 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch(), manif
|
||||||
core.info(`Failed to resolve version ${versionSpec} from manifest`);
|
core.info(`Failed to resolve version ${versionSpec} from manifest`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (versionSpec === utils_1.StableReleaseAlias.Stable ||
|
||||||
|
versionSpec === utils_1.StableReleaseAlias.OldStable) {
|
||||||
|
versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch, manifest);
|
||||||
|
}
|
||||||
// check cache
|
// check cache
|
||||||
let toolPath;
|
let toolPath;
|
||||||
toolPath = tc.find('go', versionSpec, arch);
|
toolPath = tc.find('go', versionSpec, arch);
|
||||||
|
@ -63559,11 +63563,13 @@ function run() {
|
||||||
let auth = !token ? undefined : `token ${token}`;
|
let auth = !token ? undefined : `token ${token}`;
|
||||||
const manifest = yield installer.getManifest(auth);
|
const manifest = yield installer.getManifest(auth);
|
||||||
const checkLatest = core.getBooleanInput('check-latest');
|
const checkLatest = core.getBooleanInput('check-latest');
|
||||||
if (versionSpec === utils_1.StableReleaseAlias.Stable ||
|
|
||||||
versionSpec === utils_1.StableReleaseAlias.OldStable) {
|
|
||||||
versionSpec = yield installer.resolveStableVersionInput(versionSpec, auth, arch, manifest);
|
|
||||||
}
|
|
||||||
const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch, manifest);
|
const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch, manifest);
|
||||||
|
if (utils_1.IS_WINDOWS) {
|
||||||
|
versionSpec = installDir.split('\\').reverse()[1];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
versionSpec = installDir.split('/').reverse()[1];
|
||||||
|
}
|
||||||
core.addPath(path_1.default.join(installDir, 'bin'));
|
core.addPath(path_1.default.join(installDir, 'bin'));
|
||||||
core.info('Added go to the path');
|
core.info('Added go to the path');
|
||||||
const version = installer.makeSemver(versionSpec);
|
const version = installer.makeSemver(versionSpec);
|
||||||
|
@ -63727,12 +63733,13 @@ exports.getArch = getArch;
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.StableReleaseAlias = void 0;
|
exports.IS_WINDOWS = exports.StableReleaseAlias = void 0;
|
||||||
var StableReleaseAlias;
|
var StableReleaseAlias;
|
||||||
(function (StableReleaseAlias) {
|
(function (StableReleaseAlias) {
|
||||||
StableReleaseAlias["Stable"] = "stable";
|
StableReleaseAlias["Stable"] = "stable";
|
||||||
StableReleaseAlias["OldStable"] = "oldstable";
|
StableReleaseAlias["OldStable"] = "oldstable";
|
||||||
})(StableReleaseAlias = exports.StableReleaseAlias || (exports.StableReleaseAlias = {}));
|
})(StableReleaseAlias = exports.StableReleaseAlias || (exports.StableReleaseAlias = {}));
|
||||||
|
exports.IS_WINDOWS = process.platform === 'win32';
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
|
@ -5,7 +5,7 @@ import * as semver from 'semver';
|
||||||
import * as httpm from '@actions/http-client';
|
import * as httpm from '@actions/http-client';
|
||||||
import * as sys from './system';
|
import * as sys from './system';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os, {arch} from 'os';
|
import os from 'os';
|
||||||
import {StableReleaseAlias} from './utils';
|
import {StableReleaseAlias} from './utils';
|
||||||
|
|
||||||
type InstallationType = 'dist' | 'manifest';
|
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
|
// check cache
|
||||||
let toolPath: string;
|
let toolPath: string;
|
||||||
toolPath = tc.find('go', versionSpec, arch);
|
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 cp from 'child_process';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import {StableReleaseAlias} from './utils';
|
import {IS_WINDOWS} from './utils';
|
||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
try {
|
try {
|
||||||
|
@ -35,18 +35,6 @@ export async function run() {
|
||||||
|
|
||||||
const checkLatest = core.getBooleanInput('check-latest');
|
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(
|
const installDir = await installer.getGo(
|
||||||
versionSpec,
|
versionSpec,
|
||||||
checkLatest,
|
checkLatest,
|
||||||
|
@ -55,6 +43,12 @@ export async function run() {
|
||||||
manifest
|
manifest
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
versionSpec = installDir.split('\\').reverse()[1];
|
||||||
|
} else {
|
||||||
|
versionSpec = installDir.split('/').reverse()[1];
|
||||||
|
}
|
||||||
|
|
||||||
core.addPath(path.join(installDir, 'bin'));
|
core.addPath(path.join(installDir, 'bin'));
|
||||||
core.info('Added go to the path');
|
core.info('Added go to the path');
|
||||||
|
|
||||||
|
|
|
@ -2,3 +2,5 @@ export enum StableReleaseAlias {
|
||||||
Stable = 'stable',
|
Stable = 'stable',
|
||||||
OldStable = 'oldstable'
|
OldStable = 'oldstable'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const IS_WINDOWS = process.platform === 'win32';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue