Skip to content

Release CI with nightlies #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/actions/download/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Download artifact'
description: 'Donwload artifacts with normalized names'
inputs:
name:
required: true
type: string
path:
required: true
type: string

runs:
using: "composite"
steps:
- name: Normalise name
run: |
name=${{ inputs.name }}
echo "NAME=${name//\//_}" >> "$GITHUB_ENV"
shell: bash

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.NAME }}
path: ${{ inputs.path }}

33 changes: 33 additions & 0 deletions .github/actions/upload/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'Upload artifact'
description: 'Upload artifacts with normalized names'
inputs:
if-no-files-found:
default: 'error'
type: string
name:
required: true
type: string
path:
required: true
type: string
retention-days:
default: 0
type: number

runs:
using: "composite"
steps:
- name: Normalise name
run: |
name=${{ inputs.name }}
echo "NAME=${name//\//_}" >> "$GITHUB_ENV"
shell: bash

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: ${{ inputs.if-no-files-found }}
retention-days: ${{ inputs.retention-days }}
name: ${{ env.NAME }}
path: ${{ inputs.path }}

63 changes: 63 additions & 0 deletions .github/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

set -eux

uname -a
uname -p
uname
pwd
env

if [ "${RUNNER_OS}" = Windows ] ; then
ext=".exe"
else
ext=""
fi

ghcup --no-verbose install ghc --set --install-targets "${GHC_TARGETS}" "${GHC_VERSION}"

sed -i.bak -e '/DELETE MARKER FOR CI/,/END DELETE/d' cabal.project # see comment in cabal.project
cabal update
cabal user-config diff
cabal user-config init -f
"ghc-${GHC_VERSION}" --info
"ghc" --info

# https://github.com/haskell/cabal/issues/7313#issuecomment-811851884
if [ "$(getconf LONG_BIT)" == "32" ] || [ "${DISTRO}" == "CentOS" ] ; then
echo 'constraints: lukko -ofd-locking' >> cabal.release.project.local
fi

# shellcheck disable=SC2206
args=(
-w "ghc-$GHC_VERSION"
--disable-profiling
--enable-executable-stripping
--project-file=cabal.release.project
${ADD_CABAL_ARGS}
)

cabal v2-build "${args[@]}" cabal-install

mkdir -p "out"
# shellcheck disable=SC2154
cp "$(cabal list-bin "${args[@]}" cabal-install:exe:cabal)" "out/cabal$ext"
cp dist-newstyle/cache/plan.json "out/plan.json"
cd "out/"

# create tarball/zip
TARBALL_PREFIX="cabal-install-$("./cabal" --numeric-version)"
case "${TARBALL_EXT}" in
zip)
zip "${TARBALL_PREFIX}-${ARTIFACT}.${TARBALL_EXT}" "cabal${ext}" plan.json
;;
tar.xz)
tar caf "${TARBALL_PREFIX}-${ARTIFACT}.${TARBALL_EXT}" "cabal${ext}" plan.json
;;
*)
fail "Unknown TARBALL_EXT: ${TARBALL_EXT}"
;;
esac

rm "cabal${ext}" plan.json

35 changes: 35 additions & 0 deletions .github/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -eux

env
pwd
ls -lah

cd out
case "${TARBALL_EXT}" in
zip)
unzip ./cabal-install-*-"${ARTIFACT}.${TARBALL_EXT}"
;;
tar.xz)
tar xf ./cabal-install-*-"${ARTIFACT}.${TARBALL_EXT}"
;;
*)
fail "Unknown TARBALL_EXT: ${TARBALL_EXT}"
;;
esac
cd ..

ghcup --no-verbose install ghc --set --install-targets "${GHC_TARGETS}" "${GHC_VERSION}"

cabal update

# TODO: we want to avoid building here... we should just
# be using the previously built 'cabal-tests' binary
cabal run ${ADD_CABAL_ARGS} cabal-testsuite:cabal-tests -- \
--with-cabal "$(pwd)/out/cabal" \
--intree-cabal-lib "$(pwd)" \
--test-tmp "$(pwd)/testdb" \
--skip-setup-tests \
-j "$(nproc)"

68 changes: 68 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build and release

on:
push:
branches:
- master
tags:
- 'v*'
- 'cabal-install-*'
pull_request:
branches:
- master
schedule:
- cron: '0 0 * * *'

jobs:
release-workflow:
uses: ./.github/workflows/reusable-release.yml
with:
branches: '["${{ github.ref }}"]'

release:
name: release
needs: [ "release-workflow" ]
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'schedule' }}
steps:
- name: Get current date
id: date
run: echo "NIGHTLY_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

- name: Checkout code
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: artifacts-*
merge-multiple: true
path: ./out

- name: Install requirements
run: |
sudo apt-get update && sudo apt-get install -y tar xz-utils
shell: bash

- name: build sdists
run: |
cabal sdist -o out all
shell: bash

- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
./out/*

- name: Release nightly
if: ${{ github.event_name == 'schedule' }}
uses: softprops/action-gh-release@v1
with:
tag_name: nightly-${{ env.NIGHTLY_DATE }}
draft: false
prerelease: true
files: |
./out/*
Loading
Loading