-
Notifications
You must be signed in to change notification settings - Fork 120
255 lines (254 loc) · 10.1 KB
/
build_and_deploy.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
name: build and deploy workflow
on:
workflow_dispatch:
inputs:
version:
description: "バージョン情報(A.BB.C / A.BB.C-preview.D)"
required: true
code_signing:
description: "コード署名する"
type: boolean
required: false
release:
types:
- published
pull_request:
push:
branches:
- "*"
- "**/*"
env:
# releaseタグ名か、workflow_dispatchでのバージョン名か、DEBUGが入る
VERSION: ${{ github.event.release.tag_name || github.event.inputs.version || 'DEBUG' }}
# Raw character weights are not public.
# Skip uploading to GitHub Release on public repo.
SKIP_UPLOADING_RELEASE_ASSET: ${{ secrets.SKIP_UPLOADING_RELEASE_ASSET || '1' }}
jobs:
build_and_deploy:
environment: ${{ github.event.inputs.code_signing == 'true' && 'code_signing' || '' }} # コード署名用のenvironment
strategy:
matrix:
include:
- os: windows-2019
features: ""
target: x86_64-pc-windows-msvc
artifact_name: windows-x64-cpu
whl_local_version: cpu
use_cuda: false
- os: windows-2019
features: directml
target: x86_64-pc-windows-msvc
artifact_name: windows-x64-directml
whl_local_version: directml
use_cuda: false
- os: windows-2019
features: ""
target: x86_64-pc-windows-msvc
artifact_name: windows-x64-cuda
whl_local_version: cuda
use_cuda: true
- os: windows-2019
features: ""
target: i686-pc-windows-msvc
artifact_name: windows-x86-cpu
whl_local_version: cpu
use_cuda: false
- os: ubuntu-20.04
features: ""
target: x86_64-unknown-linux-gnu
artifact_name: linux-x64-cpu
whl_local_version: cpu
use_cuda: false
- os: ubuntu-20.04
features: ""
target: x86_64-unknown-linux-gnu
artifact_name: linux-x64-gpu
whl_local_version: cuda
use_cuda: true
- os: ubuntu-20.04
features: ""
target: aarch64-unknown-linux-gnu
artifact_name: linux-arm64-cpu
whl_local_version: cpu
use_cuda: false
- os: macos-12
features: ""
target: aarch64-apple-darwin
artifact_name: osx-arm64-cpu
whl_local_version: cpu
use_cuda: false
- os: macos-12
features: ""
target: x86_64-apple-darwin
artifact_name: osx-x64-cpu
whl_local_version: cpu
use_cuda: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.8"
architecture: ${{ contains(matrix.artifact_name,'x86') && 'x86' || 'x64' }}
- name: set up ${{ matrix.target }}
uses: ./.github/actions/rust-toolchain-from-file
with:
targets: ${{ matrix.target }}
- name: Install cross compiler for aarch64-unknown-linux-gnu
if: matrix.target == 'aarch64-unknown-linux-gnu'
shell: bash
run: |
sudo apt update
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: Install cbindgen
uses: ./.github/actions/cargo-binstall-cbindgen
- name: Install cargo-edit
if: ${{ env.VERSION != 'DEBUG' }}
shell: bash
run: cargo binstall cargo-edit@^0.11 --no-confirm --log-level debug --locked # NOTE: release-0.15で追加
- name: set cargo version
if: ${{ env.VERSION != 'DEBUG' }}
shell: bash
run: |
cargo set-version "$VERSION" --exclude voicevox_core_python_api --exclude download --exclude xtask
cargo set-version "$VERSION+"${{ matrix.whl_local_version }} -p voicevox_core_python_api
- name: generate voicevox_core.h
shell: bash
run: cbindgen --crate voicevox_core_c_api -o ./voicevox_core.h
- name: build voicevox_core_c_api
run: cargo build -p voicevox_core_c_api -vv --features ${{ matrix.features }}, --target ${{ matrix.target }} --release
env:
ORT_USE_CUDA: ${{ matrix.use_cuda }}
- name: build voicevox_core_python_api
id: build-voicevox-core-python-api
shell: bash
run: |
pip install -r ./crates/voicevox_core_python_api/requirements.txt
maturin build --manifest-path ./crates/voicevox_core_python_api/Cargo.toml --features ${{ matrix.features }}, --target ${{ matrix.target }} --release
echo "whl=$(find ./target/wheels -type f)" >> "$GITHUB_OUTPUT"
env:
ORT_USE_CUDA: ${{ matrix.use_cuda }}
- name: Set ASSET_NAME env var
shell: bash
run: echo "ASSET_NAME=voicevox_core-${{ matrix.artifact_name }}-${{ env.VERSION }}" >> "$GITHUB_ENV"
- name: Organize artifact
shell: bash
run: |
mkdir -p "artifact/${{ env.ASSET_NAME }}"
cp -v voicevox_core.h "artifact/${{ env.ASSET_NAME }}"
cp -v target/${{ matrix.target }}/release/*voicevox_core.{dll,so,dylib} "artifact/${{ env.ASSET_NAME }}" || true
cp -v target/${{ matrix.target }}/release/voicevox_core.dll.lib "artifact/${{ env.ASSET_NAME }}/voicevox_core.lib" || true
cp -v -n target/${{ matrix.target }}/release/build/onnxruntime-sys-*/out/onnxruntime_*/onnxruntime-*/lib/*.{dll,so.*,so,dylib} "artifact/${{ env.ASSET_NAME }}" || true
# libonnxruntimeについてはバージョン付のshared libraryを使用するためバージョンがついてないものを削除する
rm -f artifact/${{ env.ASSET_NAME }}/libonnxruntime.{so,dylib}
cp -v README.md "artifact/${{ env.ASSET_NAME }}/README.txt"
cp -vr model "artifact/${{ env.ASSET_NAME }}/"
echo "${{ env.VERSION }}" > "artifact/${{ env.ASSET_NAME }}/VERSION"
- name: Code signing (Windows)
if: startsWith(matrix.os, 'windows') && github.event.inputs.code_signing == 'true'
shell: bash
run: |
bash build_util/codesign.bash "artifact/${{ env.ASSET_NAME }}/voicevox_core.dll"
env:
ESIGNERCKA_USERNAME: ${{ secrets.ESIGNERCKA_USERNAME }}
ESIGNERCKA_PASSWORD: ${{ secrets.ESIGNERCKA_PASSWORD }}
ESIGNERCKA_TOTP_SECRET: ${{ secrets.ESIGNERCKA_TOTP_SECRET }}
- name: Archive artifact
shell: bash
run: |
cd artifact
7z a "../${{ env.ASSET_NAME }}.zip" "${{ env.ASSET_NAME }}"
- name: Upload to Release
if: env.VERSION != 'DEBUG' && env.SKIP_UPLOADING_RELEASE_ASSET == '0'
uses: softprops/action-gh-release@v1
with:
prerelease: true
tag_name: ${{ env.VERSION }}
files: |-
${{ env.ASSET_NAME }}.zip
target_commitish: ${{ github.sha }}
- name: Upload Python whl to Release
if: env.VERSION != 'DEBUG' && env.SKIP_UPLOADING_RELEASE_ASSET == '0'
uses: softprops/action-gh-release@v1
with:
prerelease: true
tag_name: ${{ env.VERSION }}
files: |-
${{ steps.build-voicevox-core-python-api.outputs.whl }}
target_commitish: ${{ github.sha }}
deploy_downloader:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Upload to Release
if: env.VERSION != 'DEBUG' && env.SKIP_UPLOADING_RELEASE_ASSET == '0'
uses: softprops/action-gh-release@v1
with:
prerelease: true
tag_name: ${{ env.VERSION }}
files: |-
scripts/downloads/*
target_commitish: ${{ github.sha }}
deploy_precompiled_downloader:
environment: ${{ github.event.inputs.code_signing == 'true' && 'code_signing' || '' }} # コード署名用のenvironment
strategy:
matrix:
include:
- name: download-windows-x64.exe
target: x86_64-pc-windows-msvc
os: windows-2019
- name: download-linux-x64
target: x86_64-unknown-linux-gnu
os: ubuntu-20.04
- name: download-linux-arm64
target: aarch64-unknown-linux-gnu
os: ubuntu-20.04
- name: download-osx-x64
target: x86_64-apple-darwin
os: macos-12
- name: download-osx-arm64
target: aarch64-apple-darwin
os: macos-12
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install cross compiler for aarch64-unknown-linux-gnu
if: matrix.target == 'aarch64-unknown-linux-gnu'
shell: bash
run: |
sudo apt update
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Set up ${{ matrix.target }}
uses: ./.github/actions/rust-toolchain-from-file
with:
targets: ${{ matrix.target }}
- name: Build downloader
run: cargo build -vv --release -p download --target ${{ matrix.target }}
- name: Rename the binary
shell: bash
run: |
case "$OS" in
Windows) exe_suffix=.exe;;
Linux | macOS) exe_suffix=;;
esac
mv $"target/${{ matrix.target }}/release/download$exe_suffix" ./${{ matrix.name }}
- name: Code signing (Windows)
if: startsWith(matrix.os, 'windows') && github.event.inputs.code_signing == 'true'
shell: bash
run: |
bash build_util/codesign.bash ./${{ matrix.name }}
env:
ESIGNERCKA_USERNAME: ${{ secrets.ESIGNERCKA_USERNAME }}
ESIGNERCKA_PASSWORD: ${{ secrets.ESIGNERCKA_PASSWORD }}
ESIGNERCKA_TOTP_SECRET: ${{ secrets.ESIGNERCKA_TOTP_SECRET }}
- name: Upload to Release
if: env.VERSION != 'DEBUG' && env.SKIP_UPLOADING_RELEASE_ASSET == '0'
uses: softprops/action-gh-release@v1
with:
prerelease: true
tag_name: ${{ env.VERSION }}
files: ${{ matrix.name }}
target_commitish: ${{ github.sha }}