-
Notifications
You must be signed in to change notification settings - Fork 14
914 lines (832 loc) · 30.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
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
name: Release
on:
push:
branches:
- release-v1
- release-v2
jobs:
build-python-sdk-macos:
runs-on: macos-13
strategy:
fail-fast: true
matrix:
python:
- version: "3.7"
universal2: false
- version: "3.8"
universal2: true
- version: "3.9"
universal2: true
- version: "3.10"
universal2: true
- version: "3.11"
universal2: true
- version: "3.12"
universal2: true
- version: "3.13"
universal2: true
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v5
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: PyO3/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: ${{ matrix.python.universal2 }}
uses: PyO3/maturin-action@v1
with:
args: -i python --release --target universal2-apple-darwin --out dist -m python/Cargo.toml
- name: Install built wheel - universal2
if: ${{ matrix.python.universal2 }}
run: |
pip install longport --no-index --find-links dist --force-reinstall
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.python.version }}
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", "3.12", "3.13"]
target: [x64, x86]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v5
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: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: -i python --release --out dist -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@v4
with:
name: wheels-windows-${{ matrix.target }}-${{ matrix.python-version }}
path: dist
build-python-sdk-linux:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
target: [x86_64, i686]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: auto
args: -i python${{ matrix.python-version }} --release --out dist -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@v4
with:
name: wheels-linux-${{ matrix.target }}-${{ matrix.python-version }}
path: dist
build-python-sdk-linux-cross:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
target: [aarch64]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: 2_28
args: -i python${{ matrix.python-version }} --release --out dist -m python/Cargo.toml
- uses: uraimo/run-on-arch-action@v2
name: Install built wheel
with:
arch: none
distro: none
base_image: "--platform=linux/aarch64 ubuntu:20.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 python${{ matrix.python-version }}-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@v4
with:
name: wheels-linux-${{ matrix.target }}-${{ matrix.python-version }}
path: dist
build-nodejs-sdk:
strategy:
fail-fast: true
matrix:
settings:
- host: ubuntu-22.04
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: |
yarn build
strip -x *.node
artifact-name: linux-x64-musl
- host: ubuntu-22.04
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
build: |
rustup target add aarch64-unknown-linux-gnu
yarn build --target aarch64-unknown-linux-gnu
aarch64-unknown-linux-gnu-strip *.node
artifact-name: linux-aarch64
# - host: ubuntu-22.04
# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
# build: |
# rustup target add aarch64-unknown-linux-musl
# yarn build --target aarch64-unknown-linux-musl
# /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
# artifact-name: linux-aarch64-musl
- host: macos-13
architecture: x64
build: |
yarn build
strip -x *.node
artifact-name: macos
- host: windows-latest
build: yarn build
architecture: x64
artifact-name: windows
- host: ubuntu-22.04
build: |
yarn build
strip *.node
artifact-name: linux-x64
- host: macos-13
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
artifact-name: macos-aarch64
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Setup node
uses: actions/setup-node@v3
if: ${{ !matrix.settings.docker }}
with:
node-version: 16
check-latest: true
architecture: ${{ matrix.settings.architecture }}
- name: Install Rust
uses: actions-rs/toolchain@v1
if: ${{ !matrix.settings.docker }}
with:
toolchain: stable
override: true
components: rustfmt, clippy
target: ${{ matrix.settings.target }}
- name: Install dependencies
working-directory: nodejs
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- name: Build
if: ${{ !matrix.settings.docker }}
working-directory: nodejs
run: ${{ matrix.settings.build }}
- name: Build in Docker
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.docker }}
with:
image: ${{ matrix.settings.docker }}
options: "--user 0:0 -v ${{ github.workspace }}:/build -w /build/nodejs"
run: ${{ matrix.settings.build }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.artifact-name }}
path: nodejs/longport.*.node
build-java-jni:
strategy:
fail-fast: true
matrix:
settings:
- host: ubuntu-22.04
lib_prefix: "lib"
lib_suffix: ".so"
target: x86_64-unknown-linux-gnu
cross: true
- host: ubuntu-22.04
lib_prefix: "lib"
lib_suffix: ".so"
target: aarch64-unknown-linux-gnu
cross: true
- host: windows-latest
lib_suffix: ".dll"
target: x86_64-pc-windows-msvc
- host: macos-13
lib_prefix: "lib"
lib_suffix: ".dylib"
target: x86_64-apple-darwin
- host: macos-13
lib_prefix: "lib"
lib_suffix: ".dylib"
target: aarch64-apple-darwin
runs-on: ${{ matrix.settings.host }}
steps:
- 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.cross }}
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: Install latest cross binary
if: ${{ matrix.settings.cross }}
uses: st3iny/install-cross-binary@v2
- name: Build with Cross
if: ${{ matrix.settings.cross }}
run: |
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@v4
with:
name: jnis-${{ matrix.settings.target }}
path: longport_java-${{ matrix.settings.target }}${{ matrix.settings.lib_suffix }}
copy-cpp-headers:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: include-c
path: c/csrc/include
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: include-cpp
path: cpp/include
build-cpp-sdk-debug:
needs:
- copy-cpp-headers
strategy:
fail-fast: true
matrix:
settings:
- host: ubuntu-22.04
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-13
target: x86_64-apple-darwin
platform: x86_64_macos
dylib_ext: dylib
- host: macos-13
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
uses: davidB/rust-cargo-make@v1
- name: Build
if: ${{ matrix.settings.target != 'aarch64-apple-darwin' }}
run: |
cargo make cmake-debug
cargo make c
cargo make cpp
- name: Build
if: ${{ matrix.settings.target == 'aarch64-apple-darwin' }}
run: |
cargo make cmake-debug-macos-aarch64
cargo make cpp
- name: Copy files
if: ${{ matrix.settings.host == 'windows-latest' }}
run: |
md dist\lib\${{ matrix.settings.platform }}\debug
copy cmake.build\x64\Debug\cargo\build\${{ matrix.settings.target }}\debug\longport_c.dll dist\lib\${{ matrix.settings.platform }}\debug
copy cmake.build\x64\Debug\cargo\build\${{ matrix.settings.target }}\debug\longport_c.dll.lib dist\lib\${{ matrix.settings.platform }}\debug\longport_c.lib
copy cmake.build\Debug\longport_cpp.dll dist\lib\${{ matrix.settings.platform }}\debug
copy cmake.build\cpp\Debug\longport_cpp.lib dist\lib\${{ matrix.settings.platform }}\debug
- name: Copy files
if: ${{ matrix.settings.host != 'windows-latest' }}
run: |
mkdir -p dist/lib/${{ matrix.settings.platform }}/debug
cp cmake.build/cargo/build/${{ matrix.settings.target }}/debug/liblongport_c.${{ matrix.settings.dylib_ext }} dist/lib/${{ matrix.settings.platform }}/debug
cp cmake.build/liblongport_cpp.${{ matrix.settings.dylib_ext }} dist/lib/${{ matrix.settings.platform }}/debug
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: libs-debug-${{ matrix.settings.target }}
path: dist/lib
build-cpp-sdk-release:
needs:
- copy-cpp-headers
strategy:
fail-fast: true
matrix:
settings:
- host: ubuntu-22.04
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-13
target: x86_64-apple-darwin
platform: x86_64_macos
dylib_ext: dylib
- host: macos-13
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
uses: davidB/rust-cargo-make@v1
- 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 }}\release
copy cmake.build\x64\Release\cargo\build\${{ matrix.settings.target }}\release\longport_c.dll dist\lib\${{ matrix.settings.platform }}\release
copy cmake.build\x64\Release\cargo\build\${{ matrix.settings.target }}\release\longport_c.dll.lib dist\lib\${{ matrix.settings.platform }}\release\longport_c.lib
copy cmake.build\Release\longport_cpp.dll dist\lib\${{ matrix.settings.platform }}\release
copy cmake.build\cpp\Release\longport_cpp.lib dist\lib\${{ matrix.settings.platform }}\release
- name: Copy files
if: ${{ matrix.settings.host != 'windows-latest' }}
run: |
mkdir -p dist/lib/${{ matrix.settings.platform }}/release
cp cmake.build/cargo/build/${{ matrix.settings.target }}/release/liblongport_c.${{ matrix.settings.dylib_ext }} dist/lib/${{ matrix.settings.platform }}/release
cp cmake.build/liblongport_cpp.${{ matrix.settings.dylib_ext }} dist/lib/${{ matrix.settings.platform }}/release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: libs-release-${{ matrix.settings.target }}
path: dist/lib
build-ios-cpp-sdk:
needs:
- copy-cpp-headers
strategy:
fail-fast: true
matrix:
settings:
- target: aarch64-apple-ios
platform: OS64
build-type: Debug
target-dir: debug
cargo-args: ""
- target: aarch64-apple-ios
platform: OS64
build-type: Release
target-dir: release
cargo-args: -r
- target: aarch64-apple-ios-sim
platform: SIMULATOR64
build-type: Debug
target-dir: debug
cargo-args: ""
- target: aarch64-apple-ios-sim
platform: SIMULATOR64
build-type: Release
target-dir: release
cargo-args: -r
runs-on: macos-13
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Install target
run: |
rustup target install ${{ matrix.settings.target }}
- name: Build C
working-directory: c
run: |
cargo rustc --crate-type=staticlib --target --target ${{ matrix.settings.target }} ${{ matrix.settings.cargo-args }}
- name: Get CMake
uses: lukka/get-cmake@latest
- name: Build CPP
working-directory: cpp
run: |
mkdir cmake.build
cd cmake.build && cmake -DCMAKE_BUILD_TYPE={{ matrix.settings.build-type }} -DCMAKE_TOOLCHAIN_FILE=../static/toolchains/ios.cmake -DPLATFORM=${{ matrix.settings.platform }} -DDENABLE_BITCODE=true ../static && make
- name: Copy files
run: |
mkdir -p dist/lib/${{ matrix.settings.target }}/${{ matrix.settings.target-dir }}
cp target/${{ matrix.settings.target }}/${{ matrix.settings.target-dir }}/liblongport_c.a dist/lib/${{ matrix.settings.target }}/${{ matrix.settings.target-dir }}
cp cpp/cmake.build/liblongport_cpp.a dist/lib/${{ matrix.settings.target }}/${{ matrix.settings.target-dir }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: libs-ios-${{ matrix.settings.build-type }}-${{ matrix.settings.target }}
path: dist/lib
build-android-cpp-sdk:
needs:
- copy-cpp-headers
strategy:
fail-fast: true
matrix:
settings:
- target: armv7-linux-androideabi
cc: armv7a-linux-androideabi28-clang
cxx: armv7a-linux-androideabi28-clang++
ar: llvm-ar
build-type: Debug
target-dir: debug
cargo-args: ""
- target: armv7-linux-androideabi
cc: armv7a-linux-androideabi28-clang
cxx: armv7a-linux-androideabi28-clang++
ar: llvm-ar
build-type: Release
target-dir: release
cargo-args: -r
- target: aarch64-linux-android
cc: aarch64-linux-android28-clang
cxx: aarch64-linux-android28-clang++
ar: llvm-ar
build-type: Debug
target-dir: debug
cargo-args: ""
- target: aarch64-linux-android
cc: aarch64-linux-android28-clang
cxx: aarch64-linux-android28-clang++
ar: llvm-ar
build-type: Release
target-dir: release
cargo-args: -r
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Install target
run: |
rustup target install ${{ matrix.settings.target }}
- name: Setup NDK
id: setup-ndk
uses: nttld/setup-ndk@v1
with:
ndk-version: r26d
add-to-path: true
- name: Build C
working-directory: c
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
CC: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.settings.cc }}
AR: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.settings.ar }}
run: |
cargo rustc --crate-type=staticlib --target ${{ matrix.settings.target }} ${{ matrix.settings.cargo-args }}
- name: Get CMake
uses: lukka/get-cmake@latest
- name: Build CPP
working-directory: cpp
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
CC: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.settings.cc }}
CXX: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.settings.cxx }}
AR: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.settings.ar }}
run: |
mkdir cmake.build
cd cmake.build && cmake -DCMAKE_BUILD_TYPE=Debug ../static && make
- name: Copy files
run: |
mkdir -p dist/lib/${{ matrix.settings.target }}/${{ matrix.settings.target-dir }}
cp target/${{ matrix.settings.target }}/${{ matrix.settings.target-dir }}/liblongport_c.a dist/lib/${{ matrix.settings.target }}/${{ matrix.settings.target-dir }}
cp cpp/cmake.build/liblongport_cpp.a dist/lib/${{ matrix.settings.target }}/${{ matrix.settings.target-dir }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: libs-android-${{ matrix.settings.build-type }}-${{ matrix.settings.target }}
path: dist/lib
build:
needs:
- build-python-sdk-macos
- build-python-sdk-windows
- build-python-sdk-linux
- build-python-sdk-linux-cross
- build-nodejs-sdk
- build-java-jni
- build-cpp-sdk-debug
- build-cpp-sdk-release
- build-ios-cpp-sdk
- build-android-cpp-sdk
runs-on: ubuntu-22.04
steps:
- run: echo "All builds are done"
publish-rust-sdk:
needs:
- build
runs-on: ubuntu-22.04
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
publish-cpp-sdk:
needs:
- build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Download includes
uses: actions/download-artifact@v4
with:
path: ./sdk/libs
pattern: libs-*
merge-multiple: true
- name: Download includes
uses: actions/download-artifact@v4
with:
path: ./sdk/include
pattern: include-*
merge-multiple: true
- 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
publish-python-sdk:
runs-on: ubuntu-22.04
environment:
name: pypi
url: https://pypi.org/p/longport
permissions:
id-token: write
needs:
- build
steps:
- uses: actions/download-artifact@v4
with:
path: dist
pattern: wheels-*
merge-multiple: true
- uses: actions/setup-python@v5
with:
python-version: 3.7
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
publish-nodejs-sdk:
runs-on: ubuntu-22.04
needs:
- build
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@v4
with:
path: ./nodejs/artifacts
pattern: bindings-*
merge-multiple: true
- 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 }}
publish-java-sdk:
runs-on: ubuntu-22.04
needs: build
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@v4
with:
path: ./java/jnis
pattern: jnis-*
merge-multiple: true
- 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 }}