diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index 8ebcde0..f10f85c 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -702,7 +702,7 @@ describe('setup-go', () => { findSpy.mockImplementation(() => ''); 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'); cacheSpy.mockImplementation(async () => toolPath); @@ -722,7 +722,7 @@ describe('setup-go', () => { expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...'); expect(logSpy).toHaveBeenCalledWith('Added go to the path'); expect(logSpy).toHaveBeenCalledWith( - `Successfully set up Go version ${versionSpec}` + `Successfully set up Go version ${patchVersion}` ); }); diff --git a/dist/setup/index.js b/dist/setup/index.js index 39dd964..12d81c8 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63237,6 +63237,10 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch(), manif 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 let toolPath; toolPath = tc.find('go', versionSpec, arch); @@ -63559,11 +63563,13 @@ function run() { let auth = !token ? undefined : `token ${token}`; const manifest = yield installer.getManifest(auth); 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); + 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.info('Added go to the path'); const version = installer.makeSemver(versionSpec); @@ -63727,12 +63733,13 @@ exports.getArch = getArch; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.StableReleaseAlias = void 0; +exports.IS_WINDOWS = exports.StableReleaseAlias = void 0; var StableReleaseAlias; (function (StableReleaseAlias) { StableReleaseAlias["Stable"] = "stable"; StableReleaseAlias["OldStable"] = "oldstable"; })(StableReleaseAlias = exports.StableReleaseAlias || (exports.StableReleaseAlias = {})); +exports.IS_WINDOWS = process.platform === 'win32'; /***/ }), diff --git a/src/installer.ts b/src/installer.ts index 2e20291..37fa6e6 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -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); diff --git a/src/main.ts b/src/main.ts index 9769a84..a5816b8 100644 --- a/src/main.ts +++ b/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'); diff --git a/src/utils.ts b/src/utils.ts index 79d03bc..6f6315c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,3 +2,5 @@ export enum StableReleaseAlias { Stable = 'stable', OldStable = 'oldstable' } + +export const IS_WINDOWS = process.platform === 'win32';