CI: bumps up actions/*-artifacts
to v4
#91
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Test | |
on: | |
pull_request: | |
branches: ['**'] | |
push: | |
branches: [main] | |
tags: | |
- "v*" | |
workflow_dispatch: | |
inputs: | |
macOS: | |
description: "Builds macOS binaries" | |
type: boolean | |
required: true | |
default: false | |
release_tag: | |
description: "Release Tag" | |
type: string | |
required: false | |
default: "" | |
jobs: | |
fourmolu: | |
name: Fourmolu | |
runs-on: ubuntu-latest | |
steps: | |
# Note that you must checkout your code before running fourmolu/fourmolu-action | |
- uses: actions/checkout@v2 | |
- uses: fourmolu/fourmolu-action@v6 | |
with: | |
pattern: | | |
src/**/*.hs | |
src/**/*.hs-boot | |
src/**/*.lhs | |
app/**/*.hs | |
app/**/*.hs-boot | |
app/**/*.lhs | |
test/**/*.hs | |
test/**/*.hs-boot | |
test/**/*.lhs | |
cabal-check: | |
name: Cabal Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Workaround runner image issue | |
if: ${{ matrix.os == 'Linux' }} | |
# https://github.com/actions/runner-images/issues/7061 | |
run: sudo chown -R "${USER}" /usr/local/.ghcup | |
- uses: haskell-actions/setup@v2 | |
with: | |
cabal-version: 3.10.2.1 | |
ghc-version: 9.6.4 | |
- run: cabal check | |
build: | |
name: Build | |
strategy: | |
matrix: | |
os: [macOS] | |
ghc: ['9.6.4'] | |
image: [''] | |
include: | |
- {os: 'ubuntu', ghc: '9.6.4', image: 'fpco/alpine-haskell-stack:9.2.5'} | |
fail-fast: false | |
env: | |
bin-artifacts: "bin-artifacts" | |
cabal: cabal --project-file=cabal-${{matrix.os}}.project | |
runs-on: ${{matrix.os}}-latest | |
container: | |
image: ${{ matrix.image }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup environment (Linux) | |
if: ${{ runner.os == 'Linux' }} | |
run: | | |
apk add sudo tar zstd xz | |
echo "${HOME}/.local/bin" >> "${GITHUB_PATH}" | |
echo "${HOME}/.cabal/bin" >> "${GITHUB_PATH}" | |
echo "${HOME}/.ghcup/bin" >> "${GITHUB_PATH}" | |
- name: Setup environment (macOS) | |
if: ${{ matrix.os == 'macOS' }} | |
run: | | |
brew install pkg-config | |
- name: Setup Haskell | |
uses: haskell-actions/setup@v2 | |
with: | |
ghc-version: ${{ matrix.ghc }} | |
cabal-version: 3.10.2.1 | |
enable-stack: false | |
- name: Cache Global Cabal | |
uses: actions/cache@v3 | |
with: | |
path: '~/.cabal/store' | |
key: | | |
cabal-global-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}-${{ hashFiles('**/*.cabal')}} | |
restore-keys: | | |
cabal-global-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}- | |
cabal-global-${{ matrix.os }}-${{ matrix.ghc }}- | |
- name: Cache dist-newstyle | |
uses: actions/cache@v3 | |
with: | |
path: 'dist-newstyle' | |
key: | | |
cabal-dist-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}-${{ hashFiles('*.cabal') }}-${{ hashFiles('**/*.hs') }} | |
restore-keys: | | |
cabal-dist-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze', 'cabal-${{matrix.os}}.project') }}-${{ hashFiles('*.cabal') }}- | |
cabal-dist-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze', 'cabal-${{matrix.os}}.project') }}- | |
cabal-dist-${{ matrix.os }}-${{ matrix.ghc }}- | |
- name: "cabal v2-update" | |
shell: bash | |
run: | |
${{ env.cabal }} v2-update 'hackage.haskell.org,2023-02-13T02:00:06Z' | |
- name: "Build" | |
shell: bash | |
run: > | |
${{ env.cabal }} | |
v2-build --enable-tests | |
- name: 'Collect binaries' | |
shell: bash | |
run: | | |
set -euxo pipefail | |
mkdir -p "${{env.bin-artifacts}}" | |
cabal list-bin exe:guardian | while read -r FILE; do | |
echo "COPYING: $(basename "${FILE}") (${FILE})" | |
cp "${FILE}" "${{env.bin-artifacts}}/" | |
done | |
cabal list-bin guardian-test | while read -r FILE; do | |
echo "COPYING: $(basename "${FILE}") (${FILE})" | |
cp "${FILE}" "${{env.bin-artifacts}}/" | |
done | |
- uses: actions/upload-artifact@v4 | |
name: Upload Binary Artifacts | |
with: | |
name: bins-${{ runner.os }} | |
path: ${{ env.bin-artifacts }} | |
test: | |
name: Test | |
needs: [build] | |
strategy: | |
matrix: | |
os: [macOS] | |
ghc: ['9.6.4'] | |
image: [''] | |
include: | |
- os: 'ubuntu' | |
ghc: '9.6.4' | |
image: 'fpco/alpine-haskell-stack:9.2.5' | |
fail-fast: false | |
runs-on: ${{ matrix.os }}-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v4 | |
id: download | |
with: | |
name: bins-${{ runner.os }} | |
- name: Setup permission | |
run: 'chmod +x "${{steps.download.outputs.download-path}}/guardian-test"' | |
- name: Workaround runner image issue | |
if: ${{ matrix.os == 'Linux' }} | |
# https://github.com/actions/runner-images/issues/7061 | |
run: sudo chown -R "${USER}" /usr/local/.ghcup | |
- name: Installs pkg-config (macOS) | |
if: ${{ matrix.os == 'macOS' }} | |
run: brew install pkg-config | |
- uses: haskell-actions/setup@v2 | |
with: | |
ghc-version: 9.6.4 | |
cabal-version: 3.10.2.1 | |
stack-version: 2.15.7 | |
- run: cabal v2-update 'hackage.haskell.org,2023-02-13T02:00:06Z' | |
- name: Installs test tool dependencies | |
run: | | |
cabal install graphmod | |
mkdir -p ~/.local/bin | |
echo "${HOME}/.local/bin" >> "${GITHUB_PATH}" | |
echo "${HOME}/.ghcup/bin" >> "${GITHUB_PATH}" | |
- name: Inspect environments (macOS) | |
if: ${{ matrix.os == 'macOS' }} | |
run: | | |
echo "PATH=${PATH}" | |
ls -R "${HOME}/.ghcup" | |
ls -R "${HOME}/.local" | |
which stack | |
stack --version | |
- name: Intall cabal-plan (Linux) | |
if: ${{ matrix.os == 'ubuntu' }} | |
run: | | |
curl --location 'https://github.com/haskell-hvr/cabal-plan/releases/download/v0.6.2.0/cabal-plan-0.6.2.0-x86_64-linux.xz' | unxz > ~/.local/bin/cabal-plan | |
chmod +x ~/.local/bin/cabal-plan | |
- name: Run tests | |
run: | | |
${{steps.download.outputs.download-path}}/guardian-test | |
release: | |
name: Release | |
env: | |
ghc: 9.6.4 | |
tag: "${{ github.event.inputs.release_tag }}" | |
runs-on: ubuntu-latest | |
needs: [build] | |
if: > | |
github.event_name == 'push' | |
&& | |
startsWith(github.ref, 'refs/tags/v') | |
|| | |
github.event_name == 'workflow_dispatch' | |
&& | |
github.event.inputs.release_tag != '' | |
permissions: | |
contents: write | |
steps: | |
- name: Setup envvars | |
run: | | |
if [ -n "${{env.tag}}" ]; then | |
echo 'RELEASE=${{env.tag}}' >> "${GITHUB_ENV}" | |
else | |
RELEASE=$(echo ${{github.ref_name}} | sed 's/^v//') | |
echo "RELEASE=${RELEASE}" >> "${GITHUB_ENV}" | |
fi | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download Artifact(s) | |
id: download | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ github.workspace }}/artifacts | |
- name: Check Version | |
run: | | |
./scripts/check-version.sh "${RELEASE}" "${{ steps.download.outputs.download-path }}" | |
- name: Make Release on GitHub | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
./scripts/make-release.sh "${RELEASE}" "${{ steps.download.outputs.download-path }}" | |
- name: Creates Tarball | |
run: cabal sdist | |
- name: Upload to Hackage | |
if: > | |
github.event_name == 'push' | |
&& | |
startsWith(github.ref, 'refs/tags/v') | |
uses: haskell-actions/hackage-publish@v1 | |
with: | |
hackageToken: ${{ secrets.HACKAGE_ACCESS_TOKEN }} | |
publish: false | |
packagesPath: dist-newstyle/sdist | |