Skip to content

Add release workflow pipeline #608

Add release workflow pipeline

Add release workflow pipeline #608

Workflow file for this run

name: Haskell CI
on:
push:
branches: [ "master" ]
pull_request:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ghc: ["8.10.7", "9.6.5"]
os: [ubuntu-latest, macos-latest, windows-latest]
# GHC versions older than ghc-9.2 are not supported on macos-latest
exclude:
- os: macos-latest
ghc: "8.10.7"
steps:
- name: Install Haskell
uses: input-output-hk/actions/haskell@latest
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: 3.12.1.0
- uses: actions/checkout@v4
- name: Cabal update
run: cabal update
- name: Configure build
shell: bash
run: |
cp ".github/workflows/cabal.project.local.ci.$(uname -s)" cabal.project.local
echo "# cabal.project.local"
cat cabal.project.local
# A dry run `build all` operation does *NOT* download anything, it just looks at the package
# indices to generate an install plan.
- name: Build dry run
run: cabal build all --enable-tests --dry-run --minimize-conflict-set
# From the install plan a dependency list is generated here.
- name: Record dependencies
id: record-deps
run: |
# The tests call out to msys2 commands. We generally do not want to mix toolchains, so
# we are very deliberate about only adding msys64 to the path where absolutely necessary.
${{ (runner.os == 'Windows' && '$env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH)') || '' }}
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
# From the dependency list the cached dependencies is restored.
# The hash of `dependencies.txt` is used as a part of the cache key because that will be stable
# until the `index-state` values in the `cabal.project` file changes.
- name: Restore cached dependencies
uses: actions/cache/restore@v4
id: cache
with:
path: |
${{ steps.setup-haskell.outputs.cabal-store }}
dist-newstyle
key: cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
# The dependencies are installed. If the cache is found and restored in the previous step,
# this should be a no-op. If the cache key is not found the build assets are produced for the
# caching in the next step.
- name: Install dependencies
run: cabal build all --enable-tests --only-dependencies -j --ghc-option=-j4
# Always store the cabal cache.
# This may benignly fail if the cache key is already populated.
- name: Cache Cabal store
uses: actions/cache/save@v4
with:
path: |
${{ steps.setup-haskell.outputs.cabal-store }}
dist-newstyle
key: cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
- name: Build Windows
if: runner.os == 'Windows'
id: build-step-windows
run: |
cabal build all --enable-tests -j --ghc-option=-j4
if ( "${{ runner.os }}" -eq "Windows" ) {
echo "exe-location=D:\a\cardano-addresses\cardano-addresses\dist-newstyle\build\x86_64-windows\ghc-${{ matrix.ghc }}\cardano-addresses-4.0.0\x\cardano-address\build\cardano-address\cardano-address.exe" >> $env:GITHUB_OUTPUT
}
- name: Build Linux/Macos
if: runner.os != 'Windows'
run: cabal build all --enable-tests -j --ghc-option=-j4
- name: Running all tests
env:
# these two are msys2 env vars, they have no effect on non-msys2 installs.
MSYS2_PATH_TYPE: inherit
MSYSTEM: MINGW64
run: cabal test all --enable-tests --test-show-details=direct -j1
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
name: cardano-address-${{ matrix.ghc }}-${{ matrix.os }}
path: ${{ steps.build-step-windows.outputs.exe-location }}
retention-days: 1
- name: Preparing Linux/Macos artifact
if: runner.os != 'Windows'
run: |
mkdir artifacts
for exe in $(cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[] | select(.style == "local" and (."component-name" | startswith("exe:"))) | ."bin-file"'); do
if [ -f $exe ]; then
echo "Including artifact $exe"
artifactName="$(basename $exe).tar.gz"
( cd artifacts
tar -C "$(dirname $exe)" -czf "$(basename $exe).tar.gz" "$(basename $exe)"
)
else
echo "Skipping artifact $exe"
fi
done
echo "artifactPath=artifacts/$(artifactName)" >> $GITHUB_ENV
- name: Upload Linux/Macos artifact
if: runner.os != 'Windows'
uses: actions/upload-artifact@v4
with:
name: cardano-address-${{ matrix.ghc }}-${{ matrix.os }}
path: ${{ env.artifactPath }}
retention-days: 1
release:
name: "Release"
# if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
- name: Pick artifacts to publish and change names
run: |
ls *
sha256sums_filename="cardano-address-4.0.0-sha256sums.txt"
sha256sum cardano-address-*/* >> "$sha256sums_filename"
mv cardano-address-9.6.5-windows-latest/cardano-address.exe cardano-address-4.0.0-win64.exe
mv cardano-address-9.6.5-macos-latest/cardano-address.tar.gz cardano-address-4.0.0-macos.tar.gz
mv cardano-address-9.6.5-ubuntu-latest/cardano-address.tar.gz cardano-address-4.0.0-linux.tar.gz
# - name: Draft Release
# uses: softprops/action-gh-release@v2
# with:
# draft: true
# files: |
# cardano-address-*-win64.exe
# cardano-address-*-macos.tar.gz
# cardano-address-*-linux.tar.gz
# cardano-address-*-sha256sums.txt
#