CI overhaul and fix build with cabal #97
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modified from https://github.com/simonmichael/hledger/blob/master/.github/workflows/windows.yml | |
name: CI (Windows) | |
on: | |
push: | |
branches: [master, ci-*] | |
pull_request: | |
branches: [master] | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Determine stack root | |
run: | | |
echo STACK_ROOT="$(stack --system-ghc --no-install-ghc path --stack-root)" >> "${GITHUB_ENV}" | |
- name: 📥 Checkout repository | |
uses: actions/checkout@v4 | |
# things to be restored: | |
- name: 💾 Restore cached stack global package db | |
id: stack-global | |
uses: actions/cache/restore@v3 | |
with: | |
path: ${{ env.STACK_ROOT }} | |
key: ${{ runner.os }}-stack-global-${{ hashFiles('**.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-stack-global | |
- name: 💾 Restore cached .stack-work | |
id: stack-work | |
uses: actions/cache/restore@v3 | |
with: | |
path: .stack-work | |
key: ${{ runner.os }}-stack-work-${{ hashFiles('**.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-stack-work | |
# actions | |
- name: ⏬ Install stack | |
## Stack is preinstalled on GHA runners. | |
# | |
#if: steps.stack-programs-dir.outputs.cache-hit != 'true' | |
# this step is needed to get stack.exe into PATH, for now | |
# curl -sL https://get.haskellstack.org/stable/windows-x86_64.zip -o stack.zip | |
# 7z x stack.zip stack.exe | |
run: | | |
which stack | |
stack --version | |
- name: ⏬ Install GHC | |
# if: steps.stack-programs-dir.outputs.cache-hit != 'true' | |
# set PATH=C:\Users\runneradmin\AppData\Local\Programs\stack\local\bin;%PATH% | |
run: | | |
stack --no-terminal setup --install-ghc | |
- name: Install the icu library | |
run: | | |
stack exec -- pacman -S --noconfirm mingw-w64-x86_64-icu mingw-w64-x86_64-pkgconf | |
- name: 📸 Build Snapshot | |
run: | | |
stack build --no-terminal --only-snapshot -j1 | |
- name: 🧰 Build Dependencies | |
run: | | |
stack build --no-terminal --only-dependencies | |
- name: 🔨 Build and run tests | |
run: | | |
stack test | |
# things to be cached | |
- name: 💾 Cache stack global package db | |
if: always() && steps.stack-global.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v3 | |
with: | |
path: ${{ env.STACK_ROOT }} | |
key: ${{ steps.stack-global.outputs.cache-primary-key }} | |
- name: 💾 Cache .stack-work | |
if: always() && steps.stack-work.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v3 | |
with: | |
path: .stack-work | |
key: ${{ steps.stack-work.outputs.cache-primary-key }} | |
# release (optional) | |
# artifacts: | |
- name: 📦 Compress executable and data files | |
run: | | |
# locate the data-dir | |
$snapshot = (stack path --snapshot-install-root) | |
$datadir = (ls $snapshot\share *Agda-* -Recurse -Directory).FullName | |
# locate the executable | |
$local = (stack path --local-install-root) | |
$executable = (ls $local\bin *als.exe* -Recurse -File).FullName | |
# make a temporary directory for compresssing | |
mkdir zip | |
cp -r $datadir zip/data | |
cp $executable zip/ | |
# include text-icu DLLs | |
$mingw64bin = (stack path --extra-library-dirs).split(", ") -match "\\bin" | |
ls $mingw64bin | |
cp (ls $mingw64bin *libicudt*) zip/ | |
cp (ls $mingw64bin *libicuin*) zip/ | |
cp (ls $mingw64bin *libicuuc*) zip/ | |
ls zip | |
# compress | |
cd zip | |
Compress-Archive * als-windows.zip | |
cd .. | |
mv zip/als-windows.zip . | |
- name: 🚢 Release Artifacts | |
if: startsWith(github.ref, 'refs/tags/v') # so that only commits with a git tag would upload artifacts | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release upload ${{ github.ref }} als-windows.zip --clobber |