Skip to content

Commit

Permalink
Merge pull request #30 from hross/master
Browse files Browse the repository at this point in the history
Change getFileName to do architecture lookups and add arm support
  • Loading branch information
hross committed Nov 25, 2019
2 parents 75259a5 + 0cbaec8 commit 9fbc767
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 12 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ async function acquireGo(version: string): Promise<string> {
//
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);
Expand Down Expand Up @@ -89,8 +92,15 @@ async function acquireGo(version: string): Promise<string> {
}

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',
Expand All @@ -99,6 +109,7 @@ function getFileName(version: string): string {
arch,
ext
);

return filename;
}

Expand Down

0 comments on commit 9fbc767

Please sign in to comment.