Skip to content

Commit 2cfda67

Browse files
Hiroshibay-chan
andauthored
build.ymlのbuild部分とupload部分を一貫させる (#1257)
Co-authored-by: Yuto Ashida <[email protected]>
1 parent f0f2749 commit 2cfda67

File tree

4 files changed

+145
-165
lines changed

4 files changed

+145
-165
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: "Upload Release Aassets and Artifacts"
2+
description: |
3+
releaseのassetとartifactにアップロードする。
4+
release・artifactにアップロードするかはそれぞれ制御できる。
5+
6+
inputs:
7+
files:
8+
description: "アップロードするファイルのパス。ワイルドカードも使える。複数指定する場合は改行で区切る。"
9+
type: string
10+
required: true
11+
upload_release:
12+
description: "releaseにアップロードするか。"
13+
type: boolean
14+
default: false
15+
upload_artifact:
16+
description: "artifactにアップロードするか。"
17+
type: boolean
18+
default: false
19+
prerelease:
20+
description: "pre-releaseかどうか。"
21+
type: boolean
22+
default: false
23+
tag_name:
24+
description: "タグ名。"
25+
type: string
26+
target_commitish:
27+
description: "タグを付けるコミットID。"
28+
type: string
29+
artifact_name:
30+
description: "artifact名。"
31+
type: string
32+
33+
runs:
34+
using: "composite"
35+
steps:
36+
- name: Upload to Artifacts
37+
if: inputs.artifact_name != ''
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: ${{ inputs.artifact_name }}
41+
path: ${{ inputs.files }}
42+
43+
- name: Upload to Release Assets
44+
uses: softprops/action-gh-release@v1
45+
with:
46+
prerelease: ${{ inputs.prerelease }}
47+
tag_name: ${{ inputs.tag_name }}
48+
files: ${{ inputs.files }}
49+
target_commitish: ${{ inputs.target_commitish }}

.github/workflows/build.yml

+93-165
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ on:
1919
code_signing:
2020
description: "コード署名する"
2121
type: boolean
22+
upload_artifact:
23+
description: "デバッグ用に成果物をartifactにアップロードするか"
24+
type: boolean
25+
default: false
2226

2327
env:
2428
VOICEVOX_ENGINE_REPO_URL: "https://github.com/VOICEVOX/voicevox_engine"
@@ -29,7 +33,7 @@ env:
2933
${{ github.event.release.tag_name || github.event.inputs.version || '999.999.999' }}
3034

3135
jobs:
32-
build:
36+
build-and-upload:
3337
environment: ${{ github.event.inputs.code_signing == 'true' && 'code_signing' || '' }} # コード署名用のenvironment(false時の挙動は2022年7月10日時点で未定義動作)
3438
env:
3539
ELECTRON_CACHE: .cache/electron
@@ -56,6 +60,7 @@ jobs:
5660
installer_artifact_name: linux-nvidia-appimage
5761
linux_artifact_name: "VOICEVOX.${ext}"
5862
linux_executable_name: voicevox
63+
linux_appimage_7z_name: VOICEVOX.AppImage
5964
sed_name: sed
6065
os: ubuntu-20.04
6166
# Linux CPU
@@ -68,6 +73,7 @@ jobs:
6873
installer_artifact_name: linux-cpu-appimage
6974
linux_artifact_name: "VOICEVOX.${ext}"
7075
linux_executable_name: voicevox
76+
linux_appimage_7z_name: VOICEVOX-CPU.AppImage
7177
sed_name: sed
7278
os: ubuntu-20.04
7379
# Windows CUDA
@@ -359,8 +365,8 @@ jobs:
359365
shell: bash
360366
run: mkdir -p prepackage/VOICEVOX.app/Contents/Resources/ja.lproj prepackage/VOICEVOX.app/Contents/Resources/en.lproj
361367

362-
- name: Create Linux tar.gz
363-
if: startsWith(matrix.artifact_name, 'linux-')
368+
- name: Create Linux tar.gz (without nvidia)
369+
if: startsWith(matrix.artifact_name, 'linux-') && !contains(matrix.artifact_name, 'nvidia')
364370
shell: bash
365371
run: |
366372
name="${{ matrix.compressed_artifact_name }}-${{ env.VOICEVOX_EDITOR_VERSION }}"
@@ -369,27 +375,51 @@ jobs:
369375
7z a -tgzip $name.tar.gz $name.tar
370376
rm $name.tar
371377
372-
- name: Upload Linux tar.gz artifact
373-
if: startsWith(matrix.artifact_name, 'linux-')
374-
uses: actions/upload-artifact@v3
378+
- name: Upload Linux tar.gz (without nvidia)
379+
if: startsWith(matrix.artifact_name, 'linux-') && !contains(matrix.artifact_name, 'nvidia')
380+
uses: ./.github/actions/upload-release-and-artifact
375381
with:
376-
name: ${{ matrix.artifact_name }}-targz
377-
path: "${{ matrix.compressed_artifact_name }}-${{ env.VOICEVOX_EDITOR_VERSION }}.tar.gz"
382+
files: |-
383+
${{ matrix.compressed_artifact_name }}-${{ env.VOICEVOX_EDITOR_VERSION }}.tar.gz
384+
upload_release: ${{ (github.event.release.tag_name || github.event.inputs.version) != '' }}
385+
upload_artifact: ${{ github.event.inputs.upload_artifact }}
386+
prerelease: ${{ github.event.inputs.prerelease }}
387+
tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }}
388+
target_commitish: ${{ github.sha }}
389+
artifact_name: ${{ matrix.artifact_name }}-targz
378390

379-
- name: Create Windows & Mac zip
380-
if: startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'macos-')
391+
- name: Delete Linux tar.gz (without nvidia)
392+
if: startsWith(matrix.artifact_name, 'linux-') && !contains(matrix.artifact_name, 'nvidia')
393+
shell: bash
394+
run: |
395+
rm ${{ matrix.compressed_artifact_name }}-${{ env.VOICEVOX_EDITOR_VERSION }}.tar.gz
396+
397+
- name: Create Windows & Mac zip (without nvidia)
398+
if: (startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'macos-')) && !contains(matrix.artifact_name, 'nvidia')
381399
shell: bash
382400
run: |
383401
name="${{ matrix.compressed_artifact_name }}-${{ env.VOICEVOX_EDITOR_VERSION }}"
384402
7z a -tzip $name.zip prepackage/
385403
7z rn $name.zip prepackage/ VOICEVOX/
386404
387-
- name: Upload Windows & Mac zip artifact
388-
if: startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'macos-')
389-
uses: actions/upload-artifact@v3
405+
- name: Upload Windows & Mac zip (without nvidia)
406+
if: (startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'macos-')) && !contains(matrix.artifact_name, 'nvidia')
407+
uses: ./.github/actions/upload-release-and-artifact
390408
with:
391-
name: ${{ matrix.artifact_name }}-zip
392-
path: "${{ matrix.compressed_artifact_name }}-${{ env.VOICEVOX_EDITOR_VERSION }}.zip"
409+
files: |-
410+
${{ matrix.compressed_artifact_name }}-${{ env.VOICEVOX_EDITOR_VERSION }}.zip
411+
upload_release: ${{ (github.event.release.tag_name || github.event.inputs.version) != '' }}
412+
upload_artifact: ${{ github.event.inputs.upload_artifact }}
413+
prerelease: ${{ github.event.inputs.prerelease }}
414+
tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }}
415+
target_commitish: ${{ github.sha }}
416+
artifact_name: ${{ matrix.artifact_name }}-zip
417+
418+
- name: Delete Windows & Mac zip (without nvidia)
419+
if: (startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'macos-')) && !contains(matrix.artifact_name, 'nvidia')
420+
shell: bash
421+
run: |
422+
rm ${{ matrix.compressed_artifact_name }}-${{ env.VOICEVOX_EDITOR_VERSION }}.zip
393423
394424
- name: Show disk space (debug info)
395425
shell: bash
@@ -440,21 +470,53 @@ jobs:
440470
run: |
441471
df -h
442472
443-
- name: Upload Linux AppImage artifact
473+
- name: Create Linux AppImage split
474+
if: endsWith(matrix.installer_artifact_name, '-appimage')
475+
shell: bash
476+
run: |
477+
cd dist_electron/
478+
479+
for appImageFile in *.AppImage; do
480+
echo "Splitting ${appImageFile}"
481+
482+
# compressed to MyArtifact.AppImage.7z.001, MyArtifact.AppImage.7z.002, ...
483+
7z -v1g a "${{ matrix.linux_appimage_7z_name }}.7z" "${appImageFile}"
484+
485+
# Output split archive name<TAB>size<TAB>hash list to myartifact.7z.txt
486+
ls "${{ matrix.linux_appimage_7z_name }}.7z".* > archives_name.txt
487+
stat --printf="%s\n" "${{ matrix.linux_appimage_7z_name }}.7z".* > archives_size.txt
488+
md5sum "${{ matrix.linux_appimage_7z_name }}.7z".* | awk '{print $1}' | tr a-z A-Z > archives_hash.txt
489+
490+
paste -d '\t' archives_name.txt archives_size.txt archives_hash.txt > archives.txt
491+
492+
mv archives.txt "${{ matrix.installer_artifact_name }}.7z.txt"
493+
done
494+
495+
- name: Upload Linux AppImage split
444496
if: endsWith(matrix.installer_artifact_name, '-appimage')
445-
uses: actions/upload-artifact@v3
497+
uses: ./.github/actions/upload-release-and-artifact
446498
with:
447-
name: ${{ matrix.installer_artifact_name }}
448-
path: |
449-
dist_electron/*.AppImage
499+
files: |-
500+
dist_electron/*.7z.*
501+
upload_release: ${{ (github.event.release.tag_name || github.event.inputs.version) != '' }}
502+
upload_artifact: ${{ github.event.inputs.upload_artifact }}
503+
prerelease: ${{ github.event.inputs.prerelease }}
504+
tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }}
505+
target_commitish: ${{ github.sha }}
506+
artifact_name: ${{ matrix.installer_artifact_name }}-release
450507

451-
- name: Upload macOS dmg artifact
508+
- name: Upload macOS dmg
452509
if: endsWith(matrix.installer_artifact_name, '-dmg')
453-
uses: actions/upload-artifact@v3
510+
uses: ./.github/actions/upload-release-and-artifact
454511
with:
455-
name: ${{ matrix.installer_artifact_name }}
456-
path: |
512+
files: |-
457513
dist_electron/*.dmg
514+
upload_release: ${{ (github.event.release.tag_name || github.event.inputs.version) != '' }}
515+
upload_artifact: ${{ github.event.inputs.upload_artifact }}
516+
prerelease: ${{ github.event.inputs.prerelease }}
517+
tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }}
518+
target_commitish: ${{ github.sha }}
519+
artifact_name: ${{ matrix.installer_artifact_name }}
458520

459521
- name: Create Windows NSIS Web artifact directory
460522
if: endsWith(matrix.installer_artifact_name, '-nsis-web')
@@ -475,150 +537,16 @@ jobs:
475537
NEW_NAME=${OLD_NAME// /.}
476538
mv "${OLD_NAME}" $NEW_NAME
477539
478-
- name: Upload Windows NSIS Web artifact
540+
- name: Upload Windows NSIS Web
479541
if: endsWith(matrix.installer_artifact_name, '-nsis-web')
480-
uses: actions/upload-artifact@v3
481-
with:
482-
name: ${{ matrix.installer_artifact_name }}
483-
path: |
484-
nsis-web-artifact/*
485-
486-
upload-distributable-to-release:
487-
if: (github.event.release.tag_name || github.event.inputs.version) != '' # If release
488-
needs: [build]
489-
strategy:
490-
fail-fast: false
491-
matrix:
492-
os: [ubuntu-20.04]
493-
artifact_name:
494-
- linux-nvidia-appimage
495-
- linux-cpu-appimage
496-
- linux-nvidia-prepackage-targz
497-
- linux-cpu-prepackage-targz
498-
- windows-nvidia-nsis-web
499-
- windows-cpu-nsis-web
500-
- windows-directml-nsis-web
501-
- windows-nvidia-prepackage-zip
502-
- windows-cpu-prepackage-zip
503-
- windows-directml-prepackage-zip
504-
- macos-cpu-dmg
505-
- macos-cpu-prepackage-zip
506-
include:
507-
- artifact_name: linux-nvidia-appimage
508-
appimage_7z_name: VOICEVOX.AppImage
509-
- artifact_name: linux-cpu-appimage
510-
appimage_7z_name: VOICEVOX-CPU.AppImage
511-
512-
runs-on: ${{ matrix.os }}
513-
steps:
514-
- uses: actions/checkout@v3
515-
516-
- name: Download and extract distributable artifact
517-
uses: actions/download-artifact@v3
542+
uses: ./.github/actions/upload-release-and-artifact
518543
with:
519-
name: ${{ matrix.artifact_name }}
520-
path: ./artifact
521-
522-
- name: Show disk space (debug info)
523-
shell: bash
524-
run: |
525-
df -h
526-
527-
# Linux AppImage
528-
- name: Install dependencies for Linux AppImage Upload
529-
if: endsWith(matrix.artifact_name, '-appimage')
530-
shell: bash
531-
run: |
532-
sudo apt-get update
533-
sudo apt-get install -y p7zip-full
534-
535-
- name: Split AppImage artifact
536-
if: endsWith(matrix.artifact_name, '-appimage')
537-
shell: bash
538-
run: |
539-
cd artifact/
540-
541-
for appImageFile in *.AppImage; do
542-
echo "Splitting ${appImageFile}"
543-
544-
# compressed to MyArtifact.AppImage.7z.001, MyArtifact.AppImage.7z.002, ...
545-
7z -v1g a "${{ matrix.appimage_7z_name }}.7z" "${appImageFile}"
546-
547-
# Output splitted archive name<TAB>size<TAB>hash list to myartifact.7z.txt
548-
ls "${{ matrix.appimage_7z_name }}.7z".* > archives_name.txt
549-
stat --printf="%s\n" "${{ matrix.appimage_7z_name }}.7z".* > archives_size.txt
550-
md5sum "${{ matrix.appimage_7z_name }}.7z".* | awk '{print $1}' | tr a-z A-Z > archives_hash.txt
551-
552-
paste -d '\t' archives_name.txt archives_size.txt archives_hash.txt > archives.txt
553-
554-
mv archives.txt "${{ matrix.artifact_name }}.7z.txt"
555-
done
556-
557-
- name: Show disk space (debug info)
558-
if: endsWith(matrix.artifact_name, '-appimage')
559-
shell: bash
560-
run: |
561-
df -h
562-
563-
- name: Upload Linux AppImage Release artifact
564-
if: endsWith(matrix.artifact_name, '-appimage')
565-
uses: actions/upload-artifact@v3
566-
with:
567-
name: ${{ matrix.artifact_name }}-release
568-
path: |
569-
artifact/*.7z.*
570-
571-
- name: Upload Linux AppImage splitted archives to Release assets
572-
if: endsWith(matrix.artifact_name, '-appimage')
573-
uses: softprops/action-gh-release@v1
574-
with:
575-
prerelease: ${{ github.event.inputs.prerelease }}
576-
tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }}
577544
files: |-
578-
artifact/*.7z.*
579-
target_commitish: ${{ github.sha }}
580-
581-
# Windows NSIS Web
582-
- name: Upload Windows nsis-web archives to Release assets
583-
if: endsWith(matrix.artifact_name, '-nsis-web')
584-
uses: softprops/action-gh-release@v1
585-
with:
545+
nsis-web-artifact/*.7z.*
546+
nsis-web-artifact/*.exe
547+
upload_release: ${{ (github.event.release.tag_name || github.event.inputs.version) != '' }}
548+
upload_artifact: ${{ github.event.inputs.upload_artifact }}
586549
prerelease: ${{ github.event.inputs.prerelease }}
587550
tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }}
588-
files: |-
589-
artifact/*.7z.*
590-
artifact/*.exe
591-
target_commitish: ${{ github.sha }}
592-
593-
# macOS dmg
594-
- name: Upload macOS dmg to Release assets
595-
if: endsWith(matrix.artifact_name, '-dmg')
596-
uses: softprops/action-gh-release@v1
597-
with:
598-
prerelease: ${{ github.event.inputs.prerelease }}
599-
tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }}
600-
files: |-
601-
artifact/*.dmg
602-
target_commitish: ${{ github.sha }}
603-
604-
# targz
605-
- name: Upload targz to Release assets
606-
if: endsWith(matrix.artifact_name, '-targz')
607-
uses: softprops/action-gh-release@v1
608-
with:
609-
prerelease: ${{ github.event.inputs.prerelease }}
610-
tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }}
611-
files: |-
612-
artifact/*.tar.gz
613-
target_commitish: ${{ github.sha }}
614-
615-
# zip
616-
- name: Upload zip to Release assets
617-
if: endsWith(matrix.artifact_name, '-zip')
618-
uses: softprops/action-gh-release@v1
619-
with:
620-
prerelease: ${{ github.event.inputs.prerelease }}
621-
tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }}
622-
files: |-
623-
artifact/*.zip
624551
target_commitish: ${{ github.sha }}
552+
artifact_name: ${{ matrix.installer_artifact_name }}

.github/workflows/typos.yml

+2
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ jobs:
1616

1717
- name: typos-action
1818
uses: crate-ci/[email protected]
19+
with:
20+
files: ". .github"

_typos.toml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
[default.extend-words]
77
ba = "ba" # 7zコマンドの-baオプション
8+
commitish = "commitish" # softprops/action-gh-releaseのオプションの1つ
89

910
[files]
1011
extend-exclude = ["package-lock.json", "src/store/project.ts", "*.svg"]

0 commit comments

Comments
 (0)