Skip to content

Commit 2b4b07e

Browse files
committed
Migrate release CI back to github
1 parent 9a343d1 commit 2b4b07e

File tree

8 files changed

+959
-1
lines changed

8 files changed

+959
-1
lines changed

.github/actions/download/action.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: 'Download artifact'
2+
description: 'Donwload artifacts with normalized names'
3+
inputs:
4+
name:
5+
required: true
6+
type: string
7+
path:
8+
required: true
9+
type: string
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Normalise name
15+
run: |
16+
name=${{ inputs.name }}
17+
echo "NAME=${name//\//_}" >> "$GITHUB_ENV"
18+
shell: bash
19+
20+
- name: Download artifact
21+
uses: actions/download-artifact@v4
22+
with:
23+
name: ${{ env.NAME }}
24+
path: ${{ inputs.path }}
25+

.github/actions/upload/action.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 'Upload artifact'
2+
description: 'Upload artifacts with normalized names'
3+
inputs:
4+
if-no-files-found:
5+
default: 'error'
6+
type: string
7+
name:
8+
required: true
9+
type: string
10+
path:
11+
required: true
12+
type: string
13+
retention-days:
14+
default: 0
15+
type: number
16+
17+
runs:
18+
using: "composite"
19+
steps:
20+
- name: Normalise name
21+
run: |
22+
name=${{ inputs.name }}
23+
echo "NAME=${name//\//_}" >> "$GITHUB_ENV"
24+
shell: bash
25+
26+
- name: Upload artifact
27+
uses: actions/upload-artifact@v4
28+
with:
29+
if-no-files-found: ${{ inputs.if-no-files-found }}
30+
retention-days: ${{ inputs.retention-days }}
31+
name: ${{ env.NAME }}
32+
path: ${{ inputs.path }}
33+

.github/scripts/build.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
3+
set -eux
4+
5+
uname -a
6+
uname -p
7+
uname
8+
pwd
9+
env
10+
11+
if [ "${RUNNER_OS}" = Windows ] ; then
12+
ext=".exe"
13+
else
14+
ext=""
15+
fi
16+
17+
# build
18+
ghcup --no-verbose install ghc --set --install-targets "install_bin install_lib update_package_db" "${GHC_VERSION}"
19+
sed -i.bak -e '/DELETE MARKER FOR CI/,/END DELETE/d' cabal.project # see comment in cabal.project
20+
cabal update
21+
cabal user-config diff
22+
cabal user-config init -f
23+
"ghc-${GHC_VERSION}" --info
24+
"ghc" --info
25+
26+
# https://github.com/haskell/cabal/issues/7313#issuecomment-811851884
27+
if [ "$(getconf LONG_BIT)" == "32" ] || [ "${DISTRO}" == "CentOS" ] ; then
28+
echo 'constraints: lukko -ofd-locking' >> cabal.release.project.local
29+
fi
30+
31+
# shellcheck disable=SC2206
32+
args=(
33+
-w "ghc-$GHC_VERSION"
34+
--disable-profiling
35+
--enable-executable-stripping
36+
--project-file=cabal.release.project
37+
${ADD_CABAL_ARGS}
38+
)
39+
40+
cabal v2-build "${args[@]}" cabal-install
41+
42+
mkdir -p "out"
43+
# shellcheck disable=SC2154
44+
cp "$(cabal list-bin "${args[@]}" cabal-install:exe:cabal)" "out/cabal$ext"
45+
cp dist-newstyle/cache/plan.json "out/plan.json"
46+
cd "out/"
47+
48+
# create tarball/zip
49+
TARBALL_PREFIX="cabal-install-$("./cabal" --numeric-version)"
50+
case "${TARBALL_EXT}" in
51+
zip)
52+
zip "${TARBALL_PREFIX}-${ARTIFACT}.${TARBALL_EXT}" "cabal${ext}" plan.json
53+
;;
54+
tar.xz)
55+
tar caf "${TARBALL_PREFIX}-${ARTIFACT}.${TARBALL_EXT}" "cabal${ext}" plan.json
56+
;;
57+
*)
58+
fail "Unknown TARBALL_EXT: ${TARBALL_EXT}"
59+
;;
60+
esac
61+
62+
rm "cabal${ext}" plan.json
63+

.github/scripts/test.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
set -eux
4+
5+
env
6+
pwd
7+
ls -lah
8+
9+
cd out
10+
case "${TARBALL_EXT}" in
11+
zip)
12+
unzip ./cabal-install-*-"${ARTIFACT}.${TARBALL_EXT}"
13+
;;
14+
tar.xz)
15+
tar xf ./cabal-install-*-"${ARTIFACT}.${TARBALL_EXT}"
16+
;;
17+
*)
18+
fail "Unknown TARBALL_EXT: ${TARBALL_EXT}"
19+
;;
20+
esac
21+
cd ..
22+
23+
ghcup --no-verbose install ghc --set --install-targets "install_bin install_lib update_package_db" "${GHC_VERSION}"
24+
25+
cabal update
26+
27+
# TODO: we want to avoid building here... we should just
28+
# be using the previously built 'cabal-tests' binary
29+
cabal run ${ADD_CABAL_ARGS} cabal-testsuite:cabal-tests -- \
30+
--with-cabal "$(pwd)/out/cabal" \
31+
--intree-cabal-lib "$(pwd)" \
32+
--test-tmp "$(pwd)/testdb" \
33+
--skip-setup-tests \
34+
-j "$(nproc)"
35+

.github/workflows/release.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build and release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- 'v*'
9+
- 'cabal-install-*'
10+
pull_request:
11+
branches:
12+
- master
13+
schedule:
14+
- cron: '0 0 * * *'
15+
16+
jobs:
17+
release-workflow:
18+
uses: ./.github/workflows/reusable-release.yml
19+
with:
20+
branches: '["${{ github.ref }}"]'
21+
22+
release:
23+
name: release
24+
needs: [ "release-workflow" ]
25+
runs-on: ubuntu-latest
26+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Download artifacts
32+
uses: actions/download-artifact@v4
33+
with:
34+
pattern: artifacts-*
35+
merge-multiple: true
36+
path: ./out
37+
38+
- name: Install requirements
39+
run: |
40+
sudo apt-get update && sudo apt-get install -y tar xz-utils
41+
shell: bash
42+
43+
- name: build sdists
44+
run: |
45+
cabal sdist -o out all
46+
shell: bash
47+
48+
- name: Release
49+
if: startsWith(github.ref, 'refs/tags/')
50+
uses: softprops/action-gh-release@v1
51+
with:
52+
draft: true
53+
files: |
54+
./out/*
55+

0 commit comments

Comments
 (0)