diff --git a/dist/index.js b/dist/index.js
index dff1358..37158f1 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -13437,7 +13437,7 @@ function aptVersion(tool, version) {
// This regex is intentionally liberal to accommodate unusual cases like "head".
return tool === 'cabal' ? /[^.]*\.?[^.]*/.exec(version)[0] : version;
}
-async function isInstalled(tool, version, os) {
+async function isInstalled(tool, version, os, arch) {
const toolPath = tc.find(tool, version);
if (toolPath)
return success(tool, version, toolPath, os);
@@ -13462,7 +13462,7 @@ async function isInstalled(tool, version, os) {
}[os]
};
core.debug(`isInstalled ${tool} ${version} ${locations[tool]}`);
- const f = await exec(await ghcupBin(os), ['whereis', tool, version]);
+ const f = await exec(await ghcupBin(os, arch), ['whereis', tool, version]);
core.info(`\n`);
core.debug(`isInstalled whereis ${f}`);
for (const p of locations[tool]) {
@@ -13484,7 +13484,7 @@ async function isInstalled(tool, version, os) {
if (installedPath === ghcupPath) {
// If the result of this `ghcup set` is non-zero, the version we want
// is probably not actually installed
- const ghcupSetResult = await exec(await ghcupBin(os), [
+ const ghcupSetResult = await exec(await ghcupBin(os, arch), [
'set',
tool,
version
@@ -13495,7 +13495,7 @@ async function isInstalled(tool, version, os) {
else {
// Andreas, 2023-05-03, issue #245.
// Since we do not have the correct version, disable any default version.
- await exec(await ghcupBin(os), ['unset', tool]);
+ await exec(await ghcupBin(os, arch), ['unset', tool]);
}
}
else {
@@ -13507,13 +13507,13 @@ async function isInstalled(tool, version, os) {
}
return false;
}
-async function installTool(tool, version, os) {
- if (await isInstalled(tool, version, os))
+async function installTool(tool, version, os, arch) {
+ if (await isInstalled(tool, version, os, arch))
return;
warn(tool, version);
if (tool === 'stack') {
- await stack(version, os);
- if (await isInstalled(tool, version, os))
+ await stack(version, os, arch);
+ if (await isInstalled(tool, version, os, arch))
return;
return failed(tool, version);
}
@@ -13535,27 +13535,27 @@ async function installTool(tool, version, os) {
// if (!(await aptLibCurses5())) break;
await aptLibNCurses5();
}
- await ghcup(tool, version, os);
- if (await isInstalled(tool, version, os))
+ await ghcup(tool, version, os, arch);
+ if (await isInstalled(tool, version, os, arch))
return;
await apt(tool, version);
break;
case 'win32':
await choco(tool, version);
- if (await isInstalled(tool, version, os))
+ if (await isInstalled(tool, version, os, arch))
return;
- await ghcup(tool, version, os);
+ await ghcup(tool, version, os, arch);
break;
case 'darwin':
- await ghcup(tool, version, os);
+ await ghcup(tool, version, os, arch);
break;
}
- if (await isInstalled(tool, version, os))
+ if (await isInstalled(tool, version, os, arch))
return;
return failed(tool, version);
}
exports.installTool = installTool;
-async function resetTool(tool, _version, os) {
+async function resetTool(tool, _version, os, arch) {
if (tool === 'stack') {
// We don't need to do anything here... yet
// (Once we switch to utilizing ghcup for stack when possible, we can
@@ -13565,11 +13565,11 @@ async function resetTool(tool, _version, os) {
let bin = '';
switch (os) {
case 'linux':
- bin = await ghcupBin(os);
+ bin = await ghcupBin(os, arch);
await exec(bin, ['unset', tool]);
return;
case 'darwin':
- bin = await ghcupBin(os);
+ bin = await ghcupBin(os, arch);
await exec(bin, ['unset', tool]);
return;
case 'win32':
@@ -13578,11 +13578,24 @@ async function resetTool(tool, _version, os) {
}
}
exports.resetTool = resetTool;
-async function stack(version, os) {
- core.info(`Attempting to install stack ${version}`);
+async function stackArchString(arch) {
+ switch (arch) {
+ case 'arm64':
+ return Promise.resolve('aarch64');
+ case 'x64':
+ return Promise.resolve('x86_64');
+ default:
+ const err = `Unsupported architecture: ${arch}`;
+ core.error(err);
+ return Promise.reject(err);
+ }
+}
+async function stack(version, os, arch) {
+ const binArch = await stackArchString(arch);
+ core.info(`Attempting to install stack ${version} for arch ${binArch}`);
const build = {
- linux: `linux-x86_64${(0, compare_versions_1.compareVersions)(version, '2.3.1') >= 0 ? '' : '-static'}`,
- darwin: 'osx-x86_64',
+ linux: `linux-${binArch}${(0, compare_versions_1.compareVersions)(version, '2.3.1') >= 0 ? '' : '-static'}`,
+ darwin: `osx-${binArch}`,
win32: 'windows-x86_64'
}[os];
const url = `https://github.com/commercialhaskell/stack/releases/download/v${version}/stack-${version}-${build}.tar.gz`;
@@ -13642,7 +13655,7 @@ async function choco(tool, version) {
if (tool == 'ghc')
core.addPath(chocoPath);
}
-async function ghcupBin(os) {
+async function ghcupBin(os, arch) {
core.debug(`ghcupBin : ${os}`);
if (os === 'win32') {
return 'ghcup';
@@ -13650,19 +13663,20 @@ async function ghcupBin(os) {
const cachedBin = tc.find('ghcup', opts_1.ghcup_version);
if (cachedBin)
return (0, path_1.join)(cachedBin, 'ghcup');
- const bin = await tc.downloadTool(`https://downloads.haskell.org/ghcup/${opts_1.ghcup_version}/x86_64-${os === 'darwin' ? 'apple-darwin' : 'linux'}-ghcup-${opts_1.ghcup_version}`);
+ const binArch = await stackArchString(arch);
+ const bin = await tc.downloadTool(`https://downloads.haskell.org/ghcup/${opts_1.ghcup_version}/${binArch}-${os === 'darwin' ? 'apple-darwin' : 'linux'}-ghcup-${opts_1.ghcup_version}`);
await fs_1.promises.chmod(bin, 0o755);
return (0, path_1.join)(await tc.cacheFile(bin, 'ghcup', 'ghcup', opts_1.ghcup_version), 'ghcup');
}
-async function addGhcupReleaseChannel(channel, os) {
+async function addGhcupReleaseChannel(channel, os, arch) {
core.info(`Adding ghcup release channel: ${channel}`);
- const bin = await ghcupBin(os);
+ const bin = await ghcupBin(os, arch);
await exec(bin, ['config', 'add-release-channel', channel.toString()]);
}
exports.addGhcupReleaseChannel = addGhcupReleaseChannel;
-async function ghcup(tool, version, os) {
+async function ghcup(tool, version, os, arch) {
core.info(`Attempting to install ${tool} ${version} using ghcup`);
- const bin = await ghcupBin(os);
+ const bin = await ghcupBin(os, arch);
if (tool === 'cabal' && version === 'head') {
await ghcupCabalHead(os, bin);
}
@@ -13697,7 +13711,7 @@ async function ghcupCabalHead(os, bin) {
}
async function ghcupGHCHead() {
core.info(`Attempting to install ghc head using ghcup`);
- const bin = await ghcupBin('linux');
+ const bin = await ghcupBin('linux', 'x64');
const returnCode = await exec(bin, [
'install',
'ghc',
@@ -14032,16 +14046,17 @@ async function run(inputs) {
try {
core.info('Preparing to setup a Haskell environment');
const os = process.platform;
+ const arch = process.arch;
const opts = (0, opts_1.getOpts)((0, opts_1.getDefaults)(os), os, inputs);
core.debug(`run: inputs = ${JSON.stringify(inputs)}`);
core.debug(`run: os = ${JSON.stringify(os)}`);
core.debug(`run: opts = ${JSON.stringify(opts)}`);
if (opts.ghcup.releaseChannel) {
- await core.group(`Preparing ghcup environment`, async () => (0, installer_1.addGhcupReleaseChannel)(opts.ghcup.releaseChannel, os));
+ await core.group(`Preparing ghcup environment`, async () => (0, installer_1.addGhcupReleaseChannel)(opts.ghcup.releaseChannel, os, arch));
}
for (const [t, { resolved }] of Object.entries(opts).filter(o => o[1].enable)) {
- await core.group(`Preparing ${t} environment`, async () => (0, installer_1.resetTool)(t, resolved, os));
- await core.group(`Installing ${t} version ${resolved}`, async () => (0, installer_1.installTool)(t, resolved, os));
+ await core.group(`Preparing ${t} environment`, async () => (0, installer_1.resetTool)(t, resolved, os, arch));
+ await core.group(`Installing ${t} version ${resolved}`, async () => (0, installer_1.installTool)(t, resolved, os, arch));
}
if (opts.stack.setup)
await core.group('Pre-installing GHC with stack', async () => (0, exec_1.exec)('stack', ['setup', opts.ghc.resolved]));
diff --git a/lib/installer.d.ts b/lib/installer.d.ts
index 930d630..96a95b6 100644
--- a/lib/installer.d.ts
+++ b/lib/installer.d.ts
@@ -1,5 +1,5 @@
///
-import { OS, Tool } from './opts';
-export declare function installTool(tool: Tool, version: string, os: OS): Promise;
-export declare function resetTool(tool: Tool, _version: string, os: OS): Promise;
-export declare function addGhcupReleaseChannel(channel: URL, os: OS): Promise;
+import { Arch, OS, Tool } from './opts';
+export declare function installTool(tool: Tool, version: string, os: OS, arch: Arch): Promise;
+export declare function resetTool(tool: Tool, _version: string, os: OS, arch: Arch): Promise;
+export declare function addGhcupReleaseChannel(channel: URL, os: OS, arch: Arch): Promise;
diff --git a/lib/installer.js b/lib/installer.js
index c5f3ca5..8830ae2 100644
--- a/lib/installer.js
+++ b/lib/installer.js
@@ -73,7 +73,7 @@ function aptVersion(tool, version) {
// This regex is intentionally liberal to accommodate unusual cases like "head".
return tool === 'cabal' ? /[^.]*\.?[^.]*/.exec(version)[0] : version;
}
-async function isInstalled(tool, version, os) {
+async function isInstalled(tool, version, os, arch) {
const toolPath = tc.find(tool, version);
if (toolPath)
return success(tool, version, toolPath, os);
@@ -98,7 +98,7 @@ async function isInstalled(tool, version, os) {
}[os]
};
core.debug(`isInstalled ${tool} ${version} ${locations[tool]}`);
- const f = await exec(await ghcupBin(os), ['whereis', tool, version]);
+ const f = await exec(await ghcupBin(os, arch), ['whereis', tool, version]);
core.info(`\n`);
core.debug(`isInstalled whereis ${f}`);
for (const p of locations[tool]) {
@@ -120,7 +120,7 @@ async function isInstalled(tool, version, os) {
if (installedPath === ghcupPath) {
// If the result of this `ghcup set` is non-zero, the version we want
// is probably not actually installed
- const ghcupSetResult = await exec(await ghcupBin(os), [
+ const ghcupSetResult = await exec(await ghcupBin(os, arch), [
'set',
tool,
version
@@ -131,7 +131,7 @@ async function isInstalled(tool, version, os) {
else {
// Andreas, 2023-05-03, issue #245.
// Since we do not have the correct version, disable any default version.
- await exec(await ghcupBin(os), ['unset', tool]);
+ await exec(await ghcupBin(os, arch), ['unset', tool]);
}
}
else {
@@ -143,13 +143,13 @@ async function isInstalled(tool, version, os) {
}
return false;
}
-async function installTool(tool, version, os) {
- if (await isInstalled(tool, version, os))
+async function installTool(tool, version, os, arch) {
+ if (await isInstalled(tool, version, os, arch))
return;
warn(tool, version);
if (tool === 'stack') {
- await stack(version, os);
- if (await isInstalled(tool, version, os))
+ await stack(version, os, arch);
+ if (await isInstalled(tool, version, os, arch))
return;
return failed(tool, version);
}
@@ -171,27 +171,27 @@ async function installTool(tool, version, os) {
// if (!(await aptLibCurses5())) break;
await aptLibNCurses5();
}
- await ghcup(tool, version, os);
- if (await isInstalled(tool, version, os))
+ await ghcup(tool, version, os, arch);
+ if (await isInstalled(tool, version, os, arch))
return;
await apt(tool, version);
break;
case 'win32':
await choco(tool, version);
- if (await isInstalled(tool, version, os))
+ if (await isInstalled(tool, version, os, arch))
return;
- await ghcup(tool, version, os);
+ await ghcup(tool, version, os, arch);
break;
case 'darwin':
- await ghcup(tool, version, os);
+ await ghcup(tool, version, os, arch);
break;
}
- if (await isInstalled(tool, version, os))
+ if (await isInstalled(tool, version, os, arch))
return;
return failed(tool, version);
}
exports.installTool = installTool;
-async function resetTool(tool, _version, os) {
+async function resetTool(tool, _version, os, arch) {
if (tool === 'stack') {
// We don't need to do anything here... yet
// (Once we switch to utilizing ghcup for stack when possible, we can
@@ -201,11 +201,11 @@ async function resetTool(tool, _version, os) {
let bin = '';
switch (os) {
case 'linux':
- bin = await ghcupBin(os);
+ bin = await ghcupBin(os, arch);
await exec(bin, ['unset', tool]);
return;
case 'darwin':
- bin = await ghcupBin(os);
+ bin = await ghcupBin(os, arch);
await exec(bin, ['unset', tool]);
return;
case 'win32':
@@ -214,11 +214,24 @@ async function resetTool(tool, _version, os) {
}
}
exports.resetTool = resetTool;
-async function stack(version, os) {
- core.info(`Attempting to install stack ${version}`);
+async function stackArchString(arch) {
+ switch (arch) {
+ case 'arm64':
+ return Promise.resolve('aarch64');
+ case 'x64':
+ return Promise.resolve('x86_64');
+ default:
+ const err = `Unsupported architecture: ${arch}`;
+ core.error(err);
+ return Promise.reject(err);
+ }
+}
+async function stack(version, os, arch) {
+ const binArch = await stackArchString(arch);
+ core.info(`Attempting to install stack ${version} for arch ${binArch}`);
const build = {
- linux: `linux-x86_64${(0, compare_versions_1.compareVersions)(version, '2.3.1') >= 0 ? '' : '-static'}`,
- darwin: 'osx-x86_64',
+ linux: `linux-${binArch}${(0, compare_versions_1.compareVersions)(version, '2.3.1') >= 0 ? '' : '-static'}`,
+ darwin: `osx-${binArch}`,
win32: 'windows-x86_64'
}[os];
const url = `https://github.com/commercialhaskell/stack/releases/download/v${version}/stack-${version}-${build}.tar.gz`;
@@ -278,7 +291,7 @@ async function choco(tool, version) {
if (tool == 'ghc')
core.addPath(chocoPath);
}
-async function ghcupBin(os) {
+async function ghcupBin(os, arch) {
core.debug(`ghcupBin : ${os}`);
if (os === 'win32') {
return 'ghcup';
@@ -286,19 +299,20 @@ async function ghcupBin(os) {
const cachedBin = tc.find('ghcup', opts_1.ghcup_version);
if (cachedBin)
return (0, path_1.join)(cachedBin, 'ghcup');
- const bin = await tc.downloadTool(`https://downloads.haskell.org/ghcup/${opts_1.ghcup_version}/x86_64-${os === 'darwin' ? 'apple-darwin' : 'linux'}-ghcup-${opts_1.ghcup_version}`);
+ const binArch = await stackArchString(arch);
+ const bin = await tc.downloadTool(`https://downloads.haskell.org/ghcup/${opts_1.ghcup_version}/${binArch}-${os === 'darwin' ? 'apple-darwin' : 'linux'}-ghcup-${opts_1.ghcup_version}`);
await fs_1.promises.chmod(bin, 0o755);
return (0, path_1.join)(await tc.cacheFile(bin, 'ghcup', 'ghcup', opts_1.ghcup_version), 'ghcup');
}
-async function addGhcupReleaseChannel(channel, os) {
+async function addGhcupReleaseChannel(channel, os, arch) {
core.info(`Adding ghcup release channel: ${channel}`);
- const bin = await ghcupBin(os);
+ const bin = await ghcupBin(os, arch);
await exec(bin, ['config', 'add-release-channel', channel.toString()]);
}
exports.addGhcupReleaseChannel = addGhcupReleaseChannel;
-async function ghcup(tool, version, os) {
+async function ghcup(tool, version, os, arch) {
core.info(`Attempting to install ${tool} ${version} using ghcup`);
- const bin = await ghcupBin(os);
+ const bin = await ghcupBin(os, arch);
if (tool === 'cabal' && version === 'head') {
await ghcupCabalHead(os, bin);
}
@@ -333,7 +347,7 @@ async function ghcupCabalHead(os, bin) {
}
async function ghcupGHCHead() {
core.info(`Attempting to install ghc head using ghcup`);
- const bin = await ghcupBin('linux');
+ const bin = await ghcupBin('linux', 'x64');
const returnCode = await exec(bin, [
'install',
'ghc',
diff --git a/lib/opts.d.ts b/lib/opts.d.ts
index 5b5a360..c003555 100644
--- a/lib/opts.d.ts
+++ b/lib/opts.d.ts
@@ -7,6 +7,7 @@ export type Revisions = Record>>;
export type OS = 'linux' | 'darwin' | 'win32';
+export type Arch = 'arm64' | 'x64';
export type Tool = 'cabal' | 'ghc' | 'stack';
export interface ProgramOpt {
enable: boolean;
diff --git a/lib/setup-haskell.js b/lib/setup-haskell.js
index 4285907..f74417e 100644
--- a/lib/setup-haskell.js
+++ b/lib/setup-haskell.js
@@ -48,16 +48,17 @@ async function run(inputs) {
try {
core.info('Preparing to setup a Haskell environment');
const os = process.platform;
+ const arch = process.arch;
const opts = (0, opts_1.getOpts)((0, opts_1.getDefaults)(os), os, inputs);
core.debug(`run: inputs = ${JSON.stringify(inputs)}`);
core.debug(`run: os = ${JSON.stringify(os)}`);
core.debug(`run: opts = ${JSON.stringify(opts)}`);
if (opts.ghcup.releaseChannel) {
- await core.group(`Preparing ghcup environment`, async () => (0, installer_1.addGhcupReleaseChannel)(opts.ghcup.releaseChannel, os));
+ await core.group(`Preparing ghcup environment`, async () => (0, installer_1.addGhcupReleaseChannel)(opts.ghcup.releaseChannel, os, arch));
}
for (const [t, { resolved }] of Object.entries(opts).filter(o => o[1].enable)) {
- await core.group(`Preparing ${t} environment`, async () => (0, installer_1.resetTool)(t, resolved, os));
- await core.group(`Installing ${t} version ${resolved}`, async () => (0, installer_1.installTool)(t, resolved, os));
+ await core.group(`Preparing ${t} environment`, async () => (0, installer_1.resetTool)(t, resolved, os, arch));
+ await core.group(`Installing ${t} version ${resolved}`, async () => (0, installer_1.installTool)(t, resolved, os, arch));
}
if (opts.stack.setup)
await core.group('Pre-installing GHC with stack', async () => (0, exec_1.exec)('stack', ['setup', opts.ghc.resolved]));
diff --git a/src/installer.ts b/src/installer.ts
index 96e664c..93a3744 100644
--- a/src/installer.ts
+++ b/src/installer.ts
@@ -4,7 +4,7 @@ import {which} from '@actions/io';
import * as tc from '@actions/tool-cache';
import {promises as afs} from 'fs';
import {join, dirname} from 'path';
-import {ghcup_version, OS, Tool, releaseRevision} from './opts';
+import {ghcup_version, Arch, OS, Tool, releaseRevision} from './opts';
import process from 'process';
import * as glob from '@actions/glob';
import * as fs from 'fs';
@@ -69,7 +69,8 @@ function aptVersion(tool: string, version: string): string {
async function isInstalled(
tool: Tool,
version: string,
- os: OS
+ os: OS,
+ arch: Arch
): Promise {
const toolPath = tc.find(tool, version);
if (toolPath) return success(tool, version, toolPath, os);
@@ -103,7 +104,7 @@ async function isInstalled(
}[os]
};
core.debug(`isInstalled ${tool} ${version} ${locations[tool]}`);
- const f = await exec(await ghcupBin(os), ['whereis', tool, version]);
+ const f = await exec(await ghcupBin(os, arch), ['whereis', tool, version]);
core.info(`\n`);
core.debug(`isInstalled whereis ${f}`);
@@ -127,7 +128,7 @@ async function isInstalled(
if (installedPath === ghcupPath) {
// If the result of this `ghcup set` is non-zero, the version we want
// is probably not actually installed
- const ghcupSetResult = await exec(await ghcupBin(os), [
+ const ghcupSetResult = await exec(await ghcupBin(os, arch), [
'set',
tool,
version
@@ -137,7 +138,7 @@ async function isInstalled(
} else {
// Andreas, 2023-05-03, issue #245.
// Since we do not have the correct version, disable any default version.
- await exec(await ghcupBin(os), ['unset', tool]);
+ await exec(await ghcupBin(os, arch), ['unset', tool]);
}
} else {
// Install methods apt and choco have precise install paths,
@@ -152,14 +153,15 @@ async function isInstalled(
export async function installTool(
tool: Tool,
version: string,
- os: OS
+ os: OS,
+ arch: Arch
): Promise {
- if (await isInstalled(tool, version, os)) return;
+ if (await isInstalled(tool, version, os, arch)) return;
warn(tool, version);
if (tool === 'stack') {
- await stack(version, os);
- if (await isInstalled(tool, version, os)) return;
+ await stack(version, os, arch);
+ if (await isInstalled(tool, version, os, arch)) return;
return failed(tool, version);
}
@@ -183,28 +185,29 @@ export async function installTool(
// if (!(await aptLibCurses5())) break;
await aptLibNCurses5();
}
- await ghcup(tool, version, os);
- if (await isInstalled(tool, version, os)) return;
+ await ghcup(tool, version, os, arch);
+ if (await isInstalled(tool, version, os, arch)) return;
await apt(tool, version);
break;
case 'win32':
await choco(tool, version);
- if (await isInstalled(tool, version, os)) return;
- await ghcup(tool, version, os);
+ if (await isInstalled(tool, version, os, arch)) return;
+ await ghcup(tool, version, os, arch);
break;
case 'darwin':
- await ghcup(tool, version, os);
+ await ghcup(tool, version, os, arch);
break;
}
- if (await isInstalled(tool, version, os)) return;
+ if (await isInstalled(tool, version, os, arch)) return;
return failed(tool, version);
}
export async function resetTool(
tool: Tool,
_version: string,
- os: OS
+ os: OS,
+ arch: Arch
): Promise {
if (tool === 'stack') {
// We don't need to do anything here... yet
@@ -216,11 +219,11 @@ export async function resetTool(
let bin = '';
switch (os) {
case 'linux':
- bin = await ghcupBin(os);
+ bin = await ghcupBin(os, arch);
await exec(bin, ['unset', tool]);
return;
case 'darwin':
- bin = await ghcupBin(os);
+ bin = await ghcupBin(os, arch);
await exec(bin, ['unset', tool]);
return;
case 'win32':
@@ -229,13 +232,27 @@ export async function resetTool(
}
}
-async function stack(version: string, os: OS): Promise {
- core.info(`Attempting to install stack ${version}`);
+async function stackArchString(arch: Arch): Promise {
+ switch (arch) {
+ case 'arm64':
+ return Promise.resolve('aarch64');
+ case 'x64':
+ return Promise.resolve('x86_64');
+ default:
+ const err = `Unsupported architecture: ${arch}`;
+ core.error(err);
+ return Promise.reject(err);
+ }
+}
+
+async function stack(version: string, os: OS, arch: Arch): Promise {
+ const binArch = await stackArchString(arch);
+ core.info(`Attempting to install stack ${version} for arch ${binArch}`);
const build = {
- linux: `linux-x86_64${
+ linux: `linux-${binArch}${
compareVersions(version, '2.3.1') >= 0 ? '' : '-static'
}`,
- darwin: 'osx-x86_64',
+ darwin: `osx-${binArch}`,
win32: 'windows-x86_64'
}[os];
@@ -314,7 +331,7 @@ async function choco(tool: Tool, version: string): Promise {
if (tool == 'ghc') core.addPath(chocoPath);
}
-async function ghcupBin(os: OS): Promise {
+async function ghcupBin(os: OS, arch: Arch): Promise {
core.debug(`ghcupBin : ${os}`);
if (os === 'win32') {
return 'ghcup';
@@ -322,8 +339,9 @@ async function ghcupBin(os: OS): Promise {
const cachedBin = tc.find('ghcup', ghcup_version);
if (cachedBin) return join(cachedBin, 'ghcup');
+ const binArch = await stackArchString(arch);
const bin = await tc.downloadTool(
- `https://downloads.haskell.org/ghcup/${ghcup_version}/x86_64-${
+ `https://downloads.haskell.org/ghcup/${ghcup_version}/${binArch}-${
os === 'darwin' ? 'apple-darwin' : 'linux'
}-ghcup-${ghcup_version}`
);
@@ -336,16 +354,22 @@ async function ghcupBin(os: OS): Promise {
export async function addGhcupReleaseChannel(
channel: URL,
- os: OS
+ os: OS,
+ arch: Arch
): Promise {
core.info(`Adding ghcup release channel: ${channel}`);
- const bin = await ghcupBin(os);
+ const bin = await ghcupBin(os, arch);
await exec(bin, ['config', 'add-release-channel', channel.toString()]);
}
-async function ghcup(tool: Tool, version: string, os: OS): Promise {
+async function ghcup(
+ tool: Tool,
+ version: string,
+ os: OS,
+ arch: Arch
+): Promise {
core.info(`Attempting to install ${tool} ${version} using ghcup`);
- const bin = await ghcupBin(os);
+ const bin = await ghcupBin(os, arch);
if (tool === 'cabal' && version === 'head') {
await ghcupCabalHead(os, bin);
} else {
@@ -380,7 +404,7 @@ async function ghcupCabalHead(os: OS, bin: string): Promise {
async function ghcupGHCHead(): Promise {
core.info(`Attempting to install ghc head using ghcup`);
- const bin = await ghcupBin('linux');
+ const bin = await ghcupBin('linux', 'x64');
const returnCode = await exec(bin, [
'install',
'ghc',
diff --git a/src/opts.ts b/src/opts.ts
index 9fe2dc1..b919513 100644
--- a/src/opts.ts
+++ b/src/opts.ts
@@ -14,6 +14,7 @@ export type Revisions = Record<
Record>
>;
export type OS = 'linux' | 'darwin' | 'win32';
+export type Arch = 'arm64' | 'x64';
export type Tool = 'cabal' | 'ghc' | 'stack';
export interface ProgramOpt {
diff --git a/src/setup-haskell.ts b/src/setup-haskell.ts
index a0502e4..158d6f1 100644
--- a/src/setup-haskell.ts
+++ b/src/setup-haskell.ts
@@ -6,7 +6,7 @@ import * as path from 'path';
import {EOL} from 'os';
import {getOpts, getDefaults, Tool} from './opts';
import {addGhcupReleaseChannel, installTool, resetTool} from './installer';
-import type {OS} from './opts';
+import type {Arch, OS} from './opts';
import {exec} from '@actions/exec';
async function cabalConfig(): Promise {
@@ -25,6 +25,7 @@ export default async function run(
try {
core.info('Preparing to setup a Haskell environment');
const os = process.platform as OS;
+ const arch = process.arch as Arch;
const opts = getOpts(getDefaults(os), os, inputs);
core.debug(`run: inputs = ${JSON.stringify(inputs)}`);
core.debug(`run: os = ${JSON.stringify(os)}`);
@@ -32,7 +33,7 @@ export default async function run(
if (opts.ghcup.releaseChannel) {
await core.group(`Preparing ghcup environment`, async () =>
- addGhcupReleaseChannel(opts.ghcup.releaseChannel!, os)
+ addGhcupReleaseChannel(opts.ghcup.releaseChannel!, os, arch)
);
}
@@ -40,10 +41,10 @@ export default async function run(
o => o[1].enable
)) {
await core.group(`Preparing ${t} environment`, async () =>
- resetTool(t as Tool, resolved, os)
+ resetTool(t as Tool, resolved, os, arch)
);
await core.group(`Installing ${t} version ${resolved}`, async () =>
- installTool(t as Tool, resolved, os)
+ installTool(t as Tool, resolved, os, arch)
);
}