From 0cbaec8e4bfd558ae146217b0dea1dc3d6dae531 Mon Sep 17 00:00:00 2001 From: Ross Brodbeck Date: Wed, 20 Nov 2019 15:24:28 -0500 Subject: [PATCH] Change getFileName to do architecture lookups and add arm support --- lib/installer.js | 9 ++++++++- src/installer.ts | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/installer.js b/lib/installer.js index cf83c80..67a4756 100644 --- a/lib/installer.js +++ b/lib/installer.js @@ -72,6 +72,7 @@ function acquireGo(version) { // let fileName = getFileName(version); let downloadUrl = getDownloadUrl(fileName); + core.debug('Downloading Go from: ' + downloadUrl); let downloadPath = null; try { downloadPath = yield tc.downloadTool(downloadUrl); @@ -102,8 +103,14 @@ function acquireGo(version) { }); } function getFileName(version) { + const arches = { + x64: 'amd64', + arm: 'armv6l', + arm64: 'arm64', + default: '386' + }; const platform = osPlat == 'win32' ? 'windows' : osPlat; - const arch = osArch == 'x64' ? 'amd64' : '386'; + const arch = arches[osArch] || arches['default']; const ext = osPlat == 'win32' ? 'zip' : 'tar.gz'; const filename = util.format('go%s.%s-%s.%s', version, platform, arch, ext); return filename; diff --git a/src/installer.ts b/src/installer.ts index 181582e..9f25476 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -57,6 +57,9 @@ async function acquireGo(version: string): Promise { // let fileName: string = getFileName(version); let downloadUrl: string = getDownloadUrl(fileName); + + core.debug('Downloading Go from: ' + downloadUrl); + let downloadPath: string | null = null; try { downloadPath = await tc.downloadTool(downloadUrl); @@ -89,8 +92,15 @@ async function acquireGo(version: string): Promise { } function getFileName(version: string): string { + const arches: {[arch: string]: string} = { + x64: 'amd64', + arm: 'armv6l', + arm64: 'arm64', + default: '386' + }; + const platform: string = osPlat == 'win32' ? 'windows' : osPlat; - const arch: string = osArch == 'x64' ? 'amd64' : '386'; + const arch: string = arches[osArch] || arches['default']; const ext: string = osPlat == 'win32' ? 'zip' : 'tar.gz'; const filename: string = util.format( 'go%s.%s-%s.%s', @@ -99,6 +109,7 @@ function getFileName(version: string): string { arch, ext ); + return filename; }