-
Notifications
You must be signed in to change notification settings - Fork 1
216 lines (192 loc) · 7.82 KB
/
stack.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# Source: github.com/andreasabel/agda2lagda/.github/workflows/stack.yml
name: Stack build
on:
push:
branches: [ master, 'ci-*' ]
tags: [ 'v*' ]
pull_request:
types: [ opened, synchronize]
workflow_dispatch:
# For making a release, we need write permissions.
# TODO: if we split out a release job from the build job, we could make permissions more fine-grained.
permissions:
contents: write
jobs:
build:
name: GHC ${{ matrix.ghc }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Note: check release logic below when changing the matrix!
ghc: [9.2.2, 9.0.2, 8.10.7, 8.8.4, 8.6.5, 8.4.4, 8.2.2, 8.0.2]
os: [ubuntu-latest]
include:
- os: macOS-latest
ghc: 9.2.2
- os: windows-latest
ghc: 9.2.2
# Needed for Windows to make piping (... >> ...) and evaluation ( $(...) ) work.
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2 # latest (2020-12-21): v2.3.4
- name: Setup Haskell
uses: haskell/actions/setup@v1
# latest (2020-12-21): v1.1.5
# latest (2021-08-19): v1.2.3
id: haskell-setup # <-- self-chosen identifier
with:
ghc-version: ${{ matrix.ghc }}
enable-stack: true
# stack-version: latest
- name: Environment settings based on the Haskell setup
shell: bash
run: |
echo "runner.os = ${{ runner.os }}"
echo "ghc-path = ${{ steps.haskell-setup.outputs.ghc-path }}"
echo "cabal-path = ${{ steps.haskell-setup.outputs.cabal-path }}"
echo "stack-path = ${{ steps.haskell-setup.outputs.stack-path }}"
echo "cabal-store = ${{ steps.haskell-setup.outputs.cabal-store }}"
echo "ghc-exe = ${{ steps.haskell-setup.outputs.ghc-exe }}"
echo "cabal-exe = ${{ steps.haskell-setup.outputs.cabal-exe }}"
echo "stack-exe = ${{ steps.haskell-setup.outputs.stack-exe }}"
echo "stack-root = ${{ steps.haskell-setup.outputs.stack-root }}"
export GHC_VER=$(ghc --numeric-version)
export CABAL_VER=$(cabal --numeric-version)
export STACK_VER=$(stack --numeric-version)
export STACK_FLAGS="--stack-yaml stack-${GHC_VER}.yaml --system-ghc --no-terminal --color always"
export TARGET=$(if [ "${{ runner.os }}" == "Windows" ]; then echo ":bnfc"; fi)
echo "GHC_VER = ${GHC_VER}"
echo "CABAL_VER = ${CABAL_VER}"
echo "STACK_VER = ${STACK_VER}"
echo "STACK_FLAGS = ${STACK_FLAGS}"
echo "TARGET = ${TARGET}"
echo "GHC_VER=${GHC_VER}" >> ${GITHUB_ENV}
echo "CABAL_VER=${CABAL_VER}" >> ${GITHUB_ENV}
echo "STACK_VER=${STACK_VER}" >> ${GITHUB_ENV}
echo "STACK_FLAGS=${STACK_FLAGS}" >> ${GITHUB_ENV}
echo "TARGET=${TARGET}" >> ${GITHUB_ENV}
# Stack build TARGET restriction on Windows as it cannot build the 'testing' package.
# From now on, use env.{GHC|CABAL}_VER rather than matrix.{ghc|cabal}-ver!
- name: Cache dependencies
# if: runner.os == 'Linux'
uses: actions/cache@v2 # latest (2020-12-21): v2.1.3
with:
path: ${{ steps.haskell-setup.outputs.stack-root }}
# A unique cache is used for each stack.yaml.
key: ${{ runner.os }}-${{ env.STACK_VER }}-${{ hashFiles(format('stack-{0}.yaml', env.GHC_VER)) }}
- name: Build dependencies.
run: stack build ${{ env.TARGET }} ${{ env.STACK_FLAGS }} --only-dependencies
- name: Build bnfc w/o tests.
run: stack build ${{ env.TARGET }} ${{ env.STACK_FLAGS }}
- name: Build bnfc and run tests.
run: stack build ${{ env.TARGET }} ${{ env.STACK_FLAGS }} --test
# # matrix.ghc != '8.4.4' &&
# if: >-
# matrix.ghc != '8.2.2' &&
# matrix.ghc != '8.0.2'
# Fall back to string comparison as version-comparison does not seem to work.
# Exclude the versions that do not support bnfc-system-tests
- name: Run bnfc.
run: |
export BNFC_EXE=$(stack path --local-install-root ${{ env.STACK_FLAGS }})/bin/bnfc
export BNFC_VERSION=$(${BNFC_EXE} --numeric-version)
# Save env variables for the next steps
echo "BNFC_EXE=${BNFC_EXE}" >> ${GITHUB_ENV}
echo "BNFC_VERSION=${BNFC_VERSION}" >> ${GITHUB_ENV}
## Release
########################################################################
- name: Source tarball creation.
# Conditional to ensure this deployment is only run once per action.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& matrix.ghc == '9.2.2'
run: |
export DIST_TGZ=$(cabal sdist source | tail -1)
echo "DIST_TGZ=${DIST_TGZ}" >> ${GITHUB_ENV}
- name: Source tarball release.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& matrix.ghc == '9.2.2'
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
files: |
${{ env.DIST_TGZ }}
- name: Linux release preparation.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'Linux'
&& matrix.ghc == '9.2.2'
run: |
export BNFC_BIN=bnfc-${BNFC_VERSION}-linux.binary
cp -p ${BNFC_EXE} ${BNFC_BIN}
# Save env variables for the next step
echo "BNFC_BIN=${BNFC_BIN}" >> ${GITHUB_ENV}
- name: Linux release.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'Linux'
&& matrix.ghc == '9.2.2'
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
files: |
${{ env.BNFC_BIN }}
- name: Mac release preparation.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'macOS'
run: |
export BNFC_BIN=bnfc-${BNFC_VERSION}-mac.binary
export BNFC_PKG=bnfc-${BNFC_VERSION}-mac.pkg
# Raw Mac binary
cp -p ${BNFC_EXE} ${BNFC_BIN}
# Build Mac package
mkdir -p tmp/usr/local/bin
cp -p ${BNFC_EXE} tmp/usr/local/bin/bnfc
pkgbuild \
--root tmp \
--identifier com.digitalgrammars.bnfc.pkg \
--version ${BNFC_VERSION} \
--install-location / \
--ownership recommended \
${BNFC_PKG}
# Save env variables for the next step
echo "BNFC_BIN=${BNFC_BIN}" >> ${GITHUB_ENV}
echo "BNFC_PKG=${BNFC_PKG}" >> ${GITHUB_ENV}
- name: Mac release.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'macOS'
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
files: |
${{ env.BNFC_BIN }}
${{ env.BNFC_PKG }}
- name: Windows release preparation.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'Windows'
shell: bash
run: |
export BNFC_VER_EXE=bnfc-${BNFC_VERSION}.exe
cp -p ${BNFC_EXE}.exe ${BNFC_VER_EXE}
# Save env variables for the next step
echo "BNFC_VER_EXE=${BNFC_VER_EXE}" >> ${GITHUB_ENV}
- name: Windows release.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'Windows'
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
files: |
${{ env.BNFC_VER_EXE }}