Skip to content

Commit

Permalink
feat: use last GHCup version by default
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabedini committed Dec 12, 2024
1 parent aa1de54 commit 845f2ba
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test-ghcup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ jobs:
- ubuntu-latest
- macos-latest
- windows-latest
version:
- latest
- '0.1.30.0'
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4

- uses: ./ghcup
with:
version: "0.1.30.0"
version: ${{ matrix.version }}

- run: ghcup config

- run: ghcup debug-info

- run: ghcup tool-requirements

- run: ghcup list

- run: ghcup install ghc latest --set
Expand Down
3 changes: 1 addition & 2 deletions ghcup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ branding:
inputs:
version:
description: Version to install
required: true
default: latest
extra-release-channels:
description: Additional release-channels
required: true

outputs:
path:
Expand Down
8 changes: 4 additions & 4 deletions ghcup/dist/index.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions ghcup/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { main } from "./main.ts"
import core from "@actions/core";

try {
main({
version: core.getInput("version"),
extra_release_channels: core.getMultilineInput("extra-release-channels")
})
main({
version: core.getInput("version"),
extra_release_channels: core.getMultilineInput("extra-release-channels")
})
} catch (error) {
core.setFailed((error as Error).message);
}
16 changes: 7 additions & 9 deletions ghcup/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import exec from '@actions/exec';

const ext = platform.isWindows ? ".exe" : "";

const metadata_url = "https://raw.githubusercontent.com/haskell/ghcup-metadata/refs/heads/develop/ghcup-0.0.8.yaml";

type Architecture = typeof platform.arch;
type GHCupArch = 'aarch64' | 'armv7' | 'i386' | 'x86_64';

Expand All @@ -29,7 +27,11 @@ const ghcup_os_map: Map<Platform, GHCupOS> = new Map([
]);

function ghcup_url(version: string, arch: GHCupArch, os: GHCupOS): string {
return `https://downloads.haskell.org/ghcup/${version}/${arch}-${os}-ghcup-${version}${ext}`;
if (version == 'latest') {
return `https://downloads.haskell.org/ghcup/${arch}-${os}-ghcup${ext}`;
} else {
return `https://downloads.haskell.org/ghcup/${version}/${arch}-${os}-ghcup-${version}${ext}`;
}
}

async function ghcup(version: string) {
Expand All @@ -40,16 +42,12 @@ async function ghcup(version: string) {

const arch = ghcup_arch_map.get(platform.arch);
if (arch == undefined) {
const msg = `GHCup does not support architecture ${platform.arch}`;
// core.setFailed(msg);
throw msg;
throw `GHCup does not support architecture ${platform.arch}`;
}

const os = ghcup_os_map.get(platform.platform);
if (os == undefined) {
const msg = `GHCup does not support platform ${platform.platform}`
// core.setFailed(msg);
throw msg;
throw `GHCup does not support platform ${platform.platform}`;
}

const url = ghcup_url(version, arch, os);
Expand Down

0 comments on commit 845f2ba

Please sign in to comment.