-
Notifications
You must be signed in to change notification settings - Fork 1
140 lines (124 loc) · 4.16 KB
/
pre-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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-*'