2022-03-09 16:36:46 +03:00
|
|
|
name: Haskell CI
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2022-03-10 07:22:13 +03:00
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
tags:
|
|
|
|
- v*
|
2022-03-09 16:36:46 +03:00
|
|
|
pull_request:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
2022-03-10 07:22:13 +03:00
|
|
|
runs-on:
|
|
|
|
- ubuntu-latest
|
2022-03-09 16:36:46 +03:00
|
|
|
|
2022-03-10 07:22:13 +03:00
|
|
|
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
|
2022-03-09 16:36:46 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
2022-03-10 07:22:13 +03:00
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
|
2022-03-09 16:36:46 +03:00
|
|
|
steps:
|
2022-03-10 07:22:13 +03:00
|
|
|
- name: Download build artifact
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
|
|
|
|
- name: Create release
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run: |
|
2022-03-11 08:52:11 +03:00
|
|
|
# Tag artifacts by os (only Linux for now)
|
2022-03-10 07:22:13 +03:00
|
|
|
mkdir release-artifacts
|
|
|
|
for path in build-artifact-Linux/*; do
|
|
|
|
name=${path##*/}
|
2022-03-11 08:52:11 +03:00
|
|
|
cp $path release-artifacts/$name-Linux
|
2022-03-10 07:22:13 +03:00
|
|
|
done
|
|
|
|
|
2022-03-11 09:15:49 +03:00
|
|
|
# Strip binaries
|
|
|
|
strip release-artifacts/*
|
|
|
|
|
2022-03-10 07:22:13 +03:00
|
|
|
gh release create ${{ github.ref_name }} \
|
|
|
|
--repo ${{ github.repository }} --draft --generate-notes \
|
|
|
|
release-artifacts/*
|