-
Notifications
You must be signed in to change notification settings - Fork 13
604 lines (551 loc) · 19.6 KB
/
release.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
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
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
name: Release
on:
push:
branches:
- release
jobs:
publish-rust-sdk:
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 1
matrix:
package:
- name: longport-proto
registryName: longport-proto
path: rust/crates/proto
- name: longport-httpcli
registryName: longport-httpcli
path: rust/crates/httpclient
- name: longport-wscli
registryName: longport-wscli
path: rust/crates/wsclient
- name: longport-candlesticks
registryName: longport-candlesticks
path: rust/crates/candlesticks
- name: longport
registryName: longport
path: rust
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: get version
working-directory: ${{ matrix.package.path }}
run: echo PACKAGE_VERSION=$(sed -nE 's/^\s*version = "(.*?)"/\1/p' Cargo.toml) >> $GITHUB_ENV
- name: check published version
run: echo PUBLISHED_VERSION=$(cargo search ${{ matrix.package.registryName }} --limit 1 | sed -nE 's/^[^"]*"//; s/".*//1p' -) >> $GITHUB_ENV
- name: cargo login
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
run: cargo login ${{ secrets.CRATES_TOKEN }}
- name: cargo package
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
working-directory: ${{ matrix.package.path }}
run: |
cargo package
echo "We will publish:" $PACKAGE_VERSION
echo "This is current latest:" $PUBLISHED_VERSION
- name: Publish ${{ matrix.package.name }}
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
working-directory: ${{ matrix.package.path }}
run: |
echo "# Cargo Publish"
cargo publish --no-verify
build-python-sdk-macos:
runs-on: macos-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Build wheels - x86_64
uses: messense/maturin-action@v1
with:
target: x86_64
args: -i python --release --out dist -m python/Cargo.toml
- name: Install built wheel - x86_64
run: |
pip install longport --no-index --find-links dist --force-reinstall
- name: Build wheels - universal2
if: ${{ fromJSON(matrix.python-version) >= 3.8 }}
uses: messense/maturin-action@v1
with:
args: -i python --release --universal2 --out dist --no-sdist -m python/Cargo.toml
- name: Install built wheel - universal2
if: ${{ fromJSON(matrix.python-version) >= 3.8 }}
run: |
pip install longport --no-index --find-links dist --force-reinstall
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist
build-python-sdk-windows:
runs-on: windows-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
target: [x64, x86]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.target }}
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
args: -i python --release --out dist --no-sdist -m python/Cargo.toml
- name: Install built wheel
run: |
pip install longport --no-index --find-links dist --force-reinstall
python -c "import longport"
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist
build-python-sdk-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
target: [x86_64, i686]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: auto
args: -i ${{ matrix.python-version }} --release --out dist --no-sdist -m python/Cargo.toml
- name: Install built wheel
if: matrix.target == 'x86_64'
run: |
pip install longport --no-index --find-links dist --force-reinstall
python -c "import longport"
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist
build-python-sdk-linux-cross:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
target: [aarch64]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: 2_28
args: -i ${{ matrix.python-version }} --release --out dist --no-sdist -m python/Cargo.toml
- uses: uraimo/[email protected]
if: matrix.target != 'ppc64'
name: Install built wheel
with:
arch: ${{ matrix.target }}
distro: ubuntu20.04
githubToken: ${{ github.token }}
dockerRunArgs: |
--volume "${PWD}/dist:/artifacts"
install: |
apt-get update
apt-get install -y --no-install-recommends python3 python3-venv software-properties-common
add-apt-repository ppa:deadsnakes/ppa
apt-get update
apt-get install -y curl python3.7-venv python3.8-venv python3.9-venv python3.10-venv python3.11-venv
run: |
ls -lrth /artifacts
PYTHON=python${{ matrix.python-version }}
$PYTHON -m venv venv
venv/bin/pip install -U pip
venv/bin/pip install longport --no-index --find-links /artifacts --force-reinstall
venv/bin/python -c 'import longport'
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist
publish-python-sdk:
runs-on: ubuntu-latest
needs:
- build-python-sdk-macos
- build-python-sdk-windows
- build-python-sdk-linux
- build-python-sdk-linux-cross
steps:
- uses: actions/download-artifact@v2
with:
name: wheels
- uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Publish to PyPi
env:
TWINE_USERNAME: Sunli
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
pip install --upgrade twine
twine upload --skip-existing *
build-nodejs-sdk:
strategy:
fail-fast: true
matrix:
settings:
- host: macos-latest
architecture: x64
build: |
npm run build
strip -x *.node
- host: windows-latest
build: npm run build
architecture: x64
- host: ubuntu-latest
build: |
npm run build
strip *.node
- host: macos-latest
target: aarch64-apple-darwin
build: |
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*;
export CC=$(xcrun -f clang);
export CXX=$(xcrun -f clang++);
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
yarn build --target aarch64-apple-darwin
strip -x *.node
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
architecture: ${{ matrix.settings.architecture }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
target: ${{ matrix.settings.target }}
- name: Check with clippy
run: cargo clippy -p longport-nodejs --all-features
- name: Test
run: cargo test -p longport-nodejs --all-features
- name: Install napi-rs/cli
run: npm install -g @napi-rs/cli
- name: Build
working-directory: nodejs
run: ${{ matrix.settings.build }}
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings
path: nodejs/longport.*.node
publish-nodejs-sdk:
runs-on: ubuntu-latest
needs:
- build-nodejs-sdk
steps:
- uses: actions/checkout@v3
- name: Update versions
run: node ./.github/misc/update_jssdk_version.mjs $(sed -nE 's/^\s*version = "(.*?)"/\1/p' nodejs/Cargo.toml)
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
- name: Install napi-rs/cli
run: npm install -g @napi-rs/cli
- name: Download all artifacts
uses: actions/download-artifact@v2
with:
name: bindings
path: ./nodejs/artifacts
- name: Move artifacts
run: napi artifacts
working-directory: ./nodejs
- name: List packages
run: ls -R ./npm
shell: bash
working-directory: ./nodejs
- name: Publish
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
working-directory: ./nodejs
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
build-java-jni:
strategy:
fail-fast: true
matrix:
settings:
- host: ubuntu-latest
container: centos:7
lib_prefix: "lib"
lib_suffix: ".so"
target: x86_64-unknown-linux-gnu
- host: ubuntu-latest
lib_prefix: "lib"
lib_suffix: ".so"
target: aarch64-unknown-linux-gnu
- host: windows-latest
lib_suffix: ".dll"
target: x86_64-pc-windows-msvc
- host: macos-latest
lib_prefix: "lib"
lib_suffix: ".dylib"
target: x86_64-apple-darwin
- host: macos-latest
lib_prefix: "lib"
lib_suffix: ".dylib"
target: aarch64-apple-darwin
runs-on: ${{ matrix.settings.host }}
container: ${{ matrix.settings.container }}
steps:
- name: Install Git & Gcc
if: ${{ contains(matrix.settings.container, 'centos') }}
run: |
yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
yum install -y git gcc
- uses: actions/checkout@v3
with:
submodules: true
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
target: ${{ matrix.settings.target }}
- name: Build
if: ${{ matrix.settings.target != 'aarch64-unknown-linux-gnu' }}
run: |
cargo build -p longport-java --release --target ${{ matrix.settings.target }}
mv target/${{ matrix.settings.target }}/release/${{ matrix.settings.lib_prefix }}longport_java${{ matrix.settings.lib_suffix }} longport_java-${{ matrix.settings.target }}${{ matrix.settings.lib_suffix }}
- name: Build with Cross
if: ${{ matrix.settings.target == 'aarch64-unknown-linux-gnu' }}
run: |
cargo install cross
cross build -p longport-java --release --target ${{ matrix.settings.target }}
mv target/${{ matrix.settings.target }}/release/${{ matrix.settings.lib_prefix }}longport_java${{ matrix.settings.lib_suffix }} longport_java-${{ matrix.settings.target }}${{ matrix.settings.lib_suffix }}
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: jnis
path: longport_java-${{ matrix.settings.target }}${{ matrix.settings.lib_suffix }}
publish-java-sdk:
runs-on: ubuntu-latest
needs: build-java-jni
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install JDK
uses: actions/setup-java@v3
with:
java-version: "8"
distribution: "temurin"
- name: Download all artifacts
uses: actions/download-artifact@v2
with:
name: jnis
path: ./java/jnis
- name: Copy jnis
working-directory: java
run: |
mkdir -p javasrc/target/natives/linux_64
mkdir -p javasrc/target/natives/linux_arm64
mkdir -p javasrc/target/natives/windows_64
mkdir -p javasrc/target/natives/osx_64
mkdir -p javasrc/target/natives/osx_arm64
mv jnis/longport_java-x86_64-unknown-linux-gnu.so javasrc/target/natives/linux_64/liblongport_java.so
mv jnis/longport_java-aarch64-unknown-linux-gnu.so javasrc/target/natives/linux_arm64/liblongport_java.so
mv jnis/longport_java-x86_64-pc-windows-msvc.dll javasrc/target/natives/windows_64/longport_java.dll
mv jnis/longport_java-x86_64-apple-darwin.dylib javasrc/target/natives/osx_64/liblongport_java.dylib
mv jnis/longport_java-aarch64-apple-darwin.dylib javasrc/target/natives/osx_arm64/liblongport_java.dylib
- name: Get version
working-directory: java
run: echo PACKAGE_VERSION=$(sed -nE 's/^\s*version = "(.*?)"/\1/p' Cargo.toml) >> $GITHUB_ENV
- name: Update version
working-directory: java/javasrc
run: mvn versions:set -DnewVersion=${PACKAGE_VERSION}
- name: Publish maven package
uses: samuelmeuli/action-maven-publish@v1
with:
directory: java/javasrc
maven_profiles: release
maven_goals_phases: deploy
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
nexus_username: ${{ secrets.OSSRH_USERNAME }}
nexus_password: ${{ secrets.OSSRH_PASSWORD }}
copy-cpp-headers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: include
path: c/csrc/include
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: include
path: cpp/include
build-cpp-sdk:
needs:
- copy-cpp-headers
strategy:
fail-fast: true
matrix:
settings:
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
platform: x86_64_linux
dylib_ext: so
- host: windows-latest
target: x86_64-pc-windows-msvc
platform: x86_64_windows
- host: macos-latest
target: x86_64-apple-darwin
platform: x86_64_macos
dylib_ext: dylib
- host: macos-latest
target: aarch64-apple-darwin
platform: aarch64_macos
dylib_ext: dylib
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install MSBuild
if: ${{ matrix.settings.host == 'windows-latest' }}
uses: microsoft/[email protected]
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
target: ${{ matrix.settings.target }}
- name: Get CMake
uses: lukka/get-cmake@latest
- name: Install cargo make
run: cargo install cargo-make
- name: Build
if: ${{ matrix.settings.target != 'aarch64-apple-darwin' }}
run: |
cargo make cmake-release
cargo make c-release
cargo make cpp-release
- name: Build
if: ${{ matrix.settings.target == 'aarch64-apple-darwin' }}
run: |
cargo make cmake-release-macos-aarch64
cargo make cpp-release
- name: Copy files
if: ${{ matrix.settings.host == 'windows-latest' }}
run: |
md dist\lib\${{ matrix.settings.platform }}
copy cmake.build\C\Release\longport_c.dll dist\lib\${{ matrix.settings.platform }}
copy cmake.build\C\Release\longport_c.dll.lib dist\lib\${{ matrix.settings.platform }}\longport_c.lib
copy cmake.build\Release\longport_cpp.dll dist\lib\${{ matrix.settings.platform }}
copy cmake.build\cpp\Release\longport_cpp.lib dist\lib\${{ matrix.settings.platform }}
- name: Copy files
if: ${{ matrix.settings.host != 'windows-latest' }}
run: |
mkdir -p dist/lib/${{ matrix.settings.platform }}
cp cmake.build/c/liblongport_c.${{ matrix.settings.dylib_ext }} dist/lib/${{ matrix.settings.platform }}
cp cmake.build/liblongport_cpp.${{ matrix.settings.dylib_ext }} dist/lib/${{ matrix.settings.platform }}
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: libs
path: dist/lib
publish-cpp-sdk:
needs:
- build-cpp-sdk
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download includes
uses: actions/download-artifact@v2
with:
name: libs
path: ./sdk/libs
- name: Download includes
uses: actions/download-artifact@v2
with:
name: include
path: ./sdk/include
- name: Get Version
run: echo SDK_VERSION=$(sed -nE 's/^\s*version = "(.*?)"/\1/p' c/Cargo.toml) >> $GITHUB_ENV
- name: Package
run: tar czvf openapi-cpp-sdk-$SDK_VERSION.tar.gz ./sdk
- name: Upload SDK to BJ
env:
AWS_ACCESS_KEY_ID: ${{ secrets.FE_S3_OPEN_STATIC_PROD_BJ_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.FE_S3_OPEN_STATIC_PROD_BJ_ACCESS_KEY_SECRET }}
run: |
aws --region=${{ secrets.PROD_BJ_AWS_DEFAULT_REGION }} s3 cp openapi-cpp-sdk-$SDK_VERSION.tar.gz s3://${{ secrets.FE_S3_OPEN_STATIC_PROD_BJ_BUCKET }}/openapi-sdk/ --cache-control max-age=31536000
- name: Upload SDK to HK
env:
AWS_ACCESS_KEY_ID: ${{ secrets.FE_S3_OPEN_STATIC_PROD_HK_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.FE_S3_OPEN_STATIC_PROD_HK_ACCESS_KEY_SECRET }}
run: |
aws --region=${{ secrets.PROD_HK_AWS_DEFAULT_REGION }} s3 cp openapi-cpp-sdk-$SDK_VERSION.tar.gz s3://${{ secrets.FE_S3_OPEN_STATIC_PROD_HK_BUCKET }}/openapi-sdk/ --cache-control max-age=31536000