diff --git a/src/main.ts b/src/main.ts index 2e7efec6..c9c631a0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,12 +4,37 @@ import * as os from 'os' import * as path from 'path' import * as tc from '@actions/tool-cache' -let csVersion = core.getInput('version') -if (!csVersion) csVersion = '2.1.4' const scalaCLIVersion = '1.0.6' +const architecture_x86_64 = 'x86_64' +const architecture_aarch64 = 'aarch64' + +const architecture = getArchitecture() + +const csDefaultVersion_x86_64 = '2.1.7' +const csDefaultVersion_aarch64 = '2.1.7' + +const csVersion = + core.getInput('version') || + (architecture === architecture_x86_64 ? csDefaultVersion_x86_64 : csDefaultVersion_aarch64) + const coursierVersionSpec = csVersion +const coursierBinariesGithubRepository = + architecture === architecture_x86_64 + ? 'https://github.com/coursier/coursier/' + : 'https://github.com/VirtusLab/coursier-m1/' + +function getArchitecture(): string { + if (process.arch === 'x64') { + return architecture_x86_64 + } else if (process.arch === 'arm' || process.arch === 'arm64') { + return architecture_aarch64 + } else { + throw new Error(`Coursier does not have support for the ${process.arch} architecture`) + } +} + async function execOutput(cmd: string, ...args: string[]): Promise { let output = '' const options = { @@ -24,7 +49,7 @@ async function execOutput(cmd: string, ...args: string[]): Promise { } async function downloadCoursier(): Promise { - const baseUrl = `https://github.com/coursier/coursier/releases/download/v${csVersion}/cs-x86_64` + const baseUrl = `${coursierBinariesGithubRepository}/releases/download/v${csVersion}/cs-${architecture}` let csBinary = '' switch (process.platform) { case 'linux': {