-
Notifications
You must be signed in to change notification settings - Fork 5
296 lines (258 loc) · 9.4 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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
name: Build by Stack
on:
push:
branches:
- master
- ci*
tags:
- v*
pull_request:
branches:
- master
- ci*
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:
## Release preparation
##########################################################################
# From: https://github.com/RobLoach/node-raylib/blob/aca2956e9ed283e5e91b1c8f08fafd943b5d6344/.github/workflows/release.yml
create_release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
# outputs:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
# - name: Create release
# id: create_release
# uses: actions/create-release@v1
# with:
# draft: false
# prerelease: false
# release_name: fix-whitespace ${{ github.ref }}
# tag_name: ${{ github.ref }}
# # body: fix-whitespace binary release created from ${{ github.ref }}
# env:
# GITHUB_TOKEN: ${{ github.token }}
- name: Source tarball creation
run: |
cabal sdist
DIST_TGZ_PATH=$(cabal sdist | tail -1)
DIST_TGZ_NAME=$(basename "${DIST_TGZ_PATH}")
echo "DIST_TGZ_PATH=${DIST_TGZ_PATH}" >> "${GITHUB_ENV}"
echo "DIST_TGZ_NAME=${DIST_TGZ_NAME}" >> "${GITHUB_ENV}"
# - name: Source tarball release
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ${{ env.DIST_TGZ_PATH }}
# asset_name: ${{ env.DIST_TGZ_NAME }}
# asset_content_type: application/octet-stream
- name: Create release, upload source tarball
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release create ${{ github.ref }} "${{ env.DIST_TGZ_PATH }}#${{ env.DIST_TGZ_NAME }}" --title "fix-whitespace ${{ github.ref }}" --generate-notes
build:
# Run this job even if the previous was skipped.
if: ${{ !failure() }}
runs-on: ${{ matrix.os }}
needs: create_release
strategy:
matrix:
os: [ubuntu-latest]
ghc-ver: ['9.10', '9.8', '9.6', '9.4', '9.2.8', '9.0.2', '8.10.7', '8.8.4', '8.6.5', '8.4.4']
include:
- os: windows-latest
ghc-ver: '9.10'
- os: macos-latest
ghc-ver: '9.10'
fail-fast: false
env:
ARGS: "--stack-yaml stack-${{ matrix.ghc-ver }}.yaml --no-terminal --system-ghc"
# Needed for Windows to make piping (... >> ...) and evaluation ( $(...) ) work.
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.ghc-ver }}
stack-version: 'latest'
enable-stack: true
- name: Restore cache dependencies
uses: actions/cache/restore@v4
id: cache
env:
key: ${{ runner.os }}-stack-${{ steps.setup.outputs.stack-version }}-ghc-${{ steps.setup.outputs.ghc-version }}
with:
path: ${{ steps.setup.outputs.stack-root }}
# # A unique cache is used for each stack.yaml.
# key: ${{ env.key }}-${{ hashFiles(format('stack-{0}.yaml', matrix.ghc-ver)) }}
# Use simpler key scheme as we should not run out of cache due to the low frequency of PRs.
key: ${{ env.key }}-commit-${{ github.sha }}
# Let us restore caches from the same GHC version, at the risk of accumulating some cruft from older resolvers.
restore-keys: ${{ env.key }}-
- name: Install dependencies
# if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: |
stack build ${ARGS} --only-dependencies
- name: Build fix-whitespace
run: |
stack build ${ARGS}
- name: Check the whitespace issue
run: |
stack exec ${ARGS} -- fix-whitespace --check
- name: Cache dependencies
uses: actions/cache/save@v4
if: always() && steps.cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.setup.outputs.stack-root }}
key: ${{ steps.cache.outputs.cache-primary-key }}
- name: Get fix-whitespace version
run: |
FIXW_EXE=$(stack path --local-install-root ${ARGS})/bin/fix-whitespace
FIXW_VERSION=$("${FIXW_EXE}" --version)
# Save env variables for the next steps
echo "FIXW_EXE=${FIXW_EXE}" >> "${GITHUB_ENV}"
echo "FIXW_VERSION=${FIXW_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-ver == '9.10'
# run: |
# DIST_TGZ=$(cabal sdist | tail -1)
# echo "DIST_TGZ=${DIST_TGZ}" >> "${GITHUB_ENV}"
# - name: Source tarball release
# if: >-
# startsWith(github.ref, 'refs/tags/v')
# && matrix.ghc-ver == '9.10'
# # uses: softprops/action-gh-release@v1
# # with:
# # draft: true
# # prerelease: true
# # files: |
# # ${{ env.DIST_TGZ }}
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# upload_url: ${{ needs.create_release.outputs.upload_url }}
# asset_path: ${{ env.DIST_TGZ }}
# asset_name: ${{ env.DIST_TGZ }}
# asset_content_type: application/octet-stream
- name: Linux release preparation
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'Linux'
&& matrix.ghc-ver == '9.10'
run: |
FIXW_BIN=fix-whitespace-${FIXW_VERSION}-linux.binary
cp -p "${FIXW_EXE}" "${FIXW_BIN}"
# Save env variables for the next step
echo "FIXW_BIN=${FIXW_BIN}" >> "${GITHUB_ENV}"
# - name: Linux release
# if: >-
# startsWith(github.ref, 'refs/tags/v')
# && runner.os == 'Linux'
# && matrix.ghc-ver == '9.10'
# # uses: softprops/action-gh-release@v1
# # with:
# # draft: true
# # prerelease: true
# # files: |
# # ${{ env.FIXW_BIN }}
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# upload_url: ${{ needs.create_release.outputs.upload_url }}
# asset_path: ${{ env.FIXW_BIN }}
# asset_name: ${{ env.FIXW_BIN }}
# asset_content_type: application/octet-stream
- name: Mac release preparation
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'macOS'
run: |
FIXW_BIN=fix-whitespace-${FIXW_VERSION}-mac.binary
# Raw Mac binary
cp -p "${FIXW_EXE}" "${FIXW_BIN}"
# Save env variables for the next step
echo "FIXW_BIN=${FIXW_BIN}" >> "${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.FIXW_BIN }}
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# upload_url: ${{ needs.create_release.outputs.upload_url }}
# asset_path: ${{ env.FIXW_BIN }}
# asset_name: ${{ env.FIXW_BIN }}
# asset_content_type: application/octet-stream
- name: Windows release preparation
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'Windows'
shell: bash
run: |
FIXW_BIN=fix-whitespace-${FIXW_VERSION}.exe
cp -p "${FIXW_EXE}.exe" "${FIXW_BIN}"
# Save env variables for the next step
echo "FIXW_BIN=${FIXW_BIN}" >> "${GITHUB_ENV}"
# - name: Windows release
# if: >-
# startsWith(github.ref, 'refs/tags/v')
# && runner.os == 'Windows'
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# upload_url: ${{ needs.create_release.outputs.upload_url }}
# asset_path: ${{ env.FIXW_BIN }}
# asset_name: ${{ env.FIXW_BIN }}
# asset_content_type: application/octet-stream
# # uses: softprops/action-gh-release@v1
# # with:
# # draft: true
# # prerelease: true
# # files: |
# # ${{ env.FIXW_VER_EXE }}
# - name: Upload binary
# if: >-
# startsWith(github.ref, 'refs/tags/v')
# && (matrix.ghc-ver == '9.10' || runner.os != 'Linux')
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# upload_url: ${{ needs.create_release.outputs.upload_url }}
# asset_path: ${{ env.FIXW_BIN }}
# asset_name: ${{ env.FIXW_BIN }}
# asset_content_type: application/octet-stream
- name: Upload binary
if: >-
startsWith(github.ref, 'refs/tags/v')
&& (matrix.ghc-ver == '9.10' || runner.os != 'Linux')
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release upload ${{ github.ref }} "${{ env.FIXW_BIN }}" --clobber