foliage/.github/workflows/haskell.yml
2022-03-11 14:15:49 +08:00

82 lines
1.9 KiB
YAML

name: Haskell CI
on:
push:
branches:
- main
tags:
- v*
pull_request:
jobs:
build:
runs-on:
- ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Haskell
id: setup-haskell
uses: haskell/actions/setup@v1
with:
ghc-version: '8.10.7'
- name: Cache
uses: actions/cache@v1
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ runner.os }}-${{ github.sha }}
restore-keys: ${{ runner.os }}-
- name: Build dependencies
run: cabal build --only-dependencies
- name: Build
run: cabal build
- name: Test
run: cabal test
- name: Copy artifacts
run: |
mkdir ${{ github.workspace }}/build-artifacts
cabal install --install-method=copy --installdir=${{ github.workspace }}/build-artifacts
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: build-artifact-${{ runner.os }}
path: ${{ github.workspace }}/build-artifacts
if-no-files-found: error
create-release:
if: startsWith(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download build artifact
uses: actions/download-artifact@v3
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Tag artifacts by os (only Linux for now)
mkdir release-artifacts
for path in build-artifact-Linux/*; do
name=${path##*/}
cp $path release-artifacts/$name-Linux
done
# Strip binaries
strip release-artifacts/*
gh release create ${{ github.ref_name }} \
--repo ${{ github.repository }} --draft --generate-notes \
release-artifacts/*