diff --git a/README.md b/README.md index de9dc71..bcd45ee 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,7 @@ jobs: | `stack-setup-ghc` | If set, `enable-stack` must be set. Runs stack setup to install the specified GHC. (Note: setting this does _not_ imply `stack-no-global`.) | "boolean" | false/unset | | `disable-matcher` | If set, disables match messages from GHC as GitHub CI annotations. | "boolean" | false/unset | | `cabal-update` | If set to `false`, skip `cabal update` step. | `boolean` | `true` | -| `ghcup-release-channel` | If set, add a [release channel](https://www.haskell.org/ghcup/guide/#metadata) to ghcup. | `URL` | none | +| `ghcup-release-channel` | If set, add a [release channel](https://www.haskell.org/ghcup/guide/#metadata) to ghcup. | `URL` | none | Note: "boolean" types are set/unset, not true/false. That is, setting any "boolean" to a value other than the empty string (`""`) will be considered true/set. @@ -228,6 +228,7 @@ and `ghc-exe` and `ghc-path` will be set accordingly. | `stack-path` | The path of the `stack` executable _directory_ | string | | `cabal-store` | The path to the cabal store | string | | `stack-root` | The path to the stack root (equal to the `STACK_ROOT` environment variable if it is set; otherwise an OS-specific default) | string | +| `ghcup-command` | The path of the `ghcup` _executable_. Might not be an absolute file path. | string | ## Version Support diff --git a/action.yml b/action.yml index 582d9df..3f99739 100644 --- a/action.yml +++ b/action.yml @@ -45,6 +45,8 @@ outputs: description: 'The resolved version of stack' ghc-exe: description: 'The path of the ghc _executable_' + ghcup-command: + description: 'The path of the ghcup _executable_' cabal-exe: description: 'The path of the cabal _executable_' stack-exe: diff --git a/dist/index.js b/dist/index.js index 0fd69ad..22c7e10 100644 --- a/dist/index.js +++ b/dist/index.js @@ -13390,7 +13390,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.addGhcupReleaseChannel = exports.resetTool = exports.installTool = void 0; +exports.addGhcupReleaseChannel = exports.resetTool = exports.installTool = exports.configureGhcupOutput = void 0; const core = __importStar(__nccwpck_require__(2186)); const exec_1 = __nccwpck_require__(1514); const io_1 = __nccwpck_require__(7436); @@ -13407,6 +13407,11 @@ const exec = async (cmd, args) => (0, exec_1.exec)(cmd, args, { ignoreReturnCode function failed(tool, version) { throw new Error(`All install methods for ${tool} ${version} failed`); } +async function configureGhcupOutput(os, arch) { + const bin = await ghcupBin(os, arch); + core.setOutput('ghcup-command', bin); +} +exports.configureGhcupOutput = configureGhcupOutput; async function configureOutputs(tool, version, path, os) { core.setOutput(`${tool}-path`, path); core.setOutput(`${tool}-exe`, await (0, io_1.which)(tool)); @@ -14060,6 +14065,7 @@ async function run(inputs) { core.debug(`run: inputs = ${JSON.stringify(inputs)}`); core.debug(`run: os = ${JSON.stringify(os)}`); core.debug(`run: opts = ${JSON.stringify(opts)}`); + await (0, installer_1.configureGhcupOutput)(os, arch); if (opts.ghcup.releaseChannel) { await core.group(`Preparing ghcup environment`, async () => (0, installer_1.addGhcupReleaseChannel)(opts.ghcup.releaseChannel, os, arch)); } diff --git a/lib/installer.js b/lib/installer.js index 8830ae2..2167052 100644 --- a/lib/installer.js +++ b/lib/installer.js @@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.addGhcupReleaseChannel = exports.resetTool = exports.installTool = void 0; +exports.addGhcupReleaseChannel = exports.resetTool = exports.installTool = exports.configureGhcupOutput = void 0; const core = __importStar(require("@actions/core")); const exec_1 = require("@actions/exec"); const io_1 = require("@actions/io"); @@ -43,6 +43,11 @@ const exec = async (cmd, args) => (0, exec_1.exec)(cmd, args, { ignoreReturnCode function failed(tool, version) { throw new Error(`All install methods for ${tool} ${version} failed`); } +async function configureGhcupOutput(os, arch) { + const bin = await ghcupBin(os, arch); + core.setOutput('ghcup-command', bin); +} +exports.configureGhcupOutput = configureGhcupOutput; async function configureOutputs(tool, version, path, os) { core.setOutput(`${tool}-path`, path); core.setOutput(`${tool}-exe`, await (0, io_1.which)(tool)); diff --git a/src/installer.ts b/src/installer.ts index 93a3744..d95ec2d 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -18,6 +18,11 @@ function failed(tool: Tool, version: string): void { throw new Error(`All install methods for ${tool} ${version} failed`); } +export async function configureGhcupOutput(os: OS, arch: Arch): Promise { + const bin = await ghcupBin(os, arch); + core.setOutput('ghcup-command', bin); +} + async function configureOutputs( tool: Tool, version: string, diff --git a/src/setup-haskell.ts b/src/setup-haskell.ts index b8d0134..9a63f0d 100644 --- a/src/setup-haskell.ts +++ b/src/setup-haskell.ts @@ -5,7 +5,12 @@ import * as fs from 'fs'; import * as path from 'path'; import {EOL} from 'os'; import {getOpts, getDefaults, Tool} from './opts'; -import {addGhcupReleaseChannel, installTool, resetTool} from './installer'; +import { + addGhcupReleaseChannel, + configureGhcupOutput, + installTool, + resetTool +} from './installer'; import type {Arch, OS} from './opts'; import {exec} from '@actions/exec'; @@ -40,6 +45,8 @@ export default async function run( core.debug(`run: os = ${JSON.stringify(os)}`); core.debug(`run: opts = ${JSON.stringify(opts)}`); + await configureGhcupOutput(os, arch); + if (opts.ghcup.releaseChannel) { await core.group(`Preparing ghcup environment`, async () => addGhcupReleaseChannel(opts.ghcup.releaseChannel!, os, arch)