Skip to content

Commit

Permalink
Convert x64 to amd64 in executable names
Browse files Browse the repository at this point in the history
  • Loading branch information
unfunco committed Jun 14, 2021
1 parent d78b392 commit c2c13a9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
14 changes: 14 additions & 0 deletions __tests__/setup-tanka.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,18 @@ describe('GitHub Actions × Grafana Tanka', () => {
undefined
);
});

it('installs windows/x64 versions', async () => {
os.platform = 'linux';
os.arch = 'x64';

downloadToolSpy.mockImplementation(() => '/');

await tanka.install('0.16.0');

expect(downloadToolSpy).toHaveBeenCalledWith(
'https://github.com/grafana/tanka/releases/download/v0.16.0/tk-linux-amd64',
undefined
);
});
});
6 changes: 5 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,15 @@ function install(version) {
}
exports.install = install;
function getExecutableName() {
let arch = os.arch();
let platform = os.platform().toString();
if (platform === 'win32') {
platform = 'windows';
}
return `tk-${platform}-${os.arch()}`;
if (arch === 'x64') {
arch = 'amd64';
}
return `tk-${platform}-${arch}`;
}
function formatVersion(version) {
let parts = version.split('-');
Expand Down
11 changes: 9 additions & 2 deletions src/tanka.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export async function install(version: string): Promise<void> {
const executableName = getExecutableName();

const tkDownloadUrl = `https://github.com/grafana/tanka/releases/download/${semanticVersion}/${executableName}`;
core.info(`Downloading Grafana Tanka ${semanticVersion} from ${tkDownloadUrl}`);
core.info(
`Downloading Grafana Tanka ${semanticVersion} from ${tkDownloadUrl}`
);
const tkDownload = await tc.downloadTool(tkDownloadUrl, undefined);

const tkDownloadPath = path.basename(tkDownload);
Expand All @@ -42,12 +44,17 @@ export async function install(version: string): Promise<void> {
}

function getExecutableName(): string {
let arch = os.arch();
let platform = os.platform().toString();
if (platform === 'win32') {
platform = 'windows';
}

return `tk-${platform}-${os.arch()}`;
if (arch === 'x64') {
arch = 'amd64';
}

return `tk-${platform}-${arch}`;
}

function formatVersion(version: string): string {
Expand Down

0 comments on commit c2c13a9

Please sign in to comment.