Skip to content

Commit

Permalink
Expose ghcup binary location
Browse files Browse the repository at this point in the history
  • Loading branch information
fendor committed May 10, 2024
1 parent 64f55f9 commit 0a3e4b0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 136 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion lib/installer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

132 changes: 0 additions & 132 deletions lib/setup-haskell.js

This file was deleted.

5 changes: 5 additions & 0 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
const bin = await ghcupBin(os, arch);
core.setOutput('ghcup-command', bin);
}

async function configureOutputs(
tool: Tool,
version: string,
Expand Down
9 changes: 8 additions & 1 deletion src/setup-haskell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0a3e4b0

Please sign in to comment.