ical support working #21
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 | |
on: | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- '**.hs' | |
- 'stack.yaml' | |
- 'package.yaml' | |
- '**.cabal' | |
push: | |
branches: | |
- main | |
paths: | |
- '**.hs' | |
- 'stack.yaml' | |
- 'package.yaml' | |
- '**.cabal' | |
tags-ignore: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
jobs: | |
hlint: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: haskell/actions/hlint-setup@v1 | |
- uses: haskell/actions/hlint-run@v2 | |
fourmolu: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: haskell-actions/run-fourmolu@v9 | |
with: | |
# Only check the format of .hs in any directory inside cwd but not cwd. | |
pattern: | | |
*/**/*.hs | |
build-binaries: | |
name: Build and test binaries (${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
stack-build-args: -j2 | |
- os: macos-latest | |
stack-build-args: -j3 | |
- os: windows-latest | |
stack-build-args: -j2 --flag hexpat:bundle | |
steps: | |
# SETUP | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- uses: haskell/actions/setup@v2 | |
with: | |
ghc-version: '9.4.5' | |
enable-stack: true | |
stack-no-global: true | |
# CACHING | |
- name: Cache .stack-work | |
uses: actions/cache@v3 | |
with: | |
path: .stack-work/ | |
key: ${{ runner.os }}-store-${{ hashFiles('stack.yaml.lock') }}-${{ hashFiles('schedule-maker.cabal') }} | |
- name: Cache dependencies (Unix) | |
uses: actions/cache@v3 | |
if: matrix.os != 'windows-latest' | |
with: | |
path: ~/.stack | |
key: ${{ runner.os }}-store-${{ hashFiles('stack.yaml.lock') }}-${{ hashFiles('schedule-maker.cabal') }} | |
- name: Cache dependencies (Windows) | |
uses: actions/cache@v3 | |
if: matrix.os == 'windows-latest' | |
with: | |
path: C:\sr # 'C:\Users\runneradmin\AppData\Roaming\stack' | |
key: ${{ runner.os }}-store-${{ hashFiles('stack.yaml.lock') }}-${{ hashFiles('schedule-maker.cabal') }} | |
- name: Cache GHC (Windows) | |
uses: actions/cache@v3 | |
if: matrix.os == 'windows-latest' | |
with: | |
path: 'C:\Users\runneradmin\AppData\Local\Programs\stack' | |
key: ghc-${{ hashFiles('stack.yaml.lock') }} | |
# BUILD | |
- name: Build (${{ runner.os }}) | |
shell: bash | |
run: stack build --local-bin-path="$(pwd)/schedule-maker-x86_64-${{ runner.os }}" --copy-bins --ghc-options=-O2 ${{ matrix.stack-build-args }} | |
# UPLOAD BINARIES | |
- name: Compress dirs (Unix) | |
if: matrix.os != 'windows-latest' | |
shell: bash | |
run: zip -r schedule-maker-x86_64-${{ runner.os }}.zip schedule-maker-x86_64-${{ runner.os }} | |
- name: Compress dirs (Windows) | |
if: matrix.os == 'windows-latest' | |
shell: pwsh | |
run: Compress-Archive -Path "schedule-maker-x86_64-${{ runner.os }}" -DestinationPath "schedule-maker-x86_64-${{ runner.os }}.zip" | |
- name: Upload artifact (${{ runner.os }}) | |
uses: actions/upload-artifact@v3 | |
with: | |
name: schedule-maker-x86_64-${{ runner.os }} | |
path: schedule-maker-x86_64-${{ runner.os }}.zip | |
if-no-files-found: error | |
pre-release: | |
name: "Pre Release" | |
needs: build-binaries | |
if: github.event_name != 'pull_request' | |
permissions: | |
contents: write | |
runs-on: "ubuntu-latest" | |
steps: | |
- uses: actions/download-artifact@v3 | |
- name: Check artifacts | |
run: ls -R | |
- name: Create short commit sha | |
run: echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-10)" >> $GITHUB_ENV | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: Pre-release ${{ env.GITHUB_SHA_SHORT }} | |
draft: false | |
prerelease: true | |
tag_name: Pre-release-${{ env.GITHUB_SHA_SHORT }} | |
fail_on_unmatched_files: true | |
generate_release_notes: true | |
files: 'schedule-maker-x86_64-**/schedule-maker-x86_64-*' |