Skip to content

Build

Build #108

Workflow file for this run

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: |
bash build/codesign_setup.bash
THUMBPRINT="$(head -n 1 $THUMBPRINT_PATH)"
SIGNTOOL_PATH="$(head -n 1 $SIGNTOOL_PATH_PATH)"
echo "::add-mask::$THUMBPRINT"
echo "WIN_CERTIFICATE_SHA1=$THUMBPRINT" >> $GITHUB_ENV
echo 'WIN_SIGNING_HASH_ALGORITHMS=["sha256"]' >> $GITHUB_ENV
echo "SIGNTOOL_PATH=$SIGNTOOL_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}
SIGNTOOL_DIR=$(dirname "$SIGNTOOL_PATH")
ln -s "$SIGNTOOL_DIR" "$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: |
bash build/codesign_setup.bash
THUMBPRINT="$(head -n 1 $THUMBPRINT_PATH)"
SIGNTOOL_PATH="$(head -n 1 $SIGNTOOL_PATH_PATH)"
echo "::add-mask::$THUMBPRINT"
echo "WIN_CERTIFICATE_SHA1=$THUMBPRINT" >> $GITHUB_ENV
echo 'WIN_SIGNING_HASH_ALGORITHMS=["sha256"]' >> $GITHUB_ENV
echo "SIGNTOOL_PATH=$SIGNTOOL_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}
SIGNTOOL_DIR=$(dirname "$SIGNTOOL_PATH")
ln -s "$SIGNTOOL_DIR" "$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 }}