-
Notifications
You must be signed in to change notification settings - Fork 2
545 lines (527 loc) · 17.8 KB
/
dxapi-python-release.yml
File metadata and controls
545 lines (527 loc) · 17.8 KB
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
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
name: Release dxapi
on:
push:
branches: [release-*]
jobs:
prepare:
if: ${{ !contains(github.event.head_commit.message, '[skip-ci]') }}
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare branch
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git checkout -b workflow-$GITHUB_RUN_ID
versionSnapshot=`grep 'version=' project.properties | sed 's/version=\([^-]*\)/\1/'`
versionRelease=`echo $versionSnapshot | sed 's/\([^-]*\)-SNAPSHOT/\1/'`
versionSnapshotNext=`echo $versionSnapshot | perl -pe 's/^((\d+\.)*)(\d+)(.*)$/$1.($3+1).$4/e'`
echo "$versionSnapshot -> $versionRelease -> $versionSnapshotNext"
sed -i "s/version=$versionSnapshot/version=$versionRelease/" project.properties
git commit -am "[skip-ci] Generate release version"
sed -i "s/version=$versionRelease/version=$versionSnapshotNext/" project.properties
git commit -am "[skip-ci] Generate next snapshot version"
git push origin HEAD
# build dxapi
build-dxapi:
runs-on: ${{ matrix.os }}
needs: [prepare]
strategy:
matrix:
os: [ubuntu-20.04, macos-11]
include:
- os: macos-11
env_os: MACOS
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Build Dxapi
run: make -C ./dxapi/.
env:
CC: clang
OS: ${{ matrix.env_os }}
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: dxapi-${{ matrix.os }}
path: ./dxapi/bin/libdxapi-x64.a
build-windows-dxapi:
runs-on: windows-2019
needs: [prepare]
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Use MSBuild
uses: microsoft/setup-msbuild@v1.1
- name: Build Solution
run: msbuild ./dxapi/dxapi.sln /p:configuration=release /p:platform=x64 /t:rebuild
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: dxapi-windows
path: ./dxapi/bin/dxapi-x64.lib
# build tbapi python
build-linux:
runs-on: ubuntu-20.04
needs: [build-dxapi]
strategy:
matrix:
py: ['3.6', '3.7', '3.8', '3.9', '3.10']
include:
- py: '3.6'
py_env: '36'
- py: '3.7'
py_env: '37'
- py: '3.8'
py_env: '38'
- py: '3.9'
py_env: '39'
- py: '3.10'
py_env: '310'
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Checkout branch
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git fetch
git checkout -b workflow-$GITHUB_RUN_ID origin/workflow-$GITHUB_RUN_ID~1
- name: Download dxapi-linux artifacts
uses: actions/download-artifact@v3
with:
name: dxapi-ubuntu-20.04
path: dxapi/bin
- name: install dev python 3.8, 3.9
if: ${{ matrix.py == '3.8' || matrix.py == '3.9' }}
run: |
sudo apt-get update
sudo apt install -y python${{ matrix.py }}-dev
- name: install dev python 3.6, 3.7, 3.10
if: ${{ matrix.py == '3.6' || matrix.py == '3.7' || matrix.py == '3.10' }}
run: |
sudo apt-get update
sudo apt-get install -yq software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python${{ matrix.py }}-dev
- name: Build Tbapi python
run: |
make -C .
cp ./dfp/lib/linux/64/libDecimalNative.so ./bin/release/linux/x64/py${{ matrix.py_env }}/
env:
CC: clang
PYTHON_VERSION: ${{ matrix.py_env }}
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: tbapi-python-linux
path: |
./bin/release/__init__.py
./bin/release/linux/x64/py${{ matrix.py_env }}/_tbapi.so
./bin/release/linux/x64/py${{ matrix.py_env }}/libDecimalNative.so
build-windows:
runs-on: windows-2019
needs: [build-windows-dxapi]
strategy:
matrix:
py: ['3.6', '3.7', '3.8', '3.9', '3.10']
include:
- py: '3.6'
py_env: '36'
- py: '3.7'
py_env: '37'
- py: '3.8'
py_env: '38'
- py: '3.9'
py_env: '39'
- py: '3.10'
py_env: '310'
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Checkout branch
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git fetch
git checkout -b workflow-$env:GITHUB_RUN_ID origin/workflow-$env:GITHUB_RUN_ID~1
- name: Download dxapi-windows artifacts
uses: actions/download-artifact@v3
with:
name: dxapi-windows
path: dxapi/bin
- uses: actions/setup-python@v4
with:
python-version: '${{ matrix.py }}'
- name: Use MSBuild
uses: microsoft/setup-msbuild@v1.1
- name: Build Solution
run: |
Expand-Archive -Path ./swigwin/swigwin-3.0.12.zip -DestinationPath ./swigwin -Force
$pwd = pwd
$Env:SWIG_HOME="$pwd/swigwin/swigwin-3.0.12"
$Env:SWIG_HOME
python --version
python -c "import os, sys; print(os.path.dirname(sys.executable))"
$Env:PYTHON${{ matrix.py_env }}_HOME=python -c "import os, sys; print(os.path.dirname(sys.executable))"
$Env:PYTHON${{ matrix.py_env }}_HOME
msbuild ./tbapi-python.sln /p:configuration=Release${{ matrix.py_env }} /p:platform=x64 /t:rebuild
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: tbapi-python-windows
path: |
./bin/release/__init__.py
./bin/release/windows/x64/py${{ matrix.py_env }}/_tbapi.pyd
./bin/release/windows/x64/py${{ matrix.py_env }}/DecimalNative.dll
build-macos:
runs-on: macos-11
needs: [build-dxapi]
strategy:
matrix:
py: ['3.6', '3.7', '3.8', '3.9', '3.10']
include:
- py: '3.6'
py_env: '36'
py_v: '3.6.15'
py_lib: 'python3.6m'
- py: '3.7'
py_env: '37'
py_v: '3.7.12'
py_lib: 'python3.7m'
- py: '3.8'
py_env: '38'
py_v: '3.8.12'
py_lib: 'python3.8'
- py: '3.9'
py_env: '39'
py_v: '3.9.10'
py_lib: 'python3.9'
- py: '3.10'
py_env: '310'
py_v: '3.10.2'
py_lib: 'python3.10'
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Checkout branch
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git fetch
git checkout -b workflow-$GITHUB_RUN_ID origin/workflow-$GITHUB_RUN_ID~1
- name: Download dxapi-macos artifacts
uses: actions/download-artifact@v3
with:
name: dxapi-macos-11
path: dxapi/bin
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py_v }}
- name: Install SWIG
run: |
brew install pcre
cd swigwin
tar -xzvf swig-3.0.12.tar.gz
cd swig-3.0.12
./configure
make
make install
- name: Build tbapi python
run: |
make -C .
cp ./dfp/lib/osx/64/libDecimalNative.dylib ./bin/release/darwin/x64/py${{ matrix.py_env }}/
otool -L ./bin/release/darwin/x64/py${{ matrix.py_env }}/_tbapi.so
install_name_tool -change /Users/runner/hostedtoolcache/Python/${{ matrix.py_v }}/x64/lib/lib${{ matrix.py_lib }}.dylib @rpath/lib${{ matrix.py_lib }}.dylib ./bin/release/darwin/x64/py${{ matrix.py_env }}/_tbapi.so
otool -L ./bin/release/darwin/x64/py${{ matrix.py_env }}/_tbapi.so
install_name_tool -add_rpath /Users/runner/hostedtoolcache/Python/${{ matrix.py_v }}/x64/lib ./bin/release/darwin/x64/py${{ matrix.py_env }}/_tbapi.so
install_name_tool -add_rpath /usr/local/opt/python@${{ matrix.py }}/Frameworks/Python.framework/Versions/${{ matrix.py }}/lib ./bin/release/darwin/x64/py${{ matrix.py_env }}/_tbapi.so
install_name_tool -add_rpath /Library/Frameworks/Python.framework/Versions/${{ matrix.py }}/lib ./bin/release/darwin/x64/py${{ matrix.py_env }}/_tbapi.so
otool -l ./bin/release/darwin/x64/py${{ matrix.py_env }}/_tbapi.so
env:
CC: clang
OS: MACOS
PYTHON_VERSION: ${{ matrix.py_env }}
PYTHON_MACOS_HEADERS_PATH: /Users/runner/hostedtoolcache/Python/${{ matrix.py_v }}/x64/include/${{ matrix.py_lib }}
PYTHON_MACOS_LIB_PATH: /Users/runner/hostedtoolcache/Python/${{ matrix.py_v }}/x64/lib
PYTHON_MACOS_LIB: ${{ matrix.py_lib }}
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: tbapi-python-macos
path: |
./bin/release/__init__.py
./bin/release/darwin/x64/py${{ matrix.py_env }}/_tbapi.so
./bin/release/darwin/x64/py${{ matrix.py_env }}/libDecimalNative.dylib
# Gather artifacts
gather-artifacts:
runs-on: ubuntu-20.04
needs: [build-linux, build-macos, build-windows]
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Checkout branch
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git fetch
git checkout -b workflow-$GITHUB_RUN_ID origin/workflow-$GITHUB_RUN_ID~1
- name: Download tbapi-python-linux artifacts
uses: actions/download-artifact@v3
with:
name: tbapi-python-linux
path: tbapi
- name: Download tbapi-python-windows artifacts
uses: actions/download-artifact@v3
with:
name: tbapi-python-windows
path: tbapi
- name: Download tbapi-python-windows artifacts
uses: actions/download-artifact@v3
with:
name: tbapi-python-macos
path: tbapi
- uses: actions/setup-python@v4
with:
python-version: "3.10.2"
- name: Prepare test package
run: |
# version file
versionSnapshot=`grep 'version=' project.properties | sed 's/version=\([^-]*\)/\1/'`
versionRelease=`echo $versionSnapshot | sed 's/\([^-]*\)-SNAPSHOT/\1/'`
echo version=$versionRelease >> ./tbapi/project.properties
cp ./project.properties ./tbapi/
# pydoc
pip3 install pydoc-markdown
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
pydoc-markdown > ./tbapi/tbapi.md
pip3 install wheel
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: tbapi-python
path: |
./tbapi
# Tests
test-linux:
runs-on: ubuntu-20.04
needs: [gather-artifacts]
strategy:
matrix:
py: ['3.6', '3.7', '3.8', '3.9', '3.10']
services:
timebase:
image: finos/timebase-ce-server:6.1
env:
JAVA_OPTS: "-DQuantServer.enableRemoteMonitoring=true -DTimeBase.version=5.0"
ports:
- 8011:8011
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Download tbapi-python artifacts
uses: actions/download-artifact@v3
with:
name: tbapi-python
path: tests/tbapi
- uses: actions/setup-python@v4
with:
python-version: '${{ matrix.py }}'
- name: Run tests
run: |
chmod -R 777 ./tests
cd ./tests
python -c "import tbapi; print(tbapi.version())"
python TestAll.py
env:
TIMEBASE_HOST: localhost
TIMEBASE_PORT: 8011
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: test-reports-tbapi-python-linux
path: |
./tests/reports
test-windows-smoke:
runs-on: windows-2019
needs: [gather-artifacts]
strategy:
matrix:
py: ['3.6', '3.7', '3.8', '3.9', '3.10']
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Download tbapi-python artifacts
uses: actions/download-artifact@v3
with:
name: tbapi-python
path: tests/tbapi
- uses: actions/setup-python@v4
with:
python-version: '${{ matrix.py }}'
- name: Run tests
run: |
chmod -R 777 ./tests
cd ./tests
python -c "import tbapi; print(tbapi.version())"
test-macos-smoke:
runs-on: macos-11
needs: [gather-artifacts]
strategy:
matrix:
py: ['3.6', '3.7', '3.8', '3.9', '3.10']
include:
- py: '3.6'
py_v: '3.6.15'
- py: '3.7'
py_v: '3.7.12'
- py: '3.8'
py_v: '3.8.12'
- py: '3.9'
py_v: '3.9.10'
- py: '3.10'
py_v: '3.10.2'
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Download tbapi-python artifacts
uses: actions/download-artifact@v3
with:
name: tbapi-python
path: tests/tbapi
- uses: actions/setup-python@v4
with:
python-version: '${{ matrix.py_v }}'
- name: Run tests
run: |
chmod -R 777 ./tests
cd ./tests
python -c "import tbapi; print(tbapi.version())"
# Release
release:
runs-on: ubuntu-20.04
needs: [gather-artifacts, test-linux, test-windows-smoke, test-macos-smoke]
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Checkout branch
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git fetch
git checkout -b workflow-$GITHUB_RUN_ID origin/workflow-$GITHUB_RUN_ID~1
- name: Download tbapi-python artifacts
uses: actions/download-artifact@v3
with:
name: tbapi-python
path: tbapi
- uses: actions/setup-python@v4
with:
python-version: "3.10.2"
- name: Install zip
uses: montudor/action-zip@v1
- name: Prepare artifacts
id: tag
run: |
# wheel package
pip3 install wheel
python3 setup.py bdist_wheel --universal
# git tag
versionRelease=`grep 'version=' project.properties | sed 's/version=\([^-]*\)/\1/'`
git tag $versionRelease
git push origin $versionRelease
git push origin origin/workflow-$GITHUB_RUN_ID:$GITHUB_REF
export VERSION=$versionRelease
echo $VERSION
echo ::set-output name=tag::$VERSION
# create zip package
zip -r timebase_client-$versionRelease.zip ./tbapi
- name: Wheel artifacts
uses: actions/upload-artifact@v3
with:
name: tbapi-wheel
path: |
./dist
- name: Zip artifacts
uses: actions/upload-artifact@v3
with:
name: tbapi-zip
path: |
./timebase_client-*.zip
publish-github:
needs: [release]
runs-on: windows-2019
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download tbapi-wheel artifacts
uses: actions/download-artifact@v3
with:
name: tbapi-wheel
- name: Download tbapi-zip artifacts
uses: actions/download-artifact@v3
with:
name: tbapi-zip
- name: Publish github
uses: ncipollo/release-action@v1
with:
artifacts: "timebase_client-*.whl, timebase_client-*.zip, LICENSE"
prerelease: true
tag: ${{ needs.release.outputs.tag }}
token: ${{ secrets.GITHUB_TOKEN }}
publish-pip:
needs: [release]
runs-on: windows-2019
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download tbapi-python artifacts
uses: actions/download-artifact@v3
with:
name: tbapi-wheel
- name: Build PyPi package
run: |
pip install wheel
# python3 -m twine upload --repository-url $Env:REPOSITORY_URL --username $Env:REPOSITORY_USER --password $Env:REPOSITORY_PASSWORD} dist/*
env:
REPOSITORY_URL: add repository url
REPOSITORY_USER: ${{ secrets.PYPI_USER }}
REPOSITORY_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: dxapi-pypi-package
path: ./dist/
cleanup-release:
if: ${{ always() && !contains(github.event.head_commit.message, '[skip-ci]') }}
needs: [publish-github, publish-pip]
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cleanup
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git push origin --delete workflow-$GITHUB_RUN_ID || true