Revert "cabal-install: rename changelog to changelog.md (fix #8857)"
[cabal.git] / .gitlab / ci.sh
blobb0a680795865369c8fb686cd80065f4642025745
1 #!/usr/bin/env bash
3 set -Eeuo pipefail
5 source "$CI_PROJECT_DIR/.gitlab/common.sh"
7 export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR/toolchain"
8 export CABAL_DIR="$CI_PROJECT_DIR/cabal"
10 case "$(uname)" in
11 MSYS_*|MINGW*)
12 export CABAL_DIR="$(cygpath -w "$CABAL_DIR")"
13 GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/ghcup/bin"
14 EXE_EXT=".exe"
17 GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/.ghcup/bin"
18 EXE_EXT=""
20 esac
22 mkdir -p "$CABAL_DIR"
23 mkdir -p "$GHCUP_BINDIR"
24 export PATH="$GHCUP_BINDIR:$PATH"
26 export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
27 export BOOTSTRAP_HASKELL_GHC_VERSION=$GHC_VERSION
28 export BOOTSTRAP_HASKELL_CABAL_VERSION=$CABAL_INSTALL_VERSION
29 export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=yes
31 # for some reason the subshell doesn't pick up the arm64 environment on darwin
32 # and starts installing x86_64 GHC
33 case "$(uname -s)" in
34 "Darwin"|"darwin")
35 case "$(/usr/bin/arch)" in
36 aarch64|arm64|armv8l)
37 curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | arch -arm64 /bin/bash
40 curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
42 esac
45 curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
47 esac
49 # https://github.com/haskell/cabal/issues/7313#issuecomment-811851884
50 # and
51 # https://github.com/haskellari/lukko/issues/17
53 # $PLATFORM comes from CI.
54 if [ "$(getconf LONG_BIT)" = "32" -o "${PLATFORM:=xxx}" = "x86_64-linux-centos7" ] ; then
55 echo 'constraints: lukko -ofd-locking' >> cabal.project.release.local
58 args=(
59 -w "ghc-$GHC_VERSION"
60 --disable-profiling
61 --enable-executable-stripping
62 --project-file=cabal.project.release
63 ${ADD_CABAL_ARGS}
66 run cabal v2-build ${args[@]} cabal-install
68 mkdir "$CI_PROJECT_DIR/out"
69 cp "$(cabal list-bin ${args[@]} cabal-install:exe:cabal)" "$CI_PROJECT_DIR/out/cabal$EXE_EXT"
70 cp dist-newstyle/cache/plan.json "$CI_PROJECT_DIR/out/plan.json"
71 cd "$CI_PROJECT_DIR/out/"
73 # create tarball/zip
74 TARBALL_PREFIX="cabal-install-$("$CI_PROJECT_DIR/out/cabal" --numeric-version)"
75 case "${TARBALL_EXT}" in
76 zip)
77 zip "${TARBALL_PREFIX}-${TARBALL_ARCHIVE_SUFFIX}.${TARBALL_EXT}" "cabal${EXE_EXT}" plan.json
79 tar.xz)
80 tar caf "${TARBALL_PREFIX}-${TARBALL_ARCHIVE_SUFFIX}.${TARBALL_EXT}" "cabal${EXE_EXT}" plan.json
83 fail "Unknown TARBALL_EXT: ${TARBALL_EXT}"
85 esac
87 rm cabal plan.json