-
Notifications
You must be signed in to change notification settings - Fork 6
273 lines (231 loc) · 9.95 KB
/
build-engine-package.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
name: Build
on:
# push:
# branches:
# - master
release:
types:
- created
workflow_dispatch:
inputs:
version:
description: "バージョン情報 (A.BB.C / A.BB.C-preview.D)"
required: true
prerelease:
description: "プレリリースかどうか"
type: boolean
default: true
code_signing:
description: "コード署名する"
type: boolean
default: false
upload_artifact:
description: "デバッグ用に成果物を artifact にアップロードするか"
type: boolean
default: false
env:
PYTHON_VERSION: "3.11.9"
defaults:
run:
shell: bash
jobs:
config: # 全 jobs で利用する定数の定義. `env` が利用できないコンテキストでも利用できる.
runs-on: ubuntu-latest
outputs:
version: ${{ steps.vars.outputs.version }}
version_or_latest: ${{ steps.vars.outputs.version_or_latest }}
steps:
- name: <Setup> Declare variables
id: vars
run: |
: # release タグ名, または workflow_dispatch でのバージョン名. リリースでない (push event) 場合は空文字列
echo "version=${{ github.event.release.tag_name || github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
: # release タグ名, または workflow_dispatch でのバージョン名, または 'latest'
echo "version_or_latest=${{ github.event.release.tag_name || github.event.inputs.version || 'latest' }}" >> "$GITHUB_OUTPUT"
build-and-upload:
needs: [config]
environment: ${{ github.event.inputs.code_signing == 'true' && 'code_signing' || '' }} # コード署名用のenvironment
strategy:
matrix:
include:
# Windows x64
- os: windows-2022
architecture: "x64"
target: windows-x64
# macOS x64 (Intel Mac)
- os: macos-12
architecture: "x64"
target: macos-x64
# macOS arm64 (Apple Silicon Mac)
- os: macos-14
architecture: "arm64"
target: macos-arm64
# Linux x64
- os: ubuntu-20.04
architecture: "x64"
target: linux-x64
runs-on: ${{ matrix.os }}
permissions:
contents: write
env:
# GNUコマンド
sed: ${{ startsWith(matrix.os, 'macos-') && 'gsed' || 'sed' }}
split: ${{ startsWith(matrix.os, 'macos-') && 'gsplit' || 'split' }}
steps:
- name: <Setup> Declare variables
id: vars
run: echo "package_name=aivisspeech-engine-${{ matrix.target }}-${{ needs.config.outputs.version }}" >> "$GITHUB_OUTPUT"
- name: <Setup> Check out the repository
uses: actions/checkout@v4
# NOTE: The default 'sed' and 'split' of macOS is BSD 'sed' and 'split'.
# There is a difference in specification between BSD 'sed' and 'split' and GNU 'sed' and 'split',
# so you need to install GNU 'sed' and 'split'.
- name: <Setup> Install dependencies (macOS)
if: startsWith(matrix.os, 'macos-')
run: brew install gnu-sed coreutils
- name: <Setup> Set up MSVC
if: startsWith(matrix.os, 'windows-')
uses: ilammy/msvc-dev-cmd@v1
# Python install path of windows: C:/hostedtoolcache/windows/Python
- name: <Setup> Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: ${{ matrix.architecture }}
- name: <Setup> Install Poetry
run: python -m pip install poetry
- name: <Setup> Cache Poetry
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
- name: <Setup> Install Python dependencies
run: poetry install --with=build
- name: <Setup> Prepare custom PyInstaller
if: startsWith(matrix.os, 'windows-')
run: ./build_util/modify_pyinstaller.bash
- name: <Setup> Download pyopenjtalk dictionary
run: |
# try 5 times, sleep 5 seconds before retry
for _ in $(seq 5); do
EXIT_CODE=0
poetry run python -c "import pyopenjtalk; pyopenjtalk._lazy_init()" || EXIT_CODE=$?
if [ "$EXIT_CODE" = "0" ]; then
break
fi
sleep 5
done
if [ "$EXIT_CODE" != "0" ]; then
exit "$EXIT_CODE"
fi
- name: <Setup> Create download directory
run: mkdir -p download/
# Build
- name: <Build> Generate licenses.json
run: bash build_util/create_venv_and_generate_licenses.bash
- name: <Build> Build AivisSpeech Engine run.py
run: |
set -eux
jq '.version = "${{ needs.config.outputs.version_or_latest }}"' engine_manifest.json > engine_manifest.json.tmp
mv -f engine_manifest.json.tmp engine_manifest.json
# Replace version & specify dynamic libraries
$sed -i "s/__version__ = \"latest\"/__version__ = \"${{ needs.config.outputs.version_or_latest }}\"/" voicevox_engine/__init__.py
poetry run task build
- name: <Setup> Set @rpath to @executable_path
if: startsWith(matrix.os, 'macos-')
run: install_name_tool -add_rpath @executable_path/. dist/run/run
- name: <Build> Code signing
if: github.event.inputs.code_signing == 'true' && startsWith(matrix.os, 'windows-')
run: bash build_util/codesign.bash "dist/run/run.exe"
env:
ESIGNERCKA_USERNAME: ${{ secrets.ESIGNERCKA_USERNAME }}
ESIGNERCKA_PASSWORD: ${{ secrets.ESIGNERCKA_PASSWORD }}
ESIGNERCKA_TOTP_SECRET: ${{ secrets.ESIGNERCKA_TOTP_SECRET }}
- name: <Build> Rename artifact directory to archive
run: mv dist/run/ "${{ matrix.target }}/"
# 7z archives
- name: <Build> Create 7z archives
run: |
# Compress to artifact.7z.001, artifact.7z.002, ...
7z -r -v1900m a "${{ steps.vars.outputs.package_name }}.7z" "${{ matrix.target }}/"
# Output splitted archive list
ls ${{ steps.vars.outputs.package_name }}.7z.* > archives_7z.txt
mv archives_7z.txt "${{ steps.vars.outputs.package_name }}.7z.txt"
- name: <Deploy> Upload 7z archives to artifact
if: github.event.inputs.upload_artifact == 'true'
uses: actions/upload-artifact@v3
with:
name: ${{ steps.vars.outputs.package_name }}
path: |
${{ steps.vars.outputs.package_name }}.7z.*
- name: <Deploy> Upload 7z archives to Release assets
if: needs.config.outputs.version != ''
uses: ncipollo/release-action@v1
with:
allowUpdates: true
prerelease: ${{ github.event.inputs.prerelease }}
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.config.outputs.version }}
artifacts: >
${{ steps.vars.outputs.package_name }}.7z.*
commit: ${{ github.sha }}
- name: <Setup> Clean 7z archives to reduce disk usage
run: rm -f ${{ steps.vars.outputs.package_name }}.7z.*
# VVPP archives
- name: <Build> Create VVPP archives
run: |
# Compress to compressed.zip.001, compressed.zip.002, ...
# NOTE: 1000th archive will be "compressed.zip.1000" after "compressed.zip.999". This is unconsidered as an extreme case.
(cd "${{ matrix.target }}" && 7z -r -v1900M a "../compressed.zip")
# Rename to artifact.001.vvppp, artifact.002.vvppp, ...
for FILE in compressed.zip.*; do
NUMBER=${FILE##*.} # 001
mv "${FILE}" "${{ steps.vars.outputs.package_name }}.${NUMBER}.vvppp"
done
# Rename to artifact.vvpp if there are only artifact.001.vvppp
if [ "$(find ${{ steps.vars.outputs.package_name }}.*.vvppp -maxdepth 1 | wc -l)" == 1 ]; then
mv ${{ steps.vars.outputs.package_name }}.001.vvppp ${{ steps.vars.outputs.package_name }}.vvpp
fi
# Output splitted archive list
ls ${{ steps.vars.outputs.package_name }}*.vvppp ${{ steps.vars.outputs.package_name }}.vvpp > archives_vvpp.txt || true
mv archives_vvpp.txt "${{ steps.vars.outputs.package_name }}.vvpp.txt"
- name: <Deploy> Upload VVPP archives to artifact
if: github.event.inputs.upload_artifact == 'true'
uses: actions/upload-artifact@v3
with:
name: ${{ steps.vars.outputs.package_name }}
path: |
${{ steps.vars.outputs.package_name }}.vvpp
${{ steps.vars.outputs.package_name }}*.vvppp
${{ steps.vars.outputs.package_name }}.vvpp.txt
- name: <Deploy> Upload VVPP archives to Release assets
if: needs.config.outputs.version != ''
uses: ncipollo/release-action@v1
with:
allowUpdates: true
prerelease: ${{ github.event.inputs.prerelease }}
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.config.outputs.version }}
artifacts: >
${{ steps.vars.outputs.package_name }}.vvpp,
${{ steps.vars.outputs.package_name }}*.vvppp,
${{ steps.vars.outputs.package_name }}.vvpp.txt
commit: ${{ github.sha }}
update-tag-to-current-commit:
if: needs.config.outputs.version != ''
needs: [config, build-and-upload]
runs-on: ubuntu-latest
steps:
- name: <Setup> Check out the repository
uses: actions/checkout@v4
- name: <Deploy> Change tag to this commit for refreshing the release # c.f. voicevox_engine#854
run: |
git tag -f ${{ needs.config.outputs.version }}
git push -f --tag
run-release-test-workflow:
if: needs.config.outputs.version != ''
needs: [config, build-and-upload]
uses: ./.github/workflows/test-engine-package.yml
with:
version: ${{ needs.config.outputs.version }}
repo_url: ${{ format('{0}/{1}', github.server_url, github.repository) }} # このリポジトリのURL