From b7bdf8dcd07ab7a64166376b995faf6238244031 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 29 Nov 2022 22:46:12 +0100 Subject: [PATCH 1/3] add type conversion --- dist/cache-save/index.js | 13 +++++++----- dist/setup/index.js | 44 +++++++++++++++++++++++++--------------- package-lock.json | 33 ++++++++++++++++-------------- package.json | 4 ++-- src/installer.ts | 42 +++++++++++++++++++++++--------------- src/main.ts | 5 +---- 6 files changed, 83 insertions(+), 58 deletions(-) diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 10c4ddceb..e6e029d98 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -60313,7 +60313,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -60418,7 +60418,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -60437,7 +60437,7 @@ const cache = __importStar(__nccwpck_require__(7799)); const core = __importStar(__nccwpck_require__(2186)); const exec = __importStar(__nccwpck_require__(1514)); const package_managers_1 = __nccwpck_require__(6663); -exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { +const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); if (exitCode) { stderr = !stderr.trim() @@ -60447,14 +60447,16 @@ exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, fu } return stdout.trim(); }); -exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { +exports.getCommandOutput = getCommandOutput; +const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { if (!package_managers_1.supportedPackageManagers[packageManager]) { throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`); } const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager]; return obtainedPackageManager; }); -exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { +exports.getPackageManagerInfo = getPackageManagerInfo; +const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command))); const emptyPaths = pathList.filter(item => !item); if (emptyPaths.length) { @@ -60462,6 +60464,7 @@ exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0 } return pathList; }); +exports.getCacheDirectoryPath = getCacheDirectoryPath; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; diff --git a/dist/setup/index.js b/dist/setup/index.js index 06b72aa12..5e2e0df38 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63007,7 +63007,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -63032,7 +63032,7 @@ const path_1 = __importDefault(__nccwpck_require__(1017)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const constants_1 = __nccwpck_require__(9042); const cache_utils_1 = __nccwpck_require__(1678); -exports.restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { +const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); const platform = process.env.RUNNER_OS; const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); @@ -63056,6 +63056,7 @@ exports.restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __a core.saveState(constants_1.State.CacheMatchedKey, cacheKey); core.info(`Cache restored from key: ${cacheKey}`); }); +exports.restoreCache = restoreCache; const findDependencyFile = (packageManager) => { let dependencyFile = packageManager.dependencyFilePattern; const workspace = process.env.GITHUB_WORKSPACE; @@ -63090,7 +63091,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -63109,7 +63110,7 @@ const cache = __importStar(__nccwpck_require__(7799)); const core = __importStar(__nccwpck_require__(2186)); const exec = __importStar(__nccwpck_require__(1514)); const package_managers_1 = __nccwpck_require__(6663); -exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { +const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); if (exitCode) { stderr = !stderr.trim() @@ -63119,14 +63120,16 @@ exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, fu } return stdout.trim(); }); -exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { +exports.getCommandOutput = getCommandOutput; +const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { if (!package_managers_1.supportedPackageManagers[packageManager]) { throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`); } const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager]; return obtainedPackageManager; }); -exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { +exports.getPackageManagerInfo = getPackageManagerInfo; +const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command))); const emptyPaths = pathList.filter(item => !item); if (emptyPaths.length) { @@ -63134,6 +63137,7 @@ exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0 } return pathList; }); +exports.getCacheDirectoryPath = getCacheDirectoryPath; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; @@ -63196,7 +63200,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -63223,11 +63227,13 @@ const sys = __importStar(__nccwpck_require__(4300)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const os_1 = __importDefault(__nccwpck_require__(2037)); const utils_1 = __nccwpck_require__(1314); -function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch(), manifest) { +function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { return __awaiter(this, void 0, void 0, function* () { + let manifest; let osPlat = os_1.default.platform(); if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); + manifest = yield getManifest(auth); const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch, manifest); if (resolvedVersion) { versionSpec = resolvedVersion; @@ -63239,6 +63245,7 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch(), manif } if (versionSpec === utils_1.StableReleaseAlias.Stable || versionSpec === utils_1.StableReleaseAlias.OldStable) { + manifest !== null && manifest !== void 0 ? manifest : (manifest = yield getManifest(auth)); versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch, manifest); } // check cache @@ -63394,6 +63401,10 @@ function findMatch(versionSpec, arch = os_1.default.arch()) { if (!candidates) { throw new Error(`golang download url did not return results`); } + if (versionSpec === utils_1.StableReleaseAlias.Stable || + versionSpec === utils_1.StableReleaseAlias.OldStable) { + versionSpec = yield resolveStableVersionInput(versionSpec, undefined, arch, candidates); + } let goFile; for (let i = 0; i < candidates.length; i++) { let candidate = candidates[i]; @@ -63470,9 +63481,11 @@ function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch() return __awaiter(this, void 0, void 0, function* () { if (!manifest) { core.debug('No manifest cached'); - manifest = yield getManifest(auth); + manifest = (yield getManifest(auth)); } - const releases = manifest.map(release => release.version); + const releases = manifest + .filter(release => !!release.files.find(file => file.arch === arch)) + .map(release => release.version); if (versionSpec === utils_1.StableReleaseAlias.Stable) { core.info(`stable version resolved as ${releases[0]}`); return releases[0]; @@ -63480,12 +63493,12 @@ function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch() else { const versions = releases.map(release => `${semver.major(release)}.${semver.minor(release)}`); const uniqueVersions = Array.from(new Set(versions)); - const oldstableVersion = yield getInfoFromManifest(uniqueVersions[1], true, auth, arch, manifest); - core.info(`oldstable version resolved as ${oldstableVersion === null || oldstableVersion === void 0 ? void 0 : oldstableVersion.resolvedVersion}`); + const oldstableVersion = releases.find(item => item.startsWith(uniqueVersions[1])); + core.info(`oldstable version resolved as ${oldstableVersion}`); if (!oldstableVersion) { return versionSpec; } - return oldstableVersion.resolvedVersion; + return oldstableVersion; } }); } @@ -63514,7 +63527,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -63559,9 +63572,8 @@ function run() { if (versionSpec) { let token = core.getInput('token'); let auth = !token ? undefined : `token ${token}`; - const manifest = yield installer.getManifest(auth); const checkLatest = core.getBooleanInput('check-latest'); - const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch, manifest); + const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch); const installDirVersion = path_1.default.basename(path_1.default.dirname(installDir)); core.addPath(path_1.default.join(installDir, 'bin')); core.info('Added go to the path'); diff --git a/package-lock.json b/package-lock.json index 73e443dee..5d4490ca3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,9 +26,9 @@ "jest": "^27.2.5", "jest-circus": "^27.2.5", "nock": "^10.0.6", - "prettier": "^1.17.1", + "prettier": "^2.8.0", "ts-jest": "^27.0.5", - "typescript": "^3.8.3" + "typescript": "^4.3.3" } }, "node_modules/@actions/cache": { @@ -4062,15 +4062,18 @@ } }, "node_modules/prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.0.tgz", + "integrity": "sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA==", "dev": true, "bin": { "prettier": "bin-prettier.js" }, "engines": { - "node": ">=4" + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" } }, "node_modules/pretty-format": { @@ -4694,9 +4697,9 @@ } }, "node_modules/typescript": { - "version": "3.9.10", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", - "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.3.tgz", + "integrity": "sha512-rUvLW0WtF7PF2b9yenwWUi9Da9euvDRhmH7BLyBG4DCFfOJ850LGNknmRpp8Z8kXNUPObdZQEfKOiHtXuQHHKA==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -8118,9 +8121,9 @@ "dev": true }, "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.0.tgz", + "integrity": "sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA==", "dev": true }, "pretty-format": { @@ -8565,9 +8568,9 @@ } }, "typescript": { - "version": "3.9.10", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", - "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.3.tgz", + "integrity": "sha512-rUvLW0WtF7PF2b9yenwWUi9Da9euvDRhmH7BLyBG4DCFfOJ850LGNknmRpp8Z8kXNUPObdZQEfKOiHtXuQHHKA==", "dev": true }, "universalify": { diff --git a/package.json b/package.json index fbbedc0ff..9a1aa88e8 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ "jest": "^27.2.5", "jest-circus": "^27.2.5", "nock": "^10.0.6", - "prettier": "^1.17.1", + "prettier": "^2.8.0", "ts-jest": "^27.0.5", - "typescript": "^3.8.3" + "typescript": "^4.3.3" } } diff --git a/src/installer.ts b/src/installer.ts index 0c2cdee38..18eab5ccf 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -34,13 +34,14 @@ export async function getGo( versionSpec: string, checkLatest: boolean, auth: string | undefined, - arch = os.arch(), - manifest: tc.IToolRelease[] | undefined + arch = os.arch() ) { + let manifest: tc.IToolRelease[] | undefined; let osPlat: string = os.platform(); if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); + manifest = await getManifest(auth); const resolvedVersion = await resolveVersionFromManifest( versionSpec, true, @@ -60,11 +61,12 @@ export async function getGo( versionSpec === StableReleaseAlias.Stable || versionSpec === StableReleaseAlias.OldStable ) { + manifest ??= await getManifest(auth); versionSpec = await resolveStableVersionInput( versionSpec, auth, arch, - manifest + manifest as (tc.IToolRelease & IGoVersion)[] ); } @@ -266,6 +268,18 @@ export async function findMatch( throw new Error(`golang download url did not return results`); } + if ( + versionSpec === StableReleaseAlias.Stable || + versionSpec === StableReleaseAlias.OldStable + ) { + versionSpec = await resolveStableVersionInput( + versionSpec, + undefined, + arch, + candidates as (tc.IToolRelease & IGoVersion)[] + ); + } + let goFile: IGoVersionFile | undefined; for (let i = 0; i < candidates.length; i++) { let candidate: IGoVersion = candidates[i]; @@ -358,14 +372,16 @@ export async function resolveStableVersionInput( versionSpec: string, auth: string | undefined, arch = os.arch(), - manifest: tc.IToolRelease[] | undefined + manifest: (tc.IToolRelease & IGoVersion)[] | undefined ): Promise { if (!manifest) { core.debug('No manifest cached'); - manifest = await getManifest(auth); + manifest = (await getManifest(auth)) as (tc.IToolRelease & IGoVersion)[]; } - const releases = manifest.map(release => release.version); + const releases = manifest + .filter(release => !!release.files.find(file => file.arch === arch)) + .map(release => release.version); if (versionSpec === StableReleaseAlias.Stable) { core.info(`stable version resolved as ${releases[0]}`); @@ -377,22 +393,16 @@ export async function resolveStableVersionInput( ); const uniqueVersions = Array.from(new Set(versions)); - const oldstableVersion = await getInfoFromManifest( - uniqueVersions[1], - true, - auth, - arch, - manifest + const oldstableVersion = releases.find(item => + item.startsWith(uniqueVersions[1]) ); - core.info( - `oldstable version resolved as ${oldstableVersion?.resolvedVersion}` - ); + core.info(`oldstable version resolved as ${oldstableVersion}`); if (!oldstableVersion) { return versionSpec; } - return oldstableVersion.resolvedVersion; + return oldstableVersion; } } diff --git a/src/main.ts b/src/main.ts index 613cb5460..5833f16de 100644 --- a/src/main.ts +++ b/src/main.ts @@ -30,16 +30,13 @@ export async function run() { let token = core.getInput('token'); let auth = !token ? undefined : `token ${token}`; - const manifest = await installer.getManifest(auth); - const checkLatest = core.getBooleanInput('check-latest'); const installDir = await installer.getGo( versionSpec, checkLatest, auth, - arch, - manifest + arch ); const installDirVersion = path.basename(path.dirname(installDir)); From eb4d2dd387fab6b7ee331cff7c5ceb63d1602c35 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 29 Nov 2022 23:02:50 +0100 Subject: [PATCH 2/3] possible fix --- dist/setup/index.js | 5 ++++- src/installer.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 5e2e0df38..0f9cf0e9a 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63403,7 +63403,10 @@ function findMatch(versionSpec, arch = os_1.default.arch()) { } if (versionSpec === utils_1.StableReleaseAlias.Stable || versionSpec === utils_1.StableReleaseAlias.OldStable) { - versionSpec = yield resolveStableVersionInput(versionSpec, undefined, arch, candidates); + const fixedCandidates = candidates.map(item => { + return Object.assign(Object.assign({}, item), { version: makeSemver(item.version) }); + }); + versionSpec = yield resolveStableVersionInput(versionSpec, undefined, arch, fixedCandidates); } let goFile; for (let i = 0; i < candidates.length; i++) { diff --git a/src/installer.ts b/src/installer.ts index 18eab5ccf..975ace211 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -272,11 +272,14 @@ export async function findMatch( versionSpec === StableReleaseAlias.Stable || versionSpec === StableReleaseAlias.OldStable ) { + const fixedCandidates = candidates.map(item => { + return {...item, version: makeSemver(item.version)}; + }); versionSpec = await resolveStableVersionInput( versionSpec, undefined, arch, - candidates as (tc.IToolRelease & IGoVersion)[] + fixedCandidates as (tc.IToolRelease & IGoVersion)[] ); } From f62329616ac0021e377503a76c0edf1c8921f049 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 5 Dec 2022 15:40:29 +0100 Subject: [PATCH 3/3] minor changes --- dist/setup/index.js | 12 +++++++++--- src/installer.ts | 18 ++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 0f9cf0e9a..04c53eeeb 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63484,11 +63484,17 @@ function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch() return __awaiter(this, void 0, void 0, function* () { if (!manifest) { core.debug('No manifest cached'); - manifest = (yield getManifest(auth)); + manifest = yield getManifest(auth); } const releases = manifest - .filter(release => !!release.files.find(file => file.arch === arch)) - .map(release => release.version); + .map(item => { + const index = item.files.findIndex(item => item.arch === arch); + if (index === -1) { + return ''; + } + return item.version; + }) + .filter(item => !!item); if (versionSpec === utils_1.StableReleaseAlias.Stable) { core.info(`stable version resolved as ${releases[0]}`); return releases[0]; diff --git a/src/installer.ts b/src/installer.ts index 975ace211..84c9242f1 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -66,7 +66,7 @@ export async function getGo( versionSpec, auth, arch, - manifest as (tc.IToolRelease & IGoVersion)[] + manifest ); } @@ -279,7 +279,7 @@ export async function findMatch( versionSpec, undefined, arch, - fixedCandidates as (tc.IToolRelease & IGoVersion)[] + fixedCandidates ); } @@ -375,16 +375,22 @@ export async function resolveStableVersionInput( versionSpec: string, auth: string | undefined, arch = os.arch(), - manifest: (tc.IToolRelease & IGoVersion)[] | undefined + manifest: tc.IToolRelease[] | IGoVersion[] | undefined ): Promise { if (!manifest) { core.debug('No manifest cached'); - manifest = (await getManifest(auth)) as (tc.IToolRelease & IGoVersion)[]; + manifest = await getManifest(auth); } const releases = manifest - .filter(release => !!release.files.find(file => file.arch === arch)) - .map(release => release.version); + .map(item => { + const index = item.files.findIndex(item => item.arch === arch); + if (index === -1) { + return ''; + } + return item.version; + }) + .filter(item => !!item); if (versionSpec === StableReleaseAlias.Stable) { core.info(`stable version resolved as ${releases[0]}`);