Skip to content

Commit 8ba636c

Browse files
authored
Merge pull request #11072 from stable-haskell/release-ci
Rewrite release CI
2 parents b140dca + 5cabbce commit 8ba636c

File tree

12 files changed

+1209
-123
lines changed

12 files changed

+1209
-123
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: 'Download 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.bash

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
set -eux
2+
3+
uname -a
4+
uname -p
5+
uname
6+
pwd
7+
env
8+
9+
if [ "${RUNNER_OS}" = Windows ] ; then
10+
ext=".exe"
11+
else
12+
ext=""
13+
fi
14+
15+
ghcup --no-verbose install ghc --set --install-targets "${GHC_TARGETS}" "${GHC_VERSION}"
16+
17+
cabal update
18+
cabal user-config diff
19+
cabal user-config init -f
20+
"ghc-${GHC_VERSION}" --info
21+
"ghc" --info
22+
23+
# shellcheck disable=SC2206
24+
args=(
25+
-w "ghc-$GHC_VERSION"
26+
--disable-profiling
27+
--enable-executable-stripping
28+
--project-file=cabal.release.project
29+
${ADD_CABAL_ARGS}
30+
)
31+
32+
cabal v2-build "${args[@]}" cabal-install
33+
34+
mkdir -p "out"
35+
# shellcheck disable=SC2154
36+
cp "$(cabal list-bin "${args[@]}" cabal-install:exe:cabal)" "out/cabal$ext"
37+
cp dist-newstyle/cache/plan.json "out/plan.json"
38+
cd "out/"
39+
40+
# create tarball/zip
41+
TARBALL_PREFIX="cabal-install-$("./cabal" --numeric-version)"
42+
case "${TARBALL_EXT}" in
43+
zip)
44+
zip "${TARBALL_PREFIX}-${ARTIFACT}.${TARBALL_EXT}" "cabal${ext}" plan.json
45+
;;
46+
tar.xz)
47+
tar caf "${TARBALL_PREFIX}-${ARTIFACT}.${TARBALL_EXT}" "cabal${ext}" plan.json
48+
;;
49+
*)
50+
fail "Unknown TARBALL_EXT: ${TARBALL_EXT}"
51+
;;
52+
esac
53+
54+
rm "cabal${ext}" plan.json
55+

.github/scripts/test.bash

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

.github/workflows/release.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build and release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
- 'cabal-install-*'
8+
pull_request:
9+
types: [opened, synchronize, reopened, labeled]
10+
branches:
11+
- master
12+
schedule:
13+
- cron: '0 0 * * *'
14+
workflow_dispatch:
15+
16+
permissions:
17+
pull-requests: read
18+
19+
env:
20+
BUILD_LABEL: "run release build"
21+
22+
jobs:
23+
check-pr-labels:
24+
name: check PR labels
25+
runs-on: ubuntu-latest
26+
outputs:
27+
run_release_workflow: ${{ steps.gen_output.outputs.run_release_workflow }}
28+
steps:
29+
- id: gen_output
30+
run: |
31+
if [ "${{ github.event.action }}" == 'labeled' ] ; then
32+
if [ ${{ github.event.label.name == '${{ env.BUILD_LABEL }}' }} ] ; then
33+
echo run_release_workflow="yes" >> "$GITHUB_OUTPUT"
34+
else
35+
echo run_release_workflow="no" >> "$GITHUB_OUTPUT"
36+
fi
37+
elif [ "${{ github.event_name }}" = 'pull_request' ] ; then
38+
run_it=$(if gh api --jq '.labels.[].name' /repos/${{ github.repository }}/pulls/${{ github.event.number }} | grep --quiet '^${{ env.BUILD_LABEL }}$' ; then printf "%s" "yes" ; else printf "%s" "no" ; fi)
39+
echo "${run_it}"
40+
echo run_release_workflow="${run_it}" >> "$GITHUB_OUTPUT"
41+
else
42+
echo run_release_workflow="yes" >> "$GITHUB_OUTPUT"
43+
fi
44+
shell: bash
45+
env:
46+
GH_TOKEN: ${{ github.token }}
47+
48+
release-workflow:
49+
needs: ["check-pr-labels"]
50+
if: ${{ needs.check-pr-labels.outputs.run_release_workflow == 'yes' }}
51+
uses: ./.github/workflows/reusable-release.yml
52+
with:
53+
branches: '["${{ github.ref }}"]'
54+
55+
release:
56+
name: release
57+
needs: [ "release-workflow" ]
58+
runs-on: ubuntu-latest
59+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v4
63+
64+
- name: Download artifacts
65+
uses: actions/download-artifact@v4
66+
with:
67+
pattern: artifacts-*
68+
merge-multiple: true
69+
path: ./out
70+
71+
- name: Install requirements
72+
run: |
73+
sudo apt-get update && sudo apt-get install -y tar xz-utils
74+
shell: bash
75+
76+
- name: build sdists
77+
run: |
78+
cabal sdist -o out all
79+
shell: bash
80+
81+
- name: Release
82+
uses: softprops/action-gh-release@v1
83+
with:
84+
draft: true
85+
files: |
86+
./out/*
87+

0 commit comments

Comments
 (0)