-
-
Notifications
You must be signed in to change notification settings - Fork 423
528 lines (455 loc) · 15.2 KB
/
build-and-package.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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
name: BuildAndPackage
on:
push:
tags:
- "v*"
branches: master
pull_request:
branches: master
paths-ignore:
- "*.md"
- "*.markdown"
- "mkdocs/**/*"
tags-ignore:
- "*"
jobs:
version_info:
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- id: vars
run: |
set -x -e
echo "github event ref is ${{ github.ref }}"
if [ "x${{ startsWith(github.ref, 'refs/tags/v') }}" == "xtrue" ]
then
echo "Trigger was a version tag - ${{ github.ref }}"
echo ::set-output name=q_version::${GITHUB_REF#refs/tags/v}
echo ::set-output name=is_release::true
else
# For testing version propagation inside the PR
echo "Either branch of a non-version tag - setting version to 0.0.0"
echo ::set-output name=q_version::0.0.0
echo ::set-output name=is_release::false
fi
outputs:
q_version: ${{ steps.vars.outputs.q_version }}
is_release: ${{ steps.vars.outputs.is_release }}
check_version_info:
runs-on: ubuntu-18.04
needs: version_info
steps:
- name: test q_version
run: |
set -e -x
echo "outputs: ${{ toJson(needs.version_info) }}"
create-man:
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.6'
- name: Create man page
run: |
set -x -e
gem install ronn
ronn doc/USAGE.markdown
# Must be gzipped, otherwise debian does not install it
gzip doc/USAGE
- name: Upload man page
uses: actions/upload-artifact@v1.0.0
with:
name: q-man-page
path: doc/USAGE.gz
build-linux:
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache pyox
uses: actions/cache@v2
with:
path: |
~/.cache/pyoxidizer
key: ${{ runner.os }}-pyox
- name: Install pyoxidizer
run: |
set -e -x
sudo apt-get update
sudo apt-get install -y zip sqlite3 rpm
curl -o pyoxidizer.zip -L "https://github.com/indygreg/PyOxidizer/releases/download/pyoxidizer%2F0.17/pyoxidizer-0.17.0-linux_x86_64.zip"
unzip pyoxidizer.zip
chmod +x ./pyoxidizer
- name: Create Q Executable - Linux
run: |
set -e -x
./pyoxidizer build --release
export Q_EXECUTABLE=./build/x86_64-unknown-linux-gnu/release/install/q
chmod 755 $Q_EXECUTABLE
seq 1 100 | $Q_EXECUTABLE -c 1 "select sum(c1),count(*) from -" -S test.sqlite
mkdir -p packages/linux/
cp $Q_EXECUTABLE packages/linux/linux-q
- name: Upload Linux Executable
uses: actions/upload-artifact@v1.0.0
with:
name: linux-q
path: packages/linux/linux-q
test-linux:
needs: build-linux
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Python for Testing
uses: actions/setup-python@v2
with:
python-version: '3.8.12'
architecture: 'x64'
- name: Prepare Testing
run: |
set -e -x
pip3 install -r test-requirements.txt
- name: Download Linux Executable
uses: actions/download-artifact@v2
with:
name: linux-q
- name: Run Tests on Linux Executable
run: |
set -x -e
find ./ -ls
chmod 755 ./linux-q
Q_EXECUTABLE=`pwd`/linux-q Q_SKIP_EXECUTABLE_VALIDATION=true ./run-tests.sh -v
package-linux-deb:
needs: [test-linux, create-man, version_info]
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.6'
- name: Downoad man page
uses: actions/download-artifact@v2
with:
name: q-man-page
- name: Download Linux Executable
uses: actions/download-artifact@v2
with:
name: linux-q
- name: Build DEB Package
run: |
set -e -x
mkdir -p packages/linux/
find ./ -ls
chmod 755 ./linux-q
export q_version=${{ needs.version_info.outputs.q_version }}
gem install fpm
cp dist/fpm-config ~/.fpm
fpm -s dir -t deb --deb-use-file-permissions -p packages/linux/q-text-as-data-${q_version}-1.x86_64.deb --version ${q_version} ./linux-q=/usr/bin/q USAGE.gz=/usr/share/man/man1/q.1.gz
- name: Upload DEB Package
uses: actions/upload-artifact@v1.0.0
with:
name: q-text-as-data-${{ needs.version_info.outputs.q_version }}-1.x86_64.deb
path: packages/linux/q-text-as-data-${{ needs.version_info.outputs.q_version }}-1.x86_64.deb
test-deb-packaging:
runs-on: ubuntu-18.04
needs: [package-linux-deb, version_info]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download DEB
uses: actions/download-artifact@v2
with:
name: q-text-as-data-${{ needs.version_info.outputs.q_version }}-1.x86_64.deb
- name: Install Python for Testing
uses: actions/setup-python@v2
with:
python-version: '3.8.12'
architecture: 'x64'
- name: Prepare Testing
run: |
set -e -x
pip3 install -r test-requirements.txt
- name: Test DEB Package Installation
run: ./dist/test-using-deb.sh ./q-text-as-data-${{ needs.version_info.outputs.q_version }}-1.x86_64.deb
package-linux-rpm:
needs: [test-linux, create-man, version_info]
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.6'
- name: Download man page
uses: actions/download-artifact@v2
with:
name: q-man-page
- name: Download Linux Executable
uses: actions/download-artifact@v2
with:
name: linux-q
- name: Build RPM Package
run: |
set -e -x
mkdir -p packages/linux
chmod 755 ./linux-q
export q_version=${{ needs.version_info.outputs.q_version }}
gem install fpm
cp dist/fpm-config ~/.fpm
fpm -s dir -t rpm --rpm-use-file-permissions -p packages/linux/q-text-as-data-${q_version}.x86_64.rpm --version ${q_version} ./linux-q=/usr/bin/q USAGE.gz=/usr/share/man/man1/q.1.gz
- name: Upload RPM Package
uses: actions/upload-artifact@v1.0.0
with:
name: q-text-as-data-${{ needs.version_info.outputs.q_version }}.x86_64.rpm
path: packages/linux/q-text-as-data-${{ needs.version_info.outputs.q_version }}.x86_64.rpm
test-rpm-packaging:
runs-on: ubuntu-18.04
needs: [package-linux-rpm, version_info]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download RPM
uses: actions/download-artifact@v2
with:
name: q-text-as-data-${{ needs.version_info.outputs.q_version }}.x86_64.rpm
- name: Retest using RPM
run: ./dist/test-using-rpm.sh ./q-text-as-data-${{ needs.version_info.outputs.q_version }}.x86_64.rpm
build-mac:
runs-on: macos-11
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache pyox
uses: actions/cache@v2
with:
path: |
~/.cache/pyoxidizer
key: ${{ runner.os }}-pyox
- name: Install pyoxidizer
run: |
set -e -x
curl -o pyoxidizer.zip -L "https://github.com/indygreg/PyOxidizer/releases/download/pyoxidizer%2F0.17/pyoxidizer-0.17.0-macos-universal.zip"
unzip pyoxidizer.zip
mv macos-universal/pyoxidizer ./pyoxidizer
chmod +x ./pyoxidizer
- name: Create Q Executable - Mac
run: |
set -e -x
./pyoxidizer build --release
export Q_EXECUTABLE=./build/x86_64-apple-darwin/release/install/q
chmod 755 $Q_EXECUTABLE
seq 1 100 | $Q_EXECUTABLE -c 1 "select sum(c1),count(*) from -" -S test.sqlite
mkdir -p packages/macos/
cp $Q_EXECUTABLE packages/macos/macos-q
- name: Upload MacOS Executable
uses: actions/upload-artifact@v1.0.0
with:
name: macos-q
path: packages/macos/macos-q
test-mac:
needs: build-mac
runs-on: macos-11
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Python for Testing
uses: actions/setup-python@v2
with:
python-version: '3.8.12'
architecture: 'x64'
- name: Prepare Testing
run: |
set -e -x
pip3 install wheel
pip3 install -r test-requirements.txt
- name: Download MacOS Executable
uses: actions/download-artifact@v2
with:
name: macos-q
- name: Run Tests on MacOS Executable
run: |
set -e -x
chmod 755 ./macos-q
Q_EXECUTABLE=`pwd`/macos-q Q_SKIP_EXECUTABLE_VALIDATION=true ./run-tests.sh -v
not-package-mac:
# create-man is not needed, as it's generated inside the brew formula independently
needs: [test-mac]
runs-on: macos-11
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Not Packaging Mac
run: |
echo "homebrew mac cannot be packaged from the source code itself, due to the package build process of homebrew. See https://github.com/harelba/homebrew-q"
not-test-mac-packaging:
needs: not-package-mac
runs-on: macos-11
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Not Testing Mac Packaging
run: |
echo "homebrew mac packaging cannot be tested here, due to the package build process of homebrew. See https://github.com/harelba/homebrew-q"
build-windows:
runs-on: windows-latest
needs: version_info
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install MSVC build tools
uses: ilammy/msvc-dev-cmd@v1
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.8.10'
architecture: 'x64'
- name: Install pyoxidizer
shell: bash
run: |
set -x -e
python3 -V
pip3 -V
pip3 install pyoxidizer
- name: Create Q Executable - Windows
shell: bash
run: |
set -e -x
pyoxidizer build --release --var Q_VERSION ${{ needs.version_info.outputs.q_version }}
export Q_EXECUTABLE=./build/x86_64-pc-windows-msvc/release/install/q
chmod 755 $Q_EXECUTABLE
seq 1 100 | $Q_EXECUTABLE -c 1 "select sum(c1),count(*) from -" -S test.sqlite
mkdir -p packages/windows/
cp $Q_EXECUTABLE packages/windows/win-q.exe
find ./ -ls
- name: Upload Linux Executable
uses: actions/upload-artifact@v1.0.0
with:
name: win-q.exe
path: packages/windows/win-q.exe
not-really-test-windows:
needs: build-windows
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Python for Testing
uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- name: Download Windows Executable
uses: actions/download-artifact@v2
with:
name: win-q.exe
- name: Not-Really-Test Windows
shell: bash
continue-on-error: true
run: |
echo "Tests are not compatible with Windows (path separators, tmp folder names etc.). Only a sanity wil be tested"
chmod +x ./win-q.exe
seq 1 10000 | ./win-q.exe -c 1 "select sum(c1),count(*) from -" -S some-db.sqlite
package-windows:
needs: [create-man, not-really-test-windows, version_info]
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install MSVC build tools
uses: ilammy/msvc-dev-cmd@v1
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.8.10'
architecture: 'x64'
- name: Install pyoxidizer
shell: bash
run: |
set -x -e
python3 -V
pip3 -V
pip3 install pyoxidizer
- name: Create Q MSI - Windows
shell: bash
run: |
set -e -x
pyoxidizer build --release msi_installer --var Q_VERSION ${{ needs.version_info.outputs.q_version }}
export Q_MSI=./build/x86_64-pc-windows-msvc/release/msi_installer/q-text-as-data-${{ needs.version_info.outputs.q_version }}.msi
chmod 755 $Q_MSI
mkdir -p packages/windows/
cp $Q_MSI packages/windows/q-text-as-data-${{ needs.version_info.outputs.q_version }}.msi
- name: Upload Windows MSI
uses: actions/upload-artifact@v1.0.0
with:
name: q-text-as-data-${{ needs.version_info.outputs.q_version }}.msi
path: packages/windows/q-text-as-data-${{ needs.version_info.outputs.q_version }}.msi
test-windows-packaging:
needs: [package-windows, version_info]
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download Windows Package
uses: actions/download-artifact@v2
with:
name: q-text-as-data-${{ needs.version_info.outputs.q_version }}.msi
- name: Test Install of MSI
continue-on-error: true
shell: powershell
run: |
$process = Start-Process msiexec.exe -ArgumentList "/i q-text-as-data-${{ needs.version_info.outputs.q_version }}.msi -l* msi-install.log /norestart /quiet" -PassThru -Wait
$process.ExitCode
gc msi-install.log
exit $process.ExitCode
- name: Test Uninstall of MSI
continue-on-error: true
shell: powershell
run: |
$process = Start-Process msiexec.exe -ArgumentList "/u q-text-as-data-${{ needs.version_info.outputs.q_version }}.msi /norestart /quiet" -PassThru -Wait
$process.ExitCode
exit $process.ExitCode
perform-prerelease:
# We'd like artifacts to be uploaded regardless of tests succeeded or not,
# this is why the dependency here is not on test-X-packaging jobs
needs: [package-linux-deb, package-linux-rpm, not-package-mac, package-windows, version_info]
runs-on: ubuntu-latest
if: needs.version_info.outputs.is_release == 'false'
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts/
- name: Timestamp pre-release
run: |
set -e -x
echo "Workflow finished at $(date)" >> artifacts/workflow-finish-time.txt
- name: Create pre-release
uses: "marvinpinto/action-automatic-releases@v1.2.1"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Next Release Development Build"
files: |
artifacts/**/*
perform-release:
needs: [not-test-mac-packaging, test-deb-packaging, test-rpm-packaging, test-windows-packaging, version_info]
runs-on: ubuntu-latest
if: needs.version_info.outputs.is_release == 'true'
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts/
- uses: "marvinpinto/action-automatic-releases@v1.2.1"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
artifacts/**/*