-
Notifications
You must be signed in to change notification settings - Fork 6
280 lines (240 loc) · 8.99 KB
/
ci.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
name: CI
on: [push]
jobs:
build:
name: Built and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- name: Use Node.js 16.x
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/setup-node@v1
with:
node-version: 16.x
- name: Restore global node modules cache
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install esy
run: npm install -g [email protected]
- name: Restore esy source cache
id: esy-cache
uses: actions/cache@v2
with:
path: ~/.esy/source
key: source-${{ matrix.os }}-${{ hashFiles('**/index.json') }}
- name: Install
run: esy install
- name: Print esy cache
id: print_esy_cache
run: node scripts/print-esy-cache.js
- name: Try to restore dependencies cache
id: deps-cache
uses: actions/cache@v2
with:
path: ${{ steps.print_esy_cache.outputs.esy_cache }}
key: deps-${{ matrix.os }}-${{ hashFiles('**/index.json') }}
restore-keys: deps-${{ matrix.os }}-
- name: Build dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: esy build-dependencies
- name: Build
run: esy build
- name: Test
if: ${{ matrix.os != 'windows-latest' }}
run: |
rm test/__snapshots__/.gitkeep
esy dune runtest --instrument-with bisect_ppx --force
esy bisect-ppx-report send-to Coveralls
env:
BISECT_SILENT: "ERR"
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
PULL_REQUEST_NUMBER: ${{ github.event.number }}
- name: Web build
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
esy b dune build
cd website
npm ci
npm run build-production
- name: Deploy to prod
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name != 'pull_request' }}
working-directory: ./website
env:
SITE_ID: ${{ secrets.SITE_ID }}
AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
run:
npx netlify deploy --site $SITE_ID --auth $AUTH_TOKEN --prod --dir=build
- name: Deploy preview
if: ${{ matrix.os == 'ubuntu-latest' }}
working-directory: ./website
env:
SITE_ID: ${{ secrets.SITE_ID }}
AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
run:
npx netlify deploy --site $SITE_ID --auth $AUTH_TOKEN --dir=build
- name: Upload artifacts for ${{ matrix.os }}
uses: actions/upload-artifact@master
with:
name: ${{ matrix.os }}-artifact
path: _build/default/bin/Bin.exe
- name: Upload JavaScript artifacts for NPM
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@master
with:
name: bundled
path: _build/default/js/Js.bc.js
# Cleanup build cache if dependencies have changed
- name: Clean build cache
if: steps.deps-cache.outputs.cache-hit != 'true'
run: esy cleanup .
publish:
needs: build
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Generate NPM package and release
run: node scripts/make-npm-release.js
- name: Download JavaScript artifact
if: ${{ success() }}
uses: actions/download-artifact@master
with:
name: bundled
path: _release/bundled
- name: Download linux artifacts
if: ${{ success() }}
uses: actions/download-artifact@master
with:
name: ubuntu-latest-artifact
path: _release/platform-linux-x64
- name: Download macOS artifacts
if: ${{ success() }}
uses: actions/download-artifact@master
with:
name: macos-latest-artifact
path: _release/platform-darwin-x64
- name: Download windows artifacts
uses: actions/download-artifact@master
with:
name: windows-latest-artifact
path: _release/platform-windows-x64
- name: Publish query-json from linux artifcats
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cp _release/platform-linux-x64/Bin.exe ./query-json
chmod +x query-json
- name: Create archives for Github release
run: |
cd _release/platform-darwin-x64
mv Bin.exe query-json
zip -r ../../query-json-darwin-x64.zip .
cd ../..
cd _release/platform-linux-x64
mv Bin.exe query-json
zip -r ../../query-json-linux-x64.zip .
cd ../..
cd _release/platform-windows-x64
mv Bin.exe query-json
zip -r ../../query-json-windows-x64.zip .
cd ../..
- name: End to end Test (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: npx bats ./e2e/test.sh
env:
IS_CI: true
- name: End to end Test (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: sh -c 'npx bats ./e2e/test.sh' \"$(pwd)/node_modules/bats/bin/bats\"
env:
IS_CI: true
- name: Check if should be published
if: ${{ success() && github.event_name != 'pull_request' }}
id: newVersion
run: |
REMOTE=$(npm view @davesnx/query-json version);
CURRENT=$(jq -r '.version' esy.json);
if [ "$REMOTE" != "$CURRENT" ]
then
echo "::set-output name=shouldPublish::true";
else
echo "::set-output name=shouldPublish::false";
fi
- name: Publish
if: ${{ success() && github.event_name != 'pull_request' && steps.newVersion.outputs.shouldPublish == 'true' }}
run: |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm config set scope "@davesnx"
npm publish --access public
working-directory: ./_release
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- name: Print short SHA
id: sha
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Publish Prerelease
if: ${{ github.event_name == 'pull_request' }}
run: |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm config set scope "@davesnx"
npm version prerelease -preid ${{ steps.sha.outputs.sha_short }} -no-git-tag-version
npm publish --tag=dev --access public
working-directory: ./_release
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- name: Create Github release
if: ${{ success() && steps.newVersion.outputs.shouldPublish == 'true' }}
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.sha.outputs.sha_short }}
release_name: Release ${{ steps.sha.outputs.sha_short }}
draft: false
prerelease: true
- name: Upload query-json-darwin-x64.zip to Github release
if: ${{ success() && steps.newVersion.outputs.shouldPublish == 'true' }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: query-json-darwin-x64.zip
asset_name: query-json-darwin-x64.zip
asset_content_type: application/gzip
- name: Upload query-json-linux-x64.zip to Github release
if: ${{ success() && steps.newVersion.outputs.shouldPublish == 'true' }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: query-json-linux-x64.zip
asset_name: query-json-linux-x64.zip
asset_content_type: application/gzip
- name: Upload query-json-windows-x64.zip to Github release
if: ${{ success() && steps.newVersion.outputs.shouldPublish == 'true' }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: query-json-windows-x64.zip
asset_name: query-json-windows-x64.zip
asset_content_type: application/gzip