Skip to content

Commit 050757b

Browse files
committed
Add config option
1 parent 7a55b60 commit 050757b

File tree

8 files changed

+248
-64
lines changed

8 files changed

+248
-64
lines changed

.github/workflows/test-ghcup.yaml

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ jobs:
2121
- uses: actions/checkout@v4
2222

2323
- uses: ./
24-
with:
25-
stack-hook: true
26-
version: ${{ matrix.version }}
2724

2825
- run: ghcup config
2926
- run: ghcup debug-info
@@ -53,12 +50,6 @@ jobs:
5350
- if: runner.os == 'Windows'
5451
run: ghcup run -m sh -- -c 'pacman --version'
5552

56-
- name: Stack hook test
57-
run: |
58-
ghcup install stack latest
59-
cat $(stack path --stack-root)/hooks/ghc-install.sh
60-
shell: bash
61-
6253
vanilla-channel:
6354
strategy:
6455
matrix:
@@ -93,3 +84,39 @@ jobs:
9384

9485
- if: runner.os == 'Windows'
9586
run: ghcup run -m sh -- -c 'pacman --version'
87+
88+
config:
89+
strategy:
90+
matrix:
91+
runs-on:
92+
- ubuntu-latest
93+
version:
94+
- latest
95+
runs-on: ${{ matrix.runs-on }}
96+
steps:
97+
- uses: actions/checkout@v4
98+
99+
- uses: ./
100+
with:
101+
stack-hook: true
102+
version: ${{ matrix.version }}
103+
config: |
104+
# see https://github.com/haskell/ghcup-hs/blob/master/data/config.yaml
105+
# for full documentation
106+
url-source:
107+
- StackSetupURL
108+
verbose: true
109+
110+
- run: ghcup config
111+
- run: ghcup debug-info
112+
- run: ghcup list
113+
114+
- run: ghcup -s GHCupURL install stack latest --set
115+
- run: ghcup -s GHCupURL whereis stack latest
116+
- run: which stack
117+
- run: stack --version
118+
119+
- name: Stack hook test
120+
run: |
121+
cat $(stack path --stack-root)/hooks/ghc-install.sh
122+
shell: bash

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ jobs:
4545
- uses: actions/checkout@v4
4646
- uses: haskell/ghcup-setup@v1
4747
with:
48-
release-channels: |
49-
GHCupURL
50-
https://raw.githubusercontent.com/haskell/ghcup-metadata/refs/heads/master/ghcup-prereleases-0.0.8.yaml
48+
config: |
49+
# see https://github.com/haskell/ghcup-hs/blob/master/data/config.yaml
50+
# for full documentation
51+
url-source:
52+
- GHCupURL
53+
- prereleases
5154
- run: |
5255
ghcup install ghc --set ${{ matrix.ghc }}
5356
ghcup install cabal --set ${{ matrix.cabal }}
@@ -59,7 +62,7 @@ jobs:
5962
| Name | Description | Type | Default |
6063
|------------------|-----------------------------------------------------------------|------------|------------|
6164
| version | GHCup version to install | `string` | `latest` |
62-
| release-channels | Set the release-channels | `string[]` | `GHCupURL` |
65+
| config | Set ghcup config | `string[]` | `null` |
6366
| stack-hook | Install the GHCup stack hook (GHCs are installed through ghcup) | `boolean` | `false` |
6467

6568
## Outputs

action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ inputs:
1010
description: GHCup version to install
1111
default: latest
1212
release-channels:
13-
description: Set the release-channels
14-
default: |
15-
GHCupURL
13+
description: Set the release-channels (deprecated, use 'config' instead)
1614
stack-hook:
1715
description: Install the GHCup stack hook (GHCs are installed through ghcup)
1816
default: false
17+
config:
18+
description: GHCup config (partial or full)
1919

2020
outputs:
2121
path:

ghcup/bun.lockb

336 Bytes
Binary file not shown.

ghcup/dist/index.js

Lines changed: 178 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ghcup/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@actions/core": "^1.11.1",
1313
"@actions/exec": "^1.1.1",
1414
"@actions/io": "^1.1.3",
15-
"@actions/tool-cache": "^2.0.1"
15+
"@actions/tool-cache": "^2.0.1",
16+
"yaml": "^2.7.0"
1617
}
1718
}

ghcup/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { main, getInputAsBool } from "./main.ts";
22
import core from "@actions/core";
3+
import YAML from "yaml";
34

45
try {
56
main({
67
version: core.getInput("version"),
78
release_channels: core.getMultilineInput("release-channels"),
89
stack_hook: getInputAsBool("stack-hook"),
10+
config: core.getInput("config")
11+
? (YAML.parse(core.getInput("config")) ??
12+
JSON.parse(core.getInput("config")))
13+
: undefined,
914
});
1015
} catch (error) {
1116
core.setFailed((error as Error).message);

ghcup/src/main.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ export function getInputAsBool(
124124

125125
export type Opts = {
126126
version: string;
127-
release_channels: string[];
127+
release_channels?: string[];
128128
stack_hook: boolean;
129+
config?: string;
129130
};
130131

131132
export async function main(opts: Opts) {
@@ -173,10 +174,19 @@ export async function main(opts: Opts) {
173174
installStackHook();
174175
}
175176

176-
await exec.exec(ghcupPath, [
177-
"config",
178-
"set",
179-
"url-source",
180-
JSON.stringify(opts.release_channels),
181-
]);
177+
if (opts.config) {
178+
await exec.exec(ghcupPath, ["config", "set", JSON.stringify(opts.config)]);
179+
}
180+
181+
if (opts.release_channels && opts.release_channels.length > 0) {
182+
core.warning(
183+
"'release-channels' option is deprecated, use 'config' instead!",
184+
);
185+
await exec.exec(ghcupPath, [
186+
"config",
187+
"set",
188+
"url-source",
189+
JSON.stringify(opts.release_channels),
190+
]);
191+
}
182192
}

0 commit comments

Comments
 (0)