From 1eafc12ba0f859d4b1d4a8bb16c5fbbddb93fa6f Mon Sep 17 00:00:00 2001 From: Piotr Chabelski Date: Thu, 16 Nov 2023 15:36:25 +0100 Subject: [PATCH 1/2] Bump `cs` to 2.1.7 --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 2e7efec6..60f52f5c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,7 +5,7 @@ import * as path from 'path' import * as tc from '@actions/tool-cache' let csVersion = core.getInput('version') -if (!csVersion) csVersion = '2.1.4' +if (!csVersion) csVersion = '2.1.7' const scalaCLIVersion = '1.0.6' const coursierVersionSpec = csVersion From 73269b5917ed111099691368547caaaec061b909 Mon Sep 17 00:00:00 2001 From: Piotr Chabelski Date: Thu, 16 Nov 2023 15:43:42 +0100 Subject: [PATCH 2/2] Add support for M1 architecture for coursier --- src/main.ts | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 60f52f5c..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.7' 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': {