Skip to content

Commit

Permalink
Merge pull request #377 from Gedochao/maintenance/fix-m1-compat
Browse files Browse the repository at this point in the history
Add support for M1 runners
  • Loading branch information
Gedochao authored Nov 16, 2023
2 parents 6e130d1 + 73269b5 commit f23b642
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
let output = ''
const options = {
Expand All @@ -24,7 +49,7 @@ async function execOutput(cmd: string, ...args: string[]): Promise<string> {
}

async function downloadCoursier(): Promise<string> {
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': {
Expand Down

0 comments on commit f23b642

Please sign in to comment.