Skip to content

Commit

Permalink
Add config option
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Jan 2, 2025
1 parent 7a55b60 commit de0b617
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 55 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test-ghcup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ jobs:
with:
stack-hook: true
version: ${{ matrix.version }}
config: |
# see https://github.com/haskell/ghcup-hs/blob/master/data/config.yaml
# for full documentation
url-source:
- GHCupURL
verbose: true
- run: ghcup config
- run: ghcup debug-info
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ jobs:
- uses: actions/checkout@v4
- uses: haskell/ghcup-setup@v1
with:
release-channels: |
GHCupURL
https://raw.githubusercontent.com/haskell/ghcup-metadata/refs/heads/master/ghcup-prereleases-0.0.8.yaml
config: |
# see https://github.com/haskell/ghcup-hs/blob/master/data/config.yaml
# for full documentation
url-source:
- GHCupURL
- prereleases
- run: |
ghcup install ghc --set ${{ matrix.ghc }}
ghcup install cabal --set ${{ matrix.cabal }}
Expand All @@ -59,7 +62,7 @@ jobs:
| Name | Description | Type | Default |
|------------------|-----------------------------------------------------------------|------------|------------|
| version | GHCup version to install | `string` | `latest` |
| release-channels | Set the release-channels | `string[]` | `GHCupURL` |
| config | Set ghcup config | `string[]` | `null` |
| stack-hook | Install the GHCup stack hook (GHCs are installed through ghcup) | `boolean` | `false` |

## Outputs
Expand Down
8 changes: 5 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ inputs:
description: GHCup version to install
default: latest
release-channels:
description: Set the release-channels
default: |
GHCupURL
description: Set the release-channels (deprecated, use 'config' instead)
default: null
stack-hook:
description: Install the GHCup stack hook (GHCs are installed through ghcup)
default: false
config:
description: GHCup config (partial or full)
default: null

outputs:
path:
Expand Down
Binary file modified ghcup/bun.lockb
Binary file not shown.
218 changes: 178 additions & 40 deletions ghcup/dist/index.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion ghcup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1"
"@actions/tool-cache": "^2.0.1",
"yaml": "^2.7.0"
}
}
4 changes: 4 additions & 0 deletions ghcup/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { main, getInputAsBool } from "./main.ts";
import core from "@actions/core";
import YAML from "yaml";

try {
main({
version: core.getInput("version"),
release_channels: core.getMultilineInput("release-channels"),
stack_hook: getInputAsBool("stack-hook"),
config:
YAML.parse(core.getInput("config")) ??
JSON.parse(core.getInput("config")),
});
} catch (error) {
core.setFailed((error as Error).message);
Expand Down
24 changes: 17 additions & 7 deletions ghcup/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ export function getInputAsBool(

export type Opts = {
version: string;
release_channels: string[];
release_channels?: string[];
stack_hook: boolean;
config?: any;
};

export async function main(opts: Opts) {
Expand Down Expand Up @@ -173,10 +174,19 @@ export async function main(opts: Opts) {
installStackHook();
}

await exec.exec(ghcupPath, [
"config",
"set",
"url-source",
JSON.stringify(opts.release_channels),
]);
if (opts.config && opts.config.length > 0) {
await exec.exec(ghcupPath, ["config", "set", JSON.stringify(opts.config)]);
}

if (opts.release_channels && opts.release_channels.length > 0) {
core.warning(
"'release-channels' option is deprecated, use 'config' instead!",
);
await exec.exec(ghcupPath, [
"config",
"set",
"url-source",
JSON.stringify(opts.release_channels),
]);
}
}

0 comments on commit de0b617

Please sign in to comment.