forked from VOICEVOX/voicevox
-
Notifications
You must be signed in to change notification settings - Fork 1
914 lines (809 loc) · 36.3 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
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: Build
on:
push:
branches:
- main
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
env:
VOICEVOX_ENGINE_REPO_URL: "https://github.com/VOICEVOX/voicevox_engine"
VOICEVOX_ENGINE_VERSION: 0.14.5
VOICEVOX_RESOURCE_VERSION: 0.14.3
VOICEVOX_EDITOR_VERSION:
|- # releaseタグ名か、workflow_dispatchでのバージョン名か、999.999.999が入る
${{ github.event.release.tag_name || github.event.inputs.version || '999.999.999' }}
jobs:
build-noengine-prepackage:
environment: ${{ github.event.inputs.code_signing == 'true' && 'code_signing' || '' }} # コード署名用のenvironment(false時の挙動は2022年7月10日時点で未定義動作)
env:
ELECTRON_CACHE: .cache/electron
ELECTRON_BUILDER_CACHE: .cache/electron-builder
cache-version: v2
strategy:
fail-fast: false
matrix:
artifact_name:
- linux-noengine-prepackage
- linux-noengine-cpu-prepackage
- windows-noengine-prepackage
- windows-noengine-cpu-prepackage
- windows-noengine-directml-prepackage
- macos-noengine-cpu-prepackage
include:
# Linux NVIDIA GPU
- artifact_name: linux-noengine-prepackage
artifact_path: dist_electron/linux-unpacked
package_name: voicevox
linux_artifact_name: "VOICEVOX.${ext}"
linux_executable_name: voicevox
sed_name: sed
os: ubuntu-20.04
# Linux CPU
- artifact_name: linux-noengine-cpu-prepackage
artifact_path: dist_electron/linux-unpacked
package_name: voicevox-cpu
linux_artifact_name: "VOICEVOX.${ext}"
linux_executable_name: voicevox
sed_name: sed
os: ubuntu-20.04
# Windows CUDA
- artifact_name: windows-noengine-prepackage
artifact_path: dist_electron/win-unpacked
package_name: voicevox-cuda
nsis_web_artifact_name: "VOICEVOX-CUDA Web Setup ${version}.${ext}"
sed_name: sed
os: windows-2019
# Windows CPU
- artifact_name: windows-noengine-cpu-prepackage
artifact_path: dist_electron/win-unpacked
package_name: voicevox-cpu
nsis_web_artifact_name: "VOICEVOX-CPU Web Setup ${version}.${ext}"
sed_name: sed
os: windows-2019
# Windows DirectML
- artifact_name: windows-noengine-directml-prepackage
artifact_path: dist_electron/win-unpacked
package_name: voicevox
nsis_web_artifact_name: "VOICEVOX Web Setup ${version}.${ext}"
sed_name: sed
os: windows-2019
# macOS CPU
- artifact_name: macos-noengine-cpu-prepackage
artifact_path: dist_electron/mac
package_name: voicevox-cpu
macos_artifact_name: "VOICEVOX.${ext}"
sed_name: gsed
os: macos-11
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
# NOTE: The default sed of macOS is BSD sed.
# There is a difference in specification between BSD sed and GNU sed,
# so you need to install GNU sed.
- name: Install GNU sed on macOS
if: startsWith(matrix.os, 'macos-')
shell: bash
run: |
brew install gnu-sed
# Rename executable file
- name: Replace package name & version
shell: bash
run: |
"${{ matrix.sed_name }}" -i 's/"name": "voicevox"/"name": "${{ matrix.package_name }}"/' package.json
# "${{ matrix.sed_name }}" -i 's/productName: "VOICEVOX"/productName: "${{ matrix.product_name }}"/' vue.config.js
"${{ matrix.sed_name }}" -i 's/"version": "999.999.999"/"version": "${{ env.VOICEVOX_EDITOR_VERSION }}"/' package.json
# NOTE: The extraFiles of electron-builder uses VOICEVOX.app/Contents/ as the file copy destination.
# However, since the executable file is located in VOICEVOX.app/Contents/MacOS/,
# it is inappropriate to copy the extraFiles to the VOICEVOX.app/Contents/ directory.
# Fix it so that it is copied to the VOICEVOX.app/Contents/MacOS/ directory.
# cf. https://k-hyoda.hatenablog.com/entry/2021/10/23/000349#%E8%BF%BD%E5%8A%A0%E5%B1%95%E9%96%8B%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E5%85%88%E3%81%AE%E8%A8%AD%E5%AE%9A
- name: Replace the extraFiles setting in vue.config.js for macOS
if: startsWith(matrix.os, 'macos-')
shell: bash
run: |
"${{ matrix.sed_name }}" -i 's/from: "build\/README.txt", to: "README.txt"/from: "build\/README.txt", to: "MacOS\/README.txt"/' vue.config.js
"${{ matrix.sed_name }}" -i 's/from: ".env.production", to: ".env"/from: ".env.production", to: "MacOS\/.env"/' vue.config.js
# In order to replace two lines with sed, we need to replace LF with \n and treat it as one line. Finally, undo it.
# cf. https://deep.tacoskingdom.com/blog/15
str_config="$(cat vue.config.js)"
echo "${str_config//$'\n'/\\n}" | "${{ matrix.sed_name }}" -e 's/from: VOICEVOX_ENGINE_DIR,\\n[ ]*to: ""/from: VOICEVOX_ENGINE_DIR, to: "MacOS\/"/' -e s/'\\n'/\\$'\n'/g > vue.config.js
cat vue.config.js
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
- name: Cache Node packages
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ env.cache-version }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ env.cache-version }}-node-
- name: Cache Electron
uses: actions/cache@v3
with:
path: ${{ env.ELECTRON_CACHE }}
key: ${{ env.cache-version }}-${{ runner.os }}--electron-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ env.cache-version }}-${{ runner.os }}--electron-cache-
- name: Cache Electron-Builder
uses: actions/cache@v3
with:
path: ${{ env.ELECTRON_BUILDER_CACHE }}
key: ${{ env.cache-version }}-${{ runner.os }}--electron-builder-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ env.cache-version }}-${{ runner.os }}--electron-builder-cache-
- name: Install dependencies
shell: bash
run: npm ci
- name: Show disk space (debug info)
shell: bash
run: |
df -h
- name: Checkout Product Version Resource
uses: actions/checkout@v3
with:
repository: VOICEVOX/voicevox_resource
ref: ${{ env.VOICEVOX_RESOURCE_VERSION }}
path: resource
- name: Create and replace software resources
shell: bash
run: |
rm build/README.txt
rm public/policy.md
{
cat resource/editor/README.md
echo
cat resource/editor/ACKNOWLEDGMENTS.md
} \
> build/README.txt
cp build/README.txt public/policy.md
cp resource/editor/PRIVACYPOLICY.md public/privacyPolicy.md
- name: Overwrite .env.production for Linux and macOS
if: startsWith(matrix.os, 'ubuntu-') || startsWith(matrix.os, 'macos-')
shell: bash
run: |
"${{ matrix.sed_name }}" -i 's|run.exe|./run|g' .env.production
- name: Replace .env.production infomations
shell: bash
run: |
# GTM ID
gtm_id=$(jq -r '.VUE_APP_GTM_CONTAINER_ID' resource/editor/metas.json)
"${{ matrix.sed_name }}" -i 's/VUE_APP_GTM_CONTAINER_ID=.*/VUE_APP_GTM_CONTAINER_ID='"$gtm_id"'/' .env.production
- name: Generate public/licenses.json
shell: bash
run: npm run license:generate -- -o public/licenses.json
- name: Show disk space (debug info)
shell: bash
run: |
df -h
- name: Define Code Signing Envs
if: startsWith(matrix.os, 'windows-') && github.event.inputs.code_signing == 'true'
shell: bash
run: |
set -eux
bash build/codesign_setup.bash
echo "WIN_CERTIFICATE_SHA1=$(head -n 1 $THUMBPRINT_PATH)" >> $GITHUB_ENV
echo 'WIN_SIGNING_HASH_ALGORITHMS=["sha256"]' >> $GITHUB_ENV
echo "SIGNTOOL_PATH=$(head -n 1 $SIGNTOOL_PATH_PATH)" >> $GITHUB_ENV
# NOTE: electron-builder 22.14.13 は指定したsigntoolを使わないのでワークアラウンドでディレクトリを差し替える
CACHE_SIGNTOOL_DIR="$ELECTRON_BUILDER_CACHE/winCodeSign/winCodeSign-2.6.0/windows-10/x64"
mv "$CACHE_SIGNTOOL_DIR"{,.bak}
ln -s "$(dirname $(head -n 1 $SIGNTOOL_PATH_PATH))" "$CACHE_SIGNTOOL_DIR"
env:
ESIGNERCKA_USERNAME: ${{ secrets.ESIGNERCKA_USERNAME }}
ESIGNERCKA_PASSWORD: ${{ secrets.ESIGNERCKA_PASSWORD }}
ESIGNERCKA_TOTP_SECRET: ${{ secrets.ESIGNERCKA_TOTP_SECRET }}
THUMBPRINT_PATH: /tmp/esignercka_thumbprint.txt
SIGNTOOL_PATH_PATH: /tmp/signtool_path.txt
# Build result will be exported to ${{ matrix.artifact_path }}
- name: Build Electron
shell: bash
env:
NSIS_WEB_ARTIFACT_NAME: ${{ matrix.nsis_web_artifact_name }}
LINUX_ARTIFACT_NAME: ${{ matrix.linux_artifact_name }}
LINUX_EXECUTABLE_NAME: ${{ matrix.linux_executable_name }}
MACOS_ARTIFACT_NAME: ${{ matrix.macos_artifact_name }}
# https://github.com/electron-userland/electron-builder/issues/3179
USE_HARD_LINKS: false
run: npm run electron:build_pnever -- --dir
- name: Reset Code Signing Envs
if: startsWith(matrix.os, 'windows-') && github.event.inputs.code_signing == 'true'
shell: bash
run: |
bash build/codesign_cleanup.bash
echo 'WIN_CERTIFICATE_SHA1=' >> $GITHUB_ENV
echo 'WIN_SIGNING_HASH_ALGORITHMS=' >> $GITHUB_ENV
echo 'SIGNTOOL_PATH=' >> $GITHUB_ENV
# NOTE: ワークアラウンドで差し替えたディレクトリを元に戻す
CACHE_SIGNTOOL_DIR="$ELECTRON_BUILDER_CACHE/winCodeSign/winCodeSign-2.6.0/windows-10/x64"
rm -r "$CACHE_SIGNTOOL_DIR"
mv "$CACHE_SIGNTOOL_DIR"{.bak,}
env:
THUMBPRINT_PATH: /tmp/esignercka_thumbprint.txt
- name: Upload NoEngine Prepackage
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}
path: |
${{ matrix.artifact_path }}
build-engine-prepackage:
env:
cache-version: v2
needs: [build-noengine-prepackage]
strategy:
fail-fast: false
matrix:
# FIXME: env cannot be referenced in matrix
# voicevox_engine_repo_url:
# - ${{ env.VOICEVOX_ENGINE_REPO_URL }}
# voicevox_engine_version:
# - ${{ env.VOICEVOX_ENGINE_VERSION }}
os: [ubuntu-20.04]
artifact_name:
- linux-nvidia-prepackage
- linux-cpu-prepackage
- windows-nvidia-prepackage
- windows-cpu-prepackage
- windows-directml-prepackage
- macos-cpu-prepackage
include:
# Linux NVIDIA GPU
- artifact_name: linux-nvidia-prepackage
noengine_artifact_name: linux-noengine-prepackage
voicevox_engine_asset_name: linux-nvidia
linux_executable_name: voicevox
compressed_artifact_name: voicevox-linux-nvidia
app_asar_dir: prepackage/resources
# Linux CPU
- artifact_name: linux-cpu-prepackage
noengine_artifact_name: linux-noengine-cpu-prepackage
voicevox_engine_asset_name: linux-cpu
linux_executable_name: voicevox
compressed_artifact_name: voicevox-linux-cpu
app_asar_dir: prepackage/resources
# Windows NVIDIA GPU
- artifact_name: windows-nvidia-prepackage
noengine_artifact_name: windows-noengine-prepackage
voicevox_engine_asset_name: windows-nvidia
compressed_artifact_name: voicevox-windows-nvidia
app_asar_dir: prepackage/resources
# Windows CPU
- artifact_name: windows-cpu-prepackage
noengine_artifact_name: windows-noengine-cpu-prepackage
voicevox_engine_asset_name: windows-cpu
compressed_artifact_name: voicevox-windows-cpu
app_asar_dir: prepackage/resources
# Windows DirectML
- artifact_name: windows-directml-prepackage
noengine_artifact_name: windows-noengine-directml-prepackage
voicevox_engine_asset_name: windows-directml
compressed_artifact_name: voicevox-windows-directml
app_asar_dir: prepackage/resources
# macOS CPU
- artifact_name: macos-cpu-prepackage
noengine_artifact_name: macos-noengine-cpu-prepackage
voicevox_engine_asset_name: macos-x64
macos_executable_name: VOICEVOX
compressed_artifact_name: voicevox-macos-cpu
app_asar_dir: prepackage/VOICEVOX.app/Contents/Resources
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
- name: Cache Node packages
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ env.cache-version }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ env.cache-version }}-node-
- name: Install asar
shell: bash
run: npm install -g asar
- name: Install dependencies
shell: bash
run: npm ci
- name: Show disk space (debug info)
shell: bash
run: |
df -h
- name: Download and extract noengine-prepackage artifact
uses: actions/download-artifact@v3
with:
name: ${{ matrix.noengine_artifact_name }}
path: ./prepackage
# Download VOICEVOX ENGINE
- name: Create directory voicevox_engine/download
shell: bash
run: |
mkdir -p voicevox_engine/download
# NOTE: VOICEVOX ENGINE should not be cached since it has a size of several GB
# and actions/cache has a limit of 5GB per repository.
# https://github.com/actions/cache#cache-limits
# - name: Dump VOICEVOX ENGINE repo URL to calc hash
# shell: bash
# run: |
# echo "${{ env.VOICEVOX_ENGINE_REPO_URL }}" > voicevox_engine/repo_url.txt
# - name: Cache VOICEVOX ENGINE
# uses: actions/cache@v3
# id: voicevox-engine-cache
# with:
# path: voicevox_engine/download
# key: ${{ env.cache-version }}-voicevox-engine-${{ hashFiles('voicevox_engine/repo_url.txt') }}-${{ env.VOICEVOX_ENGINE_VERSION }}
- name: Download VOICEVOX ENGINE
# if: steps.voicevox-engine-cache.outputs.cache-hit != 'true'
shell: bash
env:
VOICEVOX_ENGINE_RELEASE_URL: ${{ env.VOICEVOX_ENGINE_REPO_URL }}/releases/download/${{ env.VOICEVOX_ENGINE_VERSION }}
run: |
curl -L -o "voicevox_engine/download/list.txt" "${{ env.VOICEVOX_ENGINE_RELEASE_URL }}/voicevox_engine-${{ matrix.voicevox_engine_asset_name }}-${{ env.VOICEVOX_ENGINE_VERSION }}.7z.txt"
cat "voicevox_engine/download/list.txt" | xargs -I '%' curl -L -o "voicevox_engine/download/%" "${{ env.VOICEVOX_ENGINE_RELEASE_URL }}/%"
- name: Extract VOICEVOX ENGINE
shell: bash
run: |
mkdir -p voicevox_engine/tmp
# Extract first file to extract all parts
# Destination: voicevox_engine/tmp/${{ matrix.voicevox_engine_asset_name }}/
7z x "voicevox_engine/download/$(head -n1 voicevox_engine/download/list.txt)" -ovoicevox_engine/tmp/
mkdir -p voicevox_engine/voicevox_engine
mv "voicevox_engine/tmp/${{ matrix.voicevox_engine_asset_name }}"/* voicevox_engine/voicevox_engine
# remove downloads to free space
rm -rf voicevox_engine/download voicevox_engine/tmp
- name: Merge licenses.json (ENGINE, VOICEVOX)
shell: bash
run: |
# Unpack asar
asar extract "${{ matrix.app_asar_dir }}/app.asar" "${{ matrix.app_asar_dir }}/app"
rm "${{ matrix.app_asar_dir }}/app.asar"
mv voicevox_engine/voicevox_engine/licenses.json engine_licenses.json
npm run license:merge -- -o "${{ matrix.app_asar_dir }}/app/licenses.json" -i engine_licenses.json -i "${{ matrix.app_asar_dir }}/app/licenses.json"
# Repack asar
asar pack "${{ matrix.app_asar_dir }}/app" "${{ matrix.app_asar_dir }}/app.asar"
rm -rf "${{ matrix.app_asar_dir }}/app"
- name: Merge VOICEVOX ENGINE into prepackage/
if: startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'linux-')
shell: bash
run: |
mv voicevox_engine/voicevox_engine/* prepackage/
rm -rf voicevox_engine
- name: Merge VOICEVOX ENGINE into prepackage/VOICEVOX.app/Contents/MacOS/
if: startsWith(matrix.artifact_name, 'macos-')
shell: bash
run: |
mv voicevox_engine/voicevox_engine/* prepackage/VOICEVOX.app/Contents/MacOS/
rm -rf voicevox_engine
- name: Show disk space (debug info)
shell: bash
run: |
df -h
- name: Upload prepackage artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}
path: |
prepackage/
- name: Recover file permissions
if: startsWith(matrix.artifact_name, 'linux-') # linux
shell: bash
run: |
chmod +x "prepackage/${{ matrix.linux_executable_name }}"
chmod +x "prepackage/run"
- name: Recover file permissions for macOS build
if: startsWith(matrix.artifact_name, 'macos-') # macOS
shell: bash
run: |
chmod +x "prepackage/VOICEVOX.app/Contents/MacOS/${{ matrix.macos_executable_name }}"
chmod +x "prepackage/VOICEVOX.app/Contents/MacOS/run"
chmod +x "prepackage/VOICEVOX.app/Contents/Frameworks/VOICEVOX Helper (GPU).app/Contents/MacOS/VOICEVOX Helper (GPU)"
chmod +x "prepackage/VOICEVOX.app/Contents/Frameworks/VOICEVOX Helper (Plugin).app/Contents/MacOS/VOICEVOX Helper (Plugin)"
chmod +x "prepackage/VOICEVOX.app/Contents/Frameworks/VOICEVOX Helper (Renderer).app/Contents/MacOS/VOICEVOX Helper (Renderer)"
chmod +x "prepackage/VOICEVOX.app/Contents/Frameworks/VOICEVOX Helper.app/Contents/MacOS/VOICEVOX Helper"
# NOTE: actions/upload-artifact@v3 does not upload `**.lproj` directories, which are an empty directory.
# Make `ja.lproj` directory because it is necessary for Japanese localization on macOS.
- name: Make .lproj directories in Resources directory of VOICEVOX.app
if: startsWith(matrix.artifact_name, 'macos-')
shell: bash
run: mkdir -p prepackage/VOICEVOX.app/Contents/Resources/ja.lproj prepackage/VOICEVOX.app/Contents/Resources/en.lproj
- name: Create Linux tar.gz
if: startsWith(matrix.artifact_name, 'linux-')
shell: bash
run: |
mv prepackage VOICEVOX
tar cfz "${{ matrix.compressed_artifact_name }}-${{ env.VOICEVOX_EDITOR_VERSION }}.tar.gz" VOICEVOX/
- name: Upload Linux tar.gz artifact
if: startsWith(matrix.artifact_name, 'linux-')
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}-targz
path: "${{ matrix.compressed_artifact_name }}-${{ env.VOICEVOX_EDITOR_VERSION }}.tar.gz"
- name: Create Windows & Mac zip
if: startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'macos-')
shell: bash
run: |
mv prepackage VOICEVOX
zip "${{ matrix.compressed_artifact_name }}-${{ env.VOICEVOX_EDITOR_VERSION }}.zip" -r VOICEVOX
- name: Upload Windows & Mac zip artifact
if: startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'macos-')
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}-zip
path: "${{ matrix.compressed_artifact_name }}-${{ env.VOICEVOX_EDITOR_VERSION }}.zip"
build-distributable:
if: (github.event.release.tag_name || github.event.inputs.version) != '' # If release
needs: [build-engine-prepackage]
environment: ${{ github.event.inputs.code_signing == 'true' && 'code_signing' || '' }} # コード署名用のenvironment
env:
ELECTRON_CACHE: .cache/electron
ELECTRON_BUILDER_CACHE: .cache/electron-builder
cache-version: v2
strategy:
fail-fast: false
matrix:
artifact_name:
- linux-nvidia-appimage
- linux-cpu-appimage
- windows-nvidia-nsis-web
- windows-cpu-nsis-web
- windows-directml-nsis-web
- macos-cpu-dmg
include:
# Linux NVIDIA GPU
- artifact_name: linux-nvidia-appimage
engine_artifact_name: linux-nvidia-prepackage
package_name: voicevox
linux_artifact_name: "VOICEVOX.${ext}"
linux_executable_name: voicevox
sed_name: sed
os: ubuntu-20.04
# Linux CPU
- artifact_name: linux-cpu-appimage
engine_artifact_name: linux-cpu-prepackage
package_name: voicevox-cpu
linux_artifact_name: "VOICEVOX.${ext}"
linux_executable_name: voicevox
sed_name: sed
os: ubuntu-20.04
# Windows NVIDIA GPU
- artifact_name: windows-nvidia-nsis-web
engine_artifact_name: windows-nvidia-prepackage
package_name: voicevox-cuda
nsis_web_artifact_name: "VOICEVOX-CUDA Web Setup ${version}.${ext}"
sed_name: sed
os: windows-2019
# Windows CPU
- artifact_name: windows-cpu-nsis-web
engine_artifact_name: windows-cpu-prepackage
package_name: voicevox-cpu
nsis_web_artifact_name: "VOICEVOX-CPU Web Setup ${version}.${ext}"
sed_name: sed
os: windows-2019
# Windows DirectML
- artifact_name: windows-directml-nsis-web
engine_artifact_name: windows-directml-prepackage
package_name: voicevox
nsis_web_artifact_name: "VOICEVOX Web Setup ${version}.${ext}"
sed_name: sed
os: windows-2019
# macOS CPU
- artifact_name: macos-cpu-dmg
engine_artifact_name: macos-cpu-prepackage
package_name: voicevox-cpu
macos_artifact_name: "VOICEVOX ${version}.${ext}"
macos_executable_name: VOICEVOX
sed_name: gsed
os: macos-11
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
# NOTE: The default sed of macOS is BSD sed.
# There is a difference in specification between BSD sed and GNU sed,
# so you need to install GNU sed.
- name: Install GNU sed on macOS
if: startsWith(matrix.os, 'macos-')
shell: bash
run: |
brew install gnu-sed
# NOTE: If the CPU/DirectML/GPU builds have the same package name,
# the NSIS installers and the 7z files have duplicate names.
# For Linux, If they have the same product name,
# the AppImages have duplicate names.
# Files with the same name cannot be uploaded to a single GitHub Release,
# so different package/product names should be used for CPU/DirectML/GPU builds.
- name: Replace package name & version
shell: bash
run: |
"${{ matrix.sed_name }}" -i 's/"name": "voicevox"/"name": "${{ matrix.package_name }}"/' package.json
# "${{ matrix.sed_name }}" -i 's/productName: "VOICEVOX"/productName: "${{ matrix.product_name }}"/' vue.config.js
"${{ matrix.sed_name }}" -i 's/"version": "999.999.999"/"version": "${{ env.VOICEVOX_EDITOR_VERSION }}"/' package.json
- name: Download and extract engine-prepackage artifact
uses: actions/download-artifact@v3
with:
name: ${{ matrix.engine_artifact_name }}
path: ./prepackage
- name: Recover file permissions
if: endsWith(matrix.artifact_name, '-appimage') # linux
shell: bash
run: |
chmod +x "prepackage/${{ matrix.linux_executable_name }}"
chmod +x "prepackage/run"
- name: Recover file permissions for macOS build
if: endsWith(matrix.artifact_name, '-dmg') # macOS
shell: bash
run: |
chmod +x "prepackage/VOICEVOX.app/Contents/MacOS/${{ matrix.macos_executable_name }}"
chmod +x "prepackage/VOICEVOX.app/Contents/MacOS/run"
chmod +x "prepackage/VOICEVOX.app/Contents/Frameworks/VOICEVOX Helper (GPU).app/Contents/MacOS/VOICEVOX Helper (GPU)"
chmod +x "prepackage/VOICEVOX.app/Contents/Frameworks/VOICEVOX Helper (Plugin).app/Contents/MacOS/VOICEVOX Helper (Plugin)"
chmod +x "prepackage/VOICEVOX.app/Contents/Frameworks/VOICEVOX Helper (Renderer).app/Contents/MacOS/VOICEVOX Helper (Renderer)"
chmod +x "prepackage/VOICEVOX.app/Contents/Frameworks/VOICEVOX Helper.app/Contents/MacOS/VOICEVOX Helper"
# NOTE: actions/upload-artifact@v3 does not upload `**.lproj` directories, which are an empty directory.
# Make `ja.lproj` directory because it is necessary for Japanese localization on macOS.
- name: Make .lproj directories in Resources directory of VOICEVOX.app
if: endsWith(matrix.artifact_name, '-dmg')
shell: bash
run: mkdir -p prepackage/VOICEVOX.app/Contents/Resources/ja.lproj prepackage/VOICEVOX.app/Contents/Resources/en.lproj
- name: Show disk space (debug info)
shell: bash
run: |
df -h
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
- name: Cache Node packages
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ env.cache-version }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ env.cache-version }}-node-
- name: Cache Electron
uses: actions/cache@v3
with:
path: ${{ env.ELECTRON_CACHE }}
key: ${{ env.cache-version }}-${{ runner.os }}--electron-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ env.cache-version }}-${{ runner.os }}--electron-cache-
- name: Cache Electron-Builder
uses: actions/cache@v3
with:
path: ${{ env.ELECTRON_BUILDER_CACHE }}
key: ${{ env.cache-version }}-${{ runner.os }}--electron-builder-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ env.cache-version }}-${{ runner.os }}--electron-builder-cache-
- name: Install dependencies
shell: bash
run: npm ci
- name: Show disk space (debug info)
shell: bash
run: |
df -h
- name: Define Code Signing Envs
if: endsWith(matrix.artifact_name, '-nsis-web') && github.event.inputs.code_signing == 'true'
shell: bash
run: |
set -eux
bash build/codesign_setup.bash
echo "WIN_CERTIFICATE_SHA1=$(head -n 1 $THUMBPRINT_PATH)" >> $GITHUB_ENV
echo 'WIN_SIGNING_HASH_ALGORITHMS=["sha256"]' >> $GITHUB_ENV
echo "SIGNTOOL_PATH=$(head -n 1 $SIGNTOOL_PATH_PATH)" >> $GITHUB_ENV
# NOTE: electron-builder 22.14.13 は指定したsigntoolを使わないのでワークアラウンドでディレクトリを差し替える
CACHE_SIGNTOOL_DIR="$ELECTRON_BUILDER_CACHE/winCodeSign/winCodeSign-2.6.0/windows-10/x64"
mv "$CACHE_SIGNTOOL_DIR"{,.bak}
ln -s "$(dirname $(head -n 1 $SIGNTOOL_PATH_PATH))" "$CACHE_SIGNTOOL_DIR"
env:
ESIGNERCKA_USERNAME: ${{ secrets.ESIGNERCKA_USERNAME }}
ESIGNERCKA_PASSWORD: ${{ secrets.ESIGNERCKA_PASSWORD }}
ESIGNERCKA_TOTP_SECRET: ${{ secrets.ESIGNERCKA_TOTP_SECRET }}
THUMBPRINT_PATH: /tmp/esignercka_thumbprint.txt
SIGNTOOL_PATH_PATH: /tmp/signtool_path.txt
# NOTE: prepackage can be removed before splitting nsis-web archive
- name: Build Electron
if: endsWith(matrix.artifact_name, '-nsis-web') || endsWith(matrix.artifact_name, '-appimage') # windows and linux
shell: bash
env:
NSIS_WEB_ARTIFACT_NAME: ${{ matrix.nsis_web_artifact_name }}
LINUX_ARTIFACT_NAME: ${{ matrix.linux_artifact_name }}
LINUX_EXECUTABLE_NAME: ${{ matrix.linux_executable_name }}
run: npm run electron:build_pnever -- --prepackaged "prepackage/"
- name: Build Electron (for macOS)
if: endsWith(matrix.artifact_name, '-dmg') # macOS
shell: bash
env:
MACOS_ARTIFACT_NAME: ${{ matrix.macos_artifact_name }}
run: npm run electron:build_pnever -- --prepackaged "prepackage/VOICEVOX.app"
- name: Reset Code Signing Envs
if: endsWith(matrix.artifact_name, '-nsis-web') && github.event.inputs.code_signing == 'true'
shell: bash
run: |
bash build/codesign_cleanup.bash
echo 'WIN_CERTIFICATE_SHA1=' >> $GITHUB_ENV
echo 'WIN_SIGNING_HASH_ALGORITHMS=' >> $GITHUB_ENV
echo 'SIGNTOOL_PATH=' >> $GITHUB_ENV
# NOTE: ワークアラウンドで差し替えたディレクトリを元に戻す
CACHE_SIGNTOOL_DIR="$ELECTRON_BUILDER_CACHE/winCodeSign/winCodeSign-2.6.0/windows-10/x64"
rm -r "$CACHE_SIGNTOOL_DIR"
mv "$CACHE_SIGNTOOL_DIR"{.bak,}
env:
THUMBPRINT_PATH: /tmp/esignercka_thumbprint.txt
- name: Show disk space (debug info)
shell: bash
run: |
df -h
- name: Upload Linux AppImage artifact
if: endsWith(matrix.artifact_name, '-appimage')
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}
path: |
dist_electron/*.AppImage
- name: Upload macOS dmg artifact
if: endsWith(matrix.artifact_name, '-dmg')
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}
path: |
dist_electron/*.dmg
- name: Create Windows NSIS Web artifact directory
if: endsWith(matrix.artifact_name, '-nsis-web')
shell: bash
run: |
mkdir -p nsis-web-artifact
mv dist_electron/nsis-web/out/*.7z.* nsis-web-artifact/
mv dist_electron/nsis-web/*.exe nsis-web-artifact/
# Rename file name like "VOICEVOX Web Setup X.X.X.exe" to "VOICEVOX.Web.Setup.X.X.X.exe".
- name: Rename Windows NSIS Web Installer
if: endsWith(matrix.artifact_name, '-nsis-web')
shell: bash
run: |
cd nsis-web-artifact
OLD_NAME=`find . -maxdepth 1 -name '*.exe'`
# replace space by dot(.)
NEW_NAME=${OLD_NAME// /.}
mv "${OLD_NAME}" $NEW_NAME
- name: Upload Windows NSIS Web artifact
if: endsWith(matrix.artifact_name, '-nsis-web')
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}
path: |
nsis-web-artifact/*
upload-distributable-to-release:
if: (github.event.release.tag_name || github.event.inputs.version) != '' # If release
needs: [build-distributable]
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
artifact_name:
- linux-nvidia-appimage
- linux-cpu-appimage
- linux-nvidia-prepackage-targz
- linux-cpu-prepackage-targz
- windows-nvidia-nsis-web
- windows-cpu-nsis-web
- windows-directml-nsis-web
- windows-nvidia-prepackage-zip
- windows-cpu-prepackage-zip
- windows-directml-prepackage-zip
- macos-cpu-dmg
- macos-cpu-prepackage-zip
include:
- artifact_name: linux-nvidia-appimage
appimage_7z_name: VOICEVOX.AppImage
- artifact_name: linux-cpu-appimage
appimage_7z_name: VOICEVOX-CPU.AppImage
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Download and extract distributable artifact
uses: actions/download-artifact@v3
with:
name: ${{ matrix.artifact_name }}
path: ./artifact
- name: Show disk space (debug info)
shell: bash
run: |
df -h
# Linux AppImage
- name: Install dependencies for Linux AppImage Upload
if: endsWith(matrix.artifact_name, '-appimage')
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y p7zip-full
- name: Split AppImage artifact
if: endsWith(matrix.artifact_name, '-appimage')
shell: bash
run: |
cd artifact/
for appImageFile in *.AppImage; do
echo "Splitting ${appImageFile}"
# compressed to MyArtifact.AppImage.7z.001, MyArtifact.AppImage.7z.002, ...
7z -v1g a "${{ matrix.appimage_7z_name }}.7z" "${appImageFile}"
# Output splitted archive name<TAB>size<TAB>hash list to myartifact.7z.txt
ls "${{ matrix.appimage_7z_name }}.7z".* > archives_name.txt
stat --printf="%s\n" "${{ matrix.appimage_7z_name }}.7z".* > archives_size.txt
md5sum "${{ matrix.appimage_7z_name }}.7z".* | awk '{print $1}' | tr a-z A-Z > archives_hash.txt
paste -d '\t' archives_name.txt archives_size.txt archives_hash.txt > archives.txt
mv archives.txt "${{ matrix.artifact_name }}.7z.txt"
done
- name: Show disk space (debug info)
if: endsWith(matrix.artifact_name, '-appimage')
shell: bash
run: |
df -h
- name: Upload Linux AppImage Release artifact
if: endsWith(matrix.artifact_name, '-appimage')
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}-release
path: |
artifact/*.7z.*
- name: Upload Linux AppImage splitted archives to Release assets
if: endsWith(matrix.artifact_name, '-appimage')
uses: softprops/action-gh-release@v1
with:
prerelease: ${{ github.event.inputs.prerelease }}
tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }}
files: |-
artifact/*.7z.*
target_commitish: ${{ github.sha }}
# Windows NSIS Web
- name: Upload Windows nsis-web archives to Release assets
if: endsWith(matrix.artifact_name, '-nsis-web')
uses: softprops/action-gh-release@v1
with:
prerelease: ${{ github.event.inputs.prerelease }}
tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }}
files: |-
artifact/*.7z.*
artifact/*.exe
target_commitish: ${{ github.sha }}
# macOS dmg
- name: Upload macOS dmg to Release assets
if: endsWith(matrix.artifact_name, '-dmg')
uses: softprops/action-gh-release@v1
with:
prerelease: ${{ github.event.inputs.prerelease }}
tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }}
files: |-
artifact/*.dmg
target_commitish: ${{ github.sha }}
# targz
- name: Upload targz to Release assets
if: endsWith(matrix.artifact_name, '-targz')
uses: softprops/action-gh-release@v1
with:
prerelease: ${{ github.event.inputs.prerelease }}
tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }}
files: |-
artifact/*.tar.gz
target_commitish: ${{ github.sha }}
# zip
- name: Upload zip to Release assets
if: endsWith(matrix.artifact_name, '-zip')
uses: softprops/action-gh-release@v1
with:
prerelease: ${{ github.event.inputs.prerelease }}
tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }}
files: |-
artifact/*.zip
target_commitish: ${{ github.sha }}