-
Notifications
You must be signed in to change notification settings - Fork 14
802 lines (726 loc) · 33.7 KB
/
build.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
name: Build C++ Shared Library
on:
push:
workflow_dispatch:
inputs:
version:
description: "バージョン情報(A.BB.C / A.BB.C-preview.D)"
required: true
target:
description: "ビルド対象"
type: choice
default: onnxruntime
options:
- onnxruntime
- voicevox_onnxruntime
release:
description: "リリースするかどうか"
type: boolean
code_signing:
description: "コード署名する"
type: boolean
required: false
default: false
env:
TARGET_LIBRARY:
|-
${{ inputs.target || 'onnxruntime' }}
ONNXRUNTIME_VERSION:
|- # workflow_dispatchでのバージョン名が入る。無指定なら適当なバージョン
${{ inputs.version || '1.17.3' }}
RELEASE:
|- # workflow_dispatchでのreleaseフラグがあればリリースする
${{ inputs.release }}
defaults:
run:
shell: bash
jobs:
build-onnxruntime:
strategy:
fail-fast: false
matrix:
# TODO: 外せる`--compile_no_warning_as_error`は外す
include:
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-win-x64
os: windows-2022
build_opts: |-
--compile_no_warning_as_error
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Windows
CMAKE_SYSTEM_PROCESSOR=x86_64
Rust_CARGO_TARGET=x86_64-pc-windows-msvc
result_dir: build/Release
release_config: Release
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-win-x64-dml
os: windows-2022
build_opts: |-
--compile_no_warning_as_error
--use_dml
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Windows
CMAKE_SYSTEM_PROCESSOR=x86_64
Rust_CARGO_TARGET=x86_64-pc-windows-msvc
result_dir: build/Release
release_config: Release
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-win-x64-cuda
os: windows-2022
cuda_version: 12.4.1
# Windowsの場合デフォルトのパッケージ群では不十分であるため、必要そうなパッケージを指定する。ただしいくつかは不要かもしれない
cuda_sub_packages: '["cudart", "cuobjdump", "nvcc", "nvdisasm", "thrust", "cublas_dev", "cufft_dev", "curand_dev", "cusolver_dev", "cusparse_dev", "visual_studio_integration"]'
cudnn_url: https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/windows-x86_64/cudnn-windows-x86_64-8.9.7.29_cuda12-archive.zip
build_opts: |-
--compile_no_warning_as_error
--use_cuda
--cuda_version 12.4 # WindowsではCUDAのディレクトリを見つけ出すのに必要(1.16.3時点)
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Windows
CMAKE_SYSTEM_PROCESSOR=x86_64
Rust_CARGO_TARGET=x86_64-pc-windows-msvc
result_dir: build/Release
release_config: Release
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-win-x86
os: windows-2022
build_opts: |-
--compile_no_warning_as_error
--x86
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Windows
CMAKE_SYSTEM_PROCESSOR=x86
Rust_CARGO_TARGET=i686-pc-windows-msvc
result_dir: build/Release
release_config: Release
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-linux-x64
os: ubuntu-20.04
build_opts: |-
--compile_no_warning_as_error
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Linux
CMAKE_SYSTEM_PROCESSOR=x86_64
Rust_CARGO_TARGET=x86_64-unknown-linux-gnu
result_dir: build
release_config: Release
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-linux-x64-cuda
os: ubuntu-20.04
cuda_version: 12.4.1
cuda_sub_packages: "[]" # デフォルト
cudnn_url: https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/cudnn-linux-x86_64-8.9.7.29_cuda12-archive.tar.xz
build_opts: |-
--compile_no_warning_as_error
--use_cuda
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Linux
CMAKE_SYSTEM_PROCESSOR=x86_64
Rust_CARGO_TARGET=x86_64-unknown-linux-gnu
result_dir: build
release_config: Release
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-linux-armhf
os: ubuntu-20.04
cc_version: "10"
cxx_version: "10"
linux_cross_arch: arm-linux-gnueabihf
symlink_workaround: true
build_opts: |-
--compile_no_warning_as_error
--arm
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Linux
CMAKE_SYSTEM_PROCESSOR=armv7l
Rust_CARGO_TARGET=armv7-unknown-linux-gnueabihf
result_dir: build
release_config: Release
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-linux-arm64
os: ubuntu-20.04
cc_version: "10"
cxx_version: "10"
linux_cross_arch: aarch64-linux-gnu
symlink_workaround: true
build_opts: |-
--compile_no_warning_as_error
--arm64
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Linux
CMAKE_SYSTEM_PROCESSOR=aarch64
Rust_CARGO_TARGET=aarch64-unknown-linux-gnu
result_dir: build
release_config: Release
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-osx-arm64
os: macos-13
build_opts: |-
--compile_no_warning_as_error
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Darwin
CMAKE_OSX_ARCHITECTURES=arm64
Rust_CARGO_TARGET=aarch64-apple-darwin
result_dir: build
release_config: Release
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-osx-x86_64
os: macos-13
build_opts: |-
--compile_no_warning_as_error
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Darwin
CMAKE_OSX_ARCHITECTURES=x86_64
Rust_CARGO_TARGET=x86_64-apple-darwin
result_dir: build
release_config: Release
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-android-x64
os: ubuntu-20.04
build_opts: |-
--compile_no_warning_as_error
--android
--android_abi x86_64
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Android
CMAKE_SYSTEM_PROCESSOR=x86_64
Rust_CARGO_TARGET=x86_64-linux-android
result_dir: build
release_config: Release
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-android-arm64
os: ubuntu-20.04
build_opts: |-
--compile_no_warning_as_error
--android
--android_abi arm64-v8a
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Android
CMAKE_SYSTEM_PROCESSOR=aarch64
Rust_CARGO_TARGET=aarch64-linux-android
result_dir: build
release_config: Release
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-ios-arm64
os: macos-13
build_opts: |-
--compile_no_warning_as_error
--skip_tests
--use_xcode
--ios
--apple_sysroot iphoneos
--osx_arch arm64
--apple_deploy_target 16.0
--path_to_protoc_exe /usr/local/opt/protobuf@21/bin/protoc # Homebrewで入れた`protobuf@21`
--cmake_extra_defines
Rust_CARGO_TARGET=aarch64-apple-ios
result_dir: build/Release
release_config: Release-iphoneos
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-ios-sim-arm64
os: macos-13
build_opts: |-
--compile_no_warning_as_error
--skip_tests
--use_xcode
--ios
--apple_sysroot iphonesimulator
--osx_arch arm64
--apple_deploy_target 16.0
--path_to_protoc_exe /usr/local/opt/protobuf@21/bin/protoc # Homebrewで入れた`protobuf@21`
--cmake_extra_defines
Rust_CARGO_TARGET=aarch64-apple-ios-sim
result_dir: build/Release
release_config: Release-iphonesimulator
- artifact_name: ${{ inputs.target || 'onnxruntime' }}-ios-sim-x86_64
os: macos-13
build_opts: |-
--compile_no_warning_as_error
--skip_tests
--use_xcode
--ios
--apple_sysroot iphonesimulator
--osx_arch x86_64
--apple_deploy_target 16.0
--path_to_protoc_exe /usr/local/opt/protobuf@21/bin/protoc # Homebrewで入れた`protobuf@21`
--cmake_extra_defines
Rust_CARGO_TARGET=x86_64-apple-ios
result_dir: build/Release
release_config: Release-iphonesimulator
env:
# prefix usage: "", "arm-linux-gnueabihf-" => "gcc-8", "arm-linux-gnueabihf-gcc-8" (command name)
# suffix usage: "", "-arm-linux-gnueabihf" => "gcc-8", "gcc-8-arm-linux-gnueabihf" (package name)
ARCH_PREFIX: "${{ (matrix.linux_cross_arch != '' && matrix.linux_cross_arch) || '' }}${{ (matrix.linux_cross_arch != '' && '-') || '' }}"
ARCH_SUFFIX: "${{ (matrix.linux_cross_arch != '' && '-') || '' }}${{ (matrix.linux_cross_arch != '' && matrix.linux_cross_arch) || '' }}"
runs-on: ${{ matrix.os }}
environment: ${{ inputs.target == 'voicevox_onnxruntime' && 'production' || '' }} # コード署名用のenvironment
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Version check (semver)
run: |
VERSION=$ONNXRUNTIME_VERSION
if [[ $VERSION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?(\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$ ]]; then
echo "Version: $VERSION"
else
echo "$VERSION is not a valid semver."
exit 1
fi
- name: Checkout
uses: actions/checkout@v4
if: env.TARGET_LIBRARY == 'onnxruntime'
with:
repository: microsoft/onnxruntime
submodules: true
ref: v${{ env.ONNXRUNTIME_VERSION }}
- name: Checkout
uses: actions/checkout@v4
if: env.TARGET_LIBRARY == 'voicevox_onnxruntime'
with:
repository: microsoft/onnxruntime
submodules: true
ref: v${{ env.ONNXRUNTIME_VERSION }}
token: ${{ secrets.PRODUCTION_GITHUB_TOKEN }}
- name: Switch to production
if: env.TARGET_LIBRARY == 'voicevox_onnxruntime'
run: |
(
git remote add private "$PRODUCTION_REPOSITORY_URL"
git fetch private "refs/tags/v$ONNXRUNTIME_VERSION-voicevox"
git switch -d FETCH_HEAD
) > /dev/null 2>&1
env:
PRODUCTION_REPOSITORY_URL: ${{ secrets.PRODUCTION_REPOSITORY_URL }}
- name: Checkout builder
uses: actions/checkout@v4
with:
path: builder
- name: Apply patch
run: |
git apply --ignore-whitespace --reject --whitespace=fix --verbose ./builder/1_17_3_android_arm64_build.patch
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJSON(matrix) }}
run: echo "$MATRIX_CONTEXT" > matrix.json
- name: Cache build result
id: cache-build-result
uses: actions/cache@v4
with:
path: build/
key: ${{ matrix.artifact_name }}-v${{ env.ONNXRUNTIME_VERSION }}-cache-${{ hashFiles('matrix.json') }}
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
if: steps.cache-build-result.outputs.cache-hit != 'true' && runner.os == 'Linux' && contains(matrix.build_opts, '--use_cuda')
with:
tool-cache: false
large-packages: false
swap-storage: false
- name: Install tree
if: steps.cache-build-result.outputs.cache-hit != 'true' && runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
install: tree
- name: Install tree for debug
if: steps.cache-build-result.outputs.cache-hit != 'true' && runner.os == 'macOS'
run: brew install tree
- name: Install build dependencies on ubuntu
if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') && matrix.linux_cross_arch
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
git \
wget \
qemu-user-binfmt \
gcc-${{ matrix.cc_version }}"$ARCH_SUFFIX" \
g++-${{ matrix.cxx_version }}"$ARCH_SUFFIX"
- name: Install build dependencies on macos
if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'macos')
run: |
# Workaround for protoc https://github.com/microsoft/onnxruntime/issues/16238#issuecomment-1590398821
brew install protobuf@21
# ONNX Runtime v1.16.1 requires CMake 3.27 or higher.
- name: Install CMake
if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu')
env:
CMAKE_VERSION: 3.27.7
run: |
wget -O cmake.sh "https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-linux-x86_64.sh"
sudo bash cmake.sh --skip-license --prefix=/usr/local
- name: Set up CUDA
if: steps.cache-build-result.outputs.cache-hit != 'true' && matrix.cuda_version && matrix.cudnn_url
uses: Jimver/[email protected]
with:
cuda: ${{ matrix.cuda_version }}
sub-packages: ${{ matrix.cuda_sub_packages }}
method: network
- name: Set `$CUDA_HOME`
if: steps.cache-build-result.outputs.cache-hit != 'true' && matrix.cuda_version && matrix.cudnn_url
run: echo "CUDA_HOME=$CUDA_PATH" >> "$GITHUB_ENV"
- name: Set up cuDNN
if: steps.cache-build-result.outputs.cache-hit != 'true' && matrix.cuda_version && matrix.cudnn_url
run: |
mkdir download
if [ ${{ runner.os }} = Windows ]; then
curl -L "${{ matrix.cudnn_url }}" > download/cudnn.zip
unzip download/cudnn.zip -d download
rm download/cudnn.zip
else
curl -L "${{ matrix.cudnn_url }}" > download/cudnn.tar.gz
tar xvf download/cudnn.tar.gz -C download/
rm download/cudnn.tar.gz
fi
cudnn_path=$(find download -maxdepth 1 -name 'cudnn-*')
if [ ${{ runner.os }} = Windows ]; then
cudnn_path=$(cygpath -wa "$cudnn_path")
else
cudnn_path=$(realpath "$cudnn_path")
fi
echo "CUDNN_HOME=$cudnn_path" >> "$GITHUB_ENV"
- name: Extract Rust toolchain and target triple
id: rust-toolchain-and-target-triple
if: steps.cache-build-result.outputs.cache-hit != 'true' && env.TARGET_LIBRARY == 'voicevox_onnxruntime'
run: |
build_opts=(
${{ matrix.build_opts }}
)
echo "toolchain=$(cat ./rust-toolchain)" >> "$GITHUB_OUTPUT"
echo "target=$(sed -E 's/.*Rust_CARGO_TARGET=([a-z0-9_-]+).*/\1/' <<< "${build_opts[*]}")" >> "$GITHUB_OUTPUT"
- name: Set up Rust
if: steps.cache-build-result.outputs.cache-hit != 'true' && env.TARGET_LIBRARY == 'voicevox_onnxruntime'
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.rust-toolchain-and-target-triple.outputs.toolchain }}
targets: ${{ steps.rust-toolchain-and-target-triple.outputs.target }}
- name: Install cargo-binstall
if: steps.cache-build-result.outputs.cache-hit != 'true' && env.TARGET_LIBRARY == 'voicevox_onnxruntime'
uses: taiki-e/install-action@cargo-binstall
- name: Install cxxbridge-cmd
if: steps.cache-build-result.outputs.cache-hit != 'true' && env.TARGET_LIBRARY == 'voicevox_onnxruntime'
run: |
md=$(cargo metadata --manifest-path ./vv_bin/Cargo.toml --format-version 1)
version=$(jq -r '.packages[] | select(.name == "cxx").version' <<< "$md")
cargo binstall "cxxbridge-cmd@$version" --no-confirm --log-level debug
- name: Configure build environment for non-x86_64 Linux
if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') && matrix.linux_cross_arch
run: |
# Required for arm build
# https://github.com/microsoft/onnxruntime/issues/4189#issuecomment-642528278
echo 'string(APPEND CMAKE_C_FLAGS " -latomic")' >> cmake/CMakeLists.txt
echo 'string(APPEND CMAKE_CXX_FLAGS " -latomic")' >> cmake/CMakeLists.txt
# Prevent Exec Format Error during cross-compiling
if ${{ matrix.symlink_workaround }}; then
find /usr/${{ matrix.linux_cross_arch }}/lib -name '*.so*' -exec sudo ln -s {} /usr/lib/${{ matrix.linux_cross_arch }}/ ';'
sudo ln -s /usr/${{ matrix.linux_cross_arch }}/lib/ld-linux-*.so* /usr/lib/
fi
# Set environment variable CC / CXX
echo CC="$ARCH_PREFIX"gcc-${{ matrix.cc_version }} >> "$GITHUB_ENV"
echo CXX="$ARCH_PREFIX"g++-${{ matrix.cxx_version }} >> "$GITHUB_ENV"
- name: Configure to use latest Android NDK
if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') && contains(matrix.build_opts, '--android')
run: |
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2004-Readme.md#environment-variables-2
echo "ANDROID_NDK_HOME=$ANDROID_NDK_LATEST_HOME" >> "$GITHUB_ENV"
- name: Build ONNX Runtime
id: build
if: steps.cache-build-result.outputs.cache-hit != 'true'
run: |
# TODO: ↓ この記述は VOICEVOX/voicevox_core#41 時点でのarmhfビルドに対するもの。`CMAKE_SYSTEM_{NAME,PROCESSOR}`が必要のないケースが多いはず。例えばv1.17時点では、AndroidとiOSのビルドではcpuinfoのケアまでちゃんとされているはず。なので調べる。
# add --arm for gcc-8: https://github.com/microsoft/onnxruntime/issues/4189
# skip test: https://github.com/microsoft/onnxruntime/issues/2436
# ONNX Runtime v1.9.0 requires CMAKE_SYSTEM_PROCESSOR, https://github.com/microsoft/onnxruntime/releases/tag/v1.9.0
# Both CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR are required.
build_opts=(
${{ matrix.build_opts }}
)
python ./tools/ci_build/build.py \
--build_dir ./build \
--config Release \
--update \
--build \
--parallel \
--build_shared_lib \
"${build_opts[@]}" \
1>${{ env.TARGET_LIBRARY == 'onnxruntime' && '&1' || format('{0}_stdout.txt', matrix.artifact_name) }} \
2>${{ env.TARGET_LIBRARY == 'onnxruntime' && '&2' || format('{0}_stderr.txt', matrix.artifact_name) }}
- name: Send build log to Discord
if: failure() && steps.build.outcome == 'failure' && env.TARGET_LIBRARY == 'voicevox_onnxruntime'
run: |
curl \
"$PRODUCTION_DISCORD_WEBHOOK" \
-sf \
-F 'payload_json={"username":"onnxruntime-builder"}' \
-F file1=@${{ matrix.artifact_name }}_stdout.txt \
-F file2=@${{ matrix.artifact_name }}_stderr.txt \
> /dev/null 2>&1
env:
PRODUCTION_DISCORD_WEBHOOK: ${{ secrets.PRODUCTION_DISCORD_WEBHOOK }}
- name: Inspect the build directory for debug
if: steps.cache-build-result.outputs.cache-hit != 'true'
run: |
if [ ${{ runner.os }} = Windows ]; then
tree() {
msys2.cmd -c "tree $1"
}
fi
tree build
- name: Organize artifact
run: |
# コピー先artifactを予め削除しておく
rm -rf ${{ matrix.result_dir }}/${{ matrix.artifact_name }}
rm -rf ./artifact
# Set library name
ARTIFACT_NAME=${{ matrix.artifact_name }}
if [[ "$ARTIFACT_NAME" == "$TARGET_LIBRARY"-win-* ]]; then
# FIXME: この分岐はもう使わないのでは?
onnxruntime_filename=$TARGET_LIBRARY.dll
elif [[ "$ARTIFACT_NAME" == "$TARGET_LIBRARY"-linux-* ]]; then
onnxruntime_filename="lib$TARGET_LIBRARY.so.$ONNXRUNTIME_VERSION"
elif [[ "$ARTIFACT_NAME" == "$TARGET_LIBRARY"-android-* ]]; then
onnxruntime_filename="lib$TARGET_LIBRARY.so"
elif [[ "$ARTIFACT_NAME" == "$TARGET_LIBRARY"-osx-* ]] || [[ "$ARTIFACT_NAME" == "$TARGET_LIBRARY"-ios-* ]]; then
onnxruntime_filename="lib$TARGET_LIBRARY.$ONNXRUNTIME_VERSION.dylib"
else
echo "Unknown target found : ${{ matrix.artifact_name }}"
return 1
fi
# PDBファイル, Privacy.md, include/は不要なので省く
if [ ${{ runner.os }} = Windows ]; then
# https://github.com/microsoft/onnxruntime/blob/v1.16.3/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-windows.yml#L34-L72
mkdir -p ./${{ matrix.result_dir }}/${{ matrix.artifact_name }}/lib
git rev-parse HEAD > ./${{ matrix.result_dir }}/${{ matrix.artifact_name }}/GIT_COMMIT_ID
cp ./{LICENSE,README.md,ThirdPartyNotices.txt,VERSION_NUMBER} \
./${{ matrix.result_dir }}/${{ matrix.artifact_name }}/
cp ./${{ matrix.result_dir }}/${{ matrix.release_config }}/"$TARGET_LIBRARY".{dll,lib} \
./${{ matrix.result_dir }}/${{ matrix.artifact_name }}/lib/
if [ -f ./${{ matrix.result_dir }}/${{ matrix.release_config }}/"$TARGET_LIBRARY"_providers_cuda.dll ]; then
cp ./${{ matrix.result_dir }}/${{ matrix.release_config }}/"$TARGET_LIBRARY"_providers_{cuda,shared}.{dll,lib} \
./${{ matrix.result_dir }}/${{ matrix.artifact_name }}/lib/
fi
else
./tools/ci_build/github/linux/copy_strip_binary.sh \
-r ${{ matrix.result_dir }} \
-a ${{ matrix.artifact_name }} \
-l "$onnxruntime_filename" \
-c ${{ matrix.release_config }} \
-s "$(pwd)" \
-t "$(git rev-parse HEAD)"
rm -r ${{ matrix.result_dir }}/${{ matrix.artifact_name }}/{Privacy.md,include}
fi
if [ "$TARGET_LIBRARY" = voicevox_onnxruntime ]; then
mv ${{ matrix.result_dir }}/${{ matrix.artifact_name }}/{,ORT_}LICENSE
mv ${{ matrix.result_dir }}/${{ matrix.artifact_name }}/{,ORT_}README.md
mv ${{ matrix.result_dir }}/${{ matrix.artifact_name }}/{,Ort}ThirdPartyNotices.txt
mv ./VOICEVOX_LICENSE.md ${{ matrix.result_dir }}/${{ matrix.artifact_name }}/LICENSE.md
fi
mv ${{ matrix.result_dir }}/${{ matrix.artifact_name }} ./artifact/
- name: Code signing (Windows)
if: runner.os == 'Windows' && inputs.code_signing
run: find ./${{ matrix.result_dir }}/${{ matrix.artifact_name }}/lib -name '*.dll' -exec ./builder/codesign.bash {} ';'
env:
ESIGNERCKA_USERNAME: ${{ secrets.ESIGNERCKA_USERNAME }}
ESIGNERCKA_PASSWORD: ${{ secrets.ESIGNERCKA_PASSWORD }}
ESIGNERCKA_TOTP_SECRET: ${{ secrets.ESIGNERCKA_TOTP_SECRET }}
#- name: Upload artifact
# uses: actions/upload-artifact@v4
# with:
# name: ${{ matrix.artifact_name }}
# path: artifact/*
- name: Generate RELEASE_NAME
run: |
echo RELEASE_NAME=${{ matrix.artifact_name }}-"$ONNXRUNTIME_VERSION" >> "$GITHUB_ENV"
- name: Generate specifications
run: |
build_opts=(
${{ matrix.build_opts }}
)
for arg in "${build_opts[@]}"; do
case "$arg" in
CMAKE_SYSTEM_NAME=Windows) os=Windows ;;
CMAKE_SYSTEM_NAME=Linux) os=Linux ;;
CMAKE_SYSTEM_NAME=Darwin) os=macOS ;;
--android) os=Android ;;
--ios) os=iOS ;;
CMAKE_SYSTEM_PROCESSOR=x86_64 | CMAKE_OSX_ARCHITECTURES=x86_64 | x86_64) arch=x86_64 ;;
--x86) arch=x86 ;;
CMAKE_OSX_ARCHITECTURES=arm64 | --arm64 | arm64 | arm64-v8a) arch=AArch64 ;;
--arm) arch=ARMv7 ;;
--use_cuda) use_cuda=1 ;;
--use_dml) use_dml=1 ;;
esac
done
jq '
{
"os": $os,
"arch": $arch,
# ONNX Runtimeが示す順番に従う
"devices": [
("CUDA" | select($use_cuda == "1")),
("DirectML" | select($use_dml == "1")),
"CPU"
] | join("/")
}' \
-n \
--arg os "$os" \
--arg arch "$arch" \
--arg use_cuda "$use_cuda" \
--arg use_dml "$use_dml" \
> "$RELEASE_NAME.json"
#- name: Upload specifications
# uses: actions/upload-artifact@v4
# with:
# name: specs-${{ matrix.artifact_name }}
# path: ${{ env.RELEASE_NAME }}.json
#- name: Rearchive artifact
# if: env.RELEASE == 'true'
# run: |
# mv artifact/ "$RELEASE_NAME"
# tar cfz "$RELEASE_NAME.tgz" "$RELEASE_NAME/"
#- name: Upload to Release
# if: env.RELEASE == 'true'
# uses: svenstaro/upload-release-action@v2
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# tag: ${{ env.TARGET_LIBRARY }}-${{ env.ONNXRUNTIME_VERSION }}
# file: ${{ env.RELEASE_NAME }}.tgz
- name: Fail
run: false
#build-xcframework:
# needs: build-onnxruntime
# runs-on: macos-13
# outputs:
# release-name: ${{ steps.gen-envs.outputs.release-name }}
# steps:
# - name: Generate RELEASE_NAME and ONNXRUNTIME_BASENAME
# id: gen-envs
# run: |
# RELEASE_NAME=$TARGET_LIBRARY-ios-xcframework-$ONNXRUNTIME_VERSION
# echo "release-name=$RELEASE_NAME" >> "$GITHUB_OUTPUT"
# echo "RELEASE_NAME=$RELEASE_NAME" >> "$GITHUB_ENV"
# echo "ONNXRUNTIME_BASENAME=lib$TARGET_LIBRARY.$ONNXRUNTIME_VERSION.dylib" >> "$GITHUB_ENV"
# - uses: actions/checkout@v4
# - uses: actions/download-artifact@v4
# with:
# name: ${{ env.TARGET_LIBRARY }}-ios-arm64
# path: artifact/${{ env.TARGET_LIBRARY }}-aarch64-apple-ios
# - uses: actions/download-artifact@v4
# with:
# name: ${{ env.TARGET_LIBRARY }}-ios-sim-arm64
# path: artifact/${{ env.TARGET_LIBRARY }}-aarch64-apple-ios-sim
# - uses: actions/download-artifact@v4
# with:
# name: ${{ env.TARGET_LIBRARY }}-ios-sim-x86_64
# path: artifact/${{ env.TARGET_LIBRARY }}-x86_64-apple-ios
# - name: Remove no version notation dylib
# run: |
# rm -f artifact/"$TARGET_LIBRARY"-x86_64-apple-ios/lib/*"$TARGET_LIBRARY".dylib
# rm -f artifact/"$TARGET_LIBRARY"-aarch64-apple-ios-sim/lib/*"$TARGET_LIBRARY".dylib
# rm -f artifact/"$TARGET_LIBRARY"-aarch64-apple-ios/lib/*"$TARGET_LIBRARY".dylib
# - name: '"onnxruntime" → "voicevox_onnxruntime"'
# if: env.TARGET_LIBRARY == 'voicevox_onnxruntime'
# run: |
# for arch in aarch64 sim; do
# mv xcframework/Frameworks/$arch/{,voicevox_}onnxruntime.framework
# done
# find ./xcframework -type f -exec sed -i '' s/onnxruntime/voicevox_onnxruntime/ {} +
# - name: Create aarch64 Framework
# run: |
# mkdir -p "Framework-aarch64"
# cp -vr xcframework/Frameworks/aarch64/ Framework-aarch64/
# lipo -create "artifact/$TARGET_LIBRARY-aarch64-apple-ios/lib/$ONNXRUNTIME_BASENAME" \
# -output "Framework-aarch64/$TARGET_LIBRARY.framework/$TARGET_LIBRARY"
# - name: Change aarch64 @rpath
# run: |
# install_name_tool -id "@rpath/$TARGET_LIBRARY.framework/$TARGET_LIBRARY" \
# "Framework-aarch64/$TARGET_LIBRARY.framework/$TARGET_LIBRARY"
# - name: Create fat binary
# run: |
# mkdir -p "artifact/$TARGET_LIBRARY-sim"
# lipo -create "artifact/$TARGET_LIBRARY-x86_64-apple-ios/lib/$ONNXRUNTIME_BASENAME" \
# "artifact/$TARGET_LIBRARY-aarch64-apple-ios-sim/lib/$ONNXRUNTIME_BASENAME" \
# -output "artifact/$TARGET_LIBRARY-sim/$TARGET_LIBRARY"
# - name: Create sim Framework
# run: |
# mkdir -p "Framework-sim"
# cp -vr xcframework/Frameworks/sim/ Framework-sim/
# cp -v "artifact/$TARGET_LIBRARY-sim/$TARGET_LIBRARY" \
# "Framework-sim/$TARGET_LIBRARY.framework/$TARGET_LIBRARY"
# - name: Change sim @rpath
# run: |
# install_name_tool -id "@rpath/$TARGET_LIBRARY.framework/$TARGET_LIBRARY" \
# "Framework-sim/$TARGET_LIBRARY.framework/$TARGET_LIBRARY"
# - name: Create XCFramework
# run: |
# mkdir -p "artifact/$ONNXRUNTIME_BASENAME"
# xcodebuild -create-xcframework \
# -framework "Framework-sim/$TARGET_LIBRARY.framework" \
# -framework "Framework-aarch64/$TARGET_LIBRARY.framework" \
# -output "artifact/$ONNXRUNTIME_BASENAME/$TARGET_LIBRARY.xcframework"
# - name: Archive artifact
# run: |
# cd "artifact/$ONNXRUNTIME_BASENAME"
# 7z a "../../$RELEASE_NAME.zip" "$TARGET_LIBRARY.xcframework"
# - name: Upload to Release
# if: env.RELEASE == 'true'
# uses: svenstaro/upload-release-action@v2
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# tag: ${{ env.TARGET_LIBRARY }}-${{ env.ONNXRUNTIME_VERSION }}
# file: ${{ env.RELEASE_NAME }}.zip
#build-spec-table:
# needs: [build-onnxruntime, build-xcframework]
# runs-on: ubuntu-22.04
# steps:
# - name: Download specifications
# uses: actions/download-artifact@v4
# with:
# path: specs
# pattern: specs-*
# merge-multiple: true
# - name: Construct release notes
# run: |
# release_notes=$(
# cat <<EOF
# ## 動的ライブラリ
# <table data-voicevox-onnxruntime-specs-format-version="1" data-voicevox-onnxruntime-specs-type="dylibs">
# <thead>
# <tr>
# <th>OS</th>
# <th>アーキテクチャ</th>
# <th>デバイス</th>
# <th>名前</th>
# </tr>
# </thead>
# <tbody>
# EOF
# )
# release_notes+=$'\n'
# for specs_file in specs/*.json; do
# specs=$(< "$specs_file")
# release_name=$(basename "${specs_file%.json}")
# release_notes+=$' <tr>\n'
# release_notes+=" <td>$(jq .os -r <<< "$specs")</td>"$'\n'
# release_notes+=" <td>$(jq .arch -r <<< "$specs")</td>"$'\n'
# release_notes+=" <td>$(jq .devices -r <<< "$specs")</td>"$'\n'
# release_notes+=" <td><a href=\"https://github.com/$GITHUB_REPOSITORY/releases/download/$TARGET_LIBRARY-$ONNXRUNTIME_VERSION/$release_name.tgz\">$release_name.tgz</a></td>"$'\n'
# release_notes+=$' </tr>\n'
# done
# release_notes+=$(
# cat <<EOF
# </tbody>
# </table>
# ## XCFramework
# <table data-voicevox-onnxruntime-specs-format-version="1" data-voicevox-onnxruntime-specs-type="xcframeworks">
# <thead>
# <tr>
# <th>OS</th>
# <th>アーキテクチャ</th>
# <th>デバイス</th>
# <th>名前</th>
# </tr>
# </thead>
# <tbody>
# <tr>
# <td>iOS</td>
# <td>AArch64/x86_64</td>
# <td>CPU</td>
# <td><a href="https://github.com/$GITHUB_REPOSITORY/releases/download/$TARGET_LIBRARY-$ONNXRUNTIME_VERSION/${{ needs.build-xcframework.outputs.release-name }}.zip">${{ needs.build-xcframework.outputs.release-name }}.zip</a></td>
# </tr>
# </tbody>
# </table>
# EOF
# )
# tee release-notes.md >&2 <<< "$release_notes"
# - name: Update release notes
# if: env.RELEASE == 'true'
# uses: softprops/action-gh-release@v2
# with:
# body_path: release-notes.md
# prerelease: true
# tag_name: ${{ env.TARGET_LIBRARY }}-${{ env.ONNXRUNTIME_VERSION }}