-
Notifications
You must be signed in to change notification settings - Fork 2
280 lines (238 loc) · 8.93 KB
/
github-actions-image.yaml
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
name: Github Action Docker Image
on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types: [prereleased]
jobs:
check-formatting:
name: Check Haskell formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Common setup
uses: ./.github/actions/common_setup
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Run fourmolu
run: |
nix-shell nix/ci.nix -j auto --run "git ls-files '*.hs' | xargs fourmolu -m inplace -o -XRecursiveDo -o -XTypeApplications -o -XPatternSynonyms -o -XBangPatterns"
git diff --exit-code
check_versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Check library version
if: github.event_name == 'release'
run: |
if [ "$(awk -F ':' '/^version/ {gsub(/ /, "", $2); print $2}' compaREST.cabal)" != "${{ github.event.release.tag_name }}" ]; then
echo "::error file=compaREST.cabal::Library version does not match release version."
exit 1
fi
- name: Check docker tag
if: github.event_name == 'release'
run: |
if [ "$(yq eval '.runs.image' action.yaml | awk -F ':' '{print $NF}')" != "${{ github.event.release.tag_name }}" ]; then
echo "::error file=action.yaml::Action docker tag does not match release tag."
exit 1
fi
- name: Check changelog
if: github.event_name == 'release'
run: |
if ! grep '^## ${{ github.event.release.tag_name }}$' CHANGELOG.md; then
echo "::error file=CHANGELOG.md::CHANGELOG.md does not contain an entry for this release."
exit 1
fi
Linux:
needs: check_versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Common setup
uses: ./.github/actions/common_setup
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Test
shell: bash
run: |
$(nix-build -A test -j auto --no-out-link)/bin/compaREST-tests
- name: Build Linux static binary
shell: bash
run: |
cp $(nix-build -A compaRESTStaticBin -j auto --no-out-link)/bin/compaREST compaREST
- name: Upload compaREST Linux Binary
uses: actions/upload-artifact@v2
with:
name: compaREST-Linux
path: compaREST
- name: Build Docker Images
shell: bash
run: |
cp $(nix-build -A compaRESTGithubAction -j auto --no-out-link) compaREST-Github-Action-image.tar.gz
cp $(nix-build -A compaRESTImage -j auto --no-out-link) compaREST-image.tar.gz
- name: Upload compaREST Docker Github Action Image
uses: actions/upload-artifact@v2
with:
name: compaREST Github Action Docker Image
path: compaREST-Github-Action-image.tar.gz
- name: Upload compaREST Docker Image
uses: actions/upload-artifact@v2
with:
name: compaREST Docker Image
path: compaREST-image.tar.gz
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Push Nightly Docker Images to DockerHub
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
shell: bash
run: |
skopeo copy docker-archive:$(nix-build -A compaRESTGithubAction -j auto --no-out-link) docker://typeable/comparest-github-action:nightly
skopeo copy docker-archive:$(nix-build -A compaRESTImage -j auto --no-out-link) docker://typeable/comparest:nightly
- name: Push Release Docker Images to DockerHub
if: github.event_name == 'release'
shell: bash
run: |
skopeo copy docker-archive:$(nix-build -A compaRESTGithubAction -j auto --no-out-link) docker://typeable/comparest-github-action:${{ github.event.release.tag_name }}
skopeo copy docker-archive:$(nix-build -A compaRESTImage -j auto --no-out-link) docker://typeable/comparest:${{ github.event.release.tag_name }}
- name: Zip Release Assets
if: github.event_name == 'release'
shell: bash
run: |
zip compaREST-Linux-x86.zip compaREST
- name: Upload compaREST Github Action Docker Image to release
if: github.event_name == 'release'
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: compaREST-Github-Action-image.tar.gz
tag: ${{ github.ref }}
- name: Upload compaREST Docker Image to release
if: github.event_name == 'release'
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: compaREST-image.tar.gz
tag: ${{ github.ref }}
- name: Upload compaREST binary – Linux – x86 to release
if: github.event_name == 'release'
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: compaREST-Linux-x86.zip
tag: ${{ github.ref }}
dist:
needs: check_versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Cache
uses: actions/cache@v1
with:
path: |
~/.stack
.stack-work
key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**.cabal') }}
restore-keys: |
${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}
${{ runner.os }}-stack
- name: Upgrade stack
shell: bash
# Needed for Hackage token authorization
run: stack upgrade --git
- name: Build dist
run: |
stack sdist --pvp-bounds both --test-tarball
echo "distPath=$(stack path | awk -F ": " '/dist-dir/ {print $2}')" >> $GITHUB_ENV
- name: Upload compaREST sources artifact
uses: actions/upload-artifact@v2
with:
name: compaREST sources
path: ${{ env.distPath }}/*.tar.gz
- name: Upload compaREST sources to release
if: github.event_name == 'release'
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: ${{ env.distPath }}/*.tar.gz
tag: ${{ github.ref }}
- name: Publish compaREST candidate to Hackage
shell: bash
if: github.event_name == 'release'
env:
HACKAGE_KEY: ${{ secrets.HACKAGE_KEY }}
run: |
stack upload --pvp-bounds both --test-tarball --candidate .
macOS:
needs: check_versions
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Common setup
uses: ./.github/actions/common_setup
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Build macOS binary bundle
run: |
cp -LR $(nix-build -A macOSCompaRESTBundle -j auto --no-out-link) compaREST
- name: Upload macOS compaREST bundle
uses: actions/upload-artifact@v2
with:
name: compaREST binary – macOS – x86
path: compaREST
- name: Zip Release Assets
if: github.event_name == 'release'
shell: bash
run: |
zip -r compaREST-macOS-x86.zip compaREST
- name: Upload compaREST binary – macOS – x86 to release
if: github.event_name == 'release'
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: compaREST-macOS-x86.zip
tag: ${{ github.ref }}
Linux-Windows:
needs: check_versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Common setup
uses: ./.github/actions/common_setup
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Build Windows binary
run: |
cp -LR $(nix-build -A WindowsCompaRESTBin -j auto --no-out-link)/bin compaREST
- name: Upload Windows compaREST bundle
uses: actions/upload-artifact@v2
with:
name: compaREST binary – Windows
path: compaREST
- name: Zip Release Assets
if: github.event_name == 'release'
shell: bash
run: |
zip -r compaREST-Windows.zip compaREST
- name: Upload compaREST binary – Windows to release
if: github.event_name == 'release'
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: compaREST-Windows.zip
tag: ${{ github.ref }}