GHCup action

April 7, 2025 ยท View on GitHub

A simple github action to install ghcup binary on any system and add it to PATH.

Usage

See action.yml

Minimal

on: [push]
name: build
jobs:
  runhaskell:
    name: Hello World
    runs-on: ubuntu-latest # or macOS-latest, or windows-latest
    steps:
      - uses: actions/checkout@v4
      - uses: haskell/ghcup-setup@v1
      - run: |
          ghcup install ghc --set latest
          runhaskell Hello.hs

Matrix testing with prereleases

on: [push]
name: build
jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        ghc: ['8.6.5', '8.8.4', 'latest-prerelease']
        cabal: ['2.4.1.0', '3.0.0.0']
        os: [ubuntu-latest, macOS-latest, windows-latest]
        exclude:
          - ghc: 8.8.4
            cabal: 2.4.1.0
    name: Haskell GHC ${{ matrix.ghc }} sample
    steps:
      - uses: actions/checkout@v4
      - uses: haskell/ghcup-setup@v1
        with:
          ghc: ${{ matrix.ghc }}
          cabal: ${{ matrix.cabal }}
          config: |
            # don't cache metadata files based on last access time
            meta-cache: 0
            # see https://github.com/haskell/ghcup-hs/blob/master/data/config.yaml
            # for full documentation
            url-source:
              - GHCupURL
              - prereleases
      - run: |
          runhaskell Hello.hs

Inputs

NameDescriptionTypeDefault
versionGHCup version to installstringlatest
ghcGHC version to installstring undefined
cabalcabal-install version to installstring undefined
stackStack version to installstring undefined
hlsHLS version to installstring undefined
configSet ghcup configstring[]{"meta-cache": 0 }
stack-hookInstall the GHCup stack hook (GHCs are installed through ghcup)booleanfalse

Outputs

NameDescriptionType
pathPath to the installed GHCupstring
versionVersion of the installed GHCupstring
basedirBase directory of GHCupstring
bindirBinary directory of GHCupstring
cachedirCache directory of GHCupstring
logsdirLog directory of GHCupstring
confdirConfig directory of GHCupstring