ghcup-hs/.github/scripts/cabal-cache.sh

47 lines
899 B
Bash
Raw Normal View History

2022-12-20 08:49:16 +00:00
#!/bin/sh
set -eux
. .github/scripts/prereq.sh
. .github/scripts/common.sh
# ensure ghcup
if ! command -v ghcup ; then
install_ghcup
fi
2022-12-20 12:49:10 +00:00
if [ "${RUNNER_OS}" = "macOS" ] ; then
rm -rf "${CABAL_DIR}"/store/*
fi
2022-12-20 08:49:16 +00:00
# ensure ghc
2023-01-15 12:01:15 +00:00
ghcup install ghc --set "${GHC_VER}"
ghcup install cabal --set "${CABAL_VER}"
2022-12-20 08:49:16 +00:00
ghc --version
cabal --version
cabal update
2023-01-15 12:01:15 +00:00
cd /tmp
cabal unpack cabal-install-3.8.1.0
cd cabal-install-3.8.1.0
2022-12-20 08:49:16 +00:00
2022-12-20 12:49:10 +00:00
if [ "${DISTRO}" = "Alpine" ] ; then
2023-01-15 12:01:15 +00:00
cabal build --constraint='lukko -ofd-locking' --ghc-options='-split-sections -optl-static' cabal-install:exe:cabal
elif [ "${DISTRO}" = "Ubuntu" ] ; then
cabal build --constraint='lukko -ofd-locking' cabal-install:exe:cabal
2022-12-20 12:49:10 +00:00
else
2023-01-15 12:01:15 +00:00
cabal build cabal-install:exe:cabal
2022-12-20 12:49:10 +00:00
fi
2023-01-15 12:01:15 +00:00
binary=$(cabal list-bin cabal-install:exe:cabal)
2022-12-20 08:49:16 +00:00
cd ..
2023-01-15 12:01:15 +00:00
mkdir -p "${CI_PROJECT_DIR}/out"
2022-12-20 08:49:16 +00:00
strip_binary "${binary}"
2023-01-15 12:01:15 +00:00
cp "${binary}" "${CI_PROJECT_DIR}/out/${ARTIFACT}"
2022-12-20 08:49:16 +00:00