Skip to content

Build

Build #28

Workflow file for this run

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:
AIVISSPEECH_ENGINE_VERSION: "1.1.0-dev"
AIVISSPEECH_EDITOR_VERSION:
|- # releaseタグ名か、workflow_dispatchでのバージョン名か、999.999.999-developが入る
${{ github.event.release.tag_name || github.event.inputs.version || '999.999.999-develop' }}
defaults:
run:
shell: bash
jobs:
build-and-upload:
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
# GNUコマンド
sed: ${{ startsWith(matrix.os, 'macos-') && 'gsed' || 'sed' }}
strategy:
fail-fast: false
matrix:
artifact_name:
- windows-x64-prepackage
- macos-x64-prepackage
- macos-arm64-prepackage
# - linux-x64-prepackage
include:
# Windows x64
- artifact_name: windows-x64-prepackage
artifact_path: dist_electron/win-unpacked
aivisspeech_engine_asset_name: Windows-x64
package_name: AivisSpeech
compressed_artifact_name: AivisSpeech-Windows-x64
app_asar_dir: prepackage/resources
installer_artifact_name: windows-x64-nsis-web
nsis_web_artifact_name: "AivisSpeech-Windows-x64-${version}.${ext}"
os: windows-2022
# macOS x64 (Intel Mac)
- artifact_name: macos-x64-prepackage
artifact_path: dist_electron/mac
aivisspeech_engine_asset_name: macOS-x64
package_name: AivisSpeech
compressed_artifact_name: AivisSpeech-macOS-x64
app_asar_dir: prepackage/AivisSpeech.app/Contents/Resources
installer_artifact_name: macos-x64-dmg
macos_artifact_name: "AivisSpeech-macOS-x64-${version}.${ext}"
os: macos-13
# macOS arm64 (Apple Silicon Mac)
- artifact_name: macos-arm64-prepackage
artifact_path: dist_electron/mac-arm64
aivisspeech_engine_asset_name: macOS-arm64
package_name: AivisSpeech
compressed_artifact_name: AivisSpeech-macOS-arm64
app_asar_dir: prepackage/AivisSpeech.app/Contents/Resources
installer_artifact_name: macos-arm64-dmg
macos_artifact_name: "AivisSpeech-macOS-arm64-${version}.${ext}"
os: macos-14
# Linux x64
# - artifact_name: linux-x64-prepackage
# artifact_path: dist_electron/linux-unpacked
# aivisspeech_engine_asset_name: Linux-x64
# package_name: AivisSpeech
# compressed_artifact_name: AivisSpeech-Linux-x64
# app_asar_dir: prepackage/resources
# installer_artifact_name: linux-x64-appimage
# linux_artifact_name: "AivisSpeech.${ext}"
# linux_executable_name: AivisSpeech
# linux_appimage_7z_name: AivisSpeech.AppImage
# os: ubuntu-20.04
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
# 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-')
run: |
brew install gnu-sed
# Rename executable file
# 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
run: |
$sed -i 's/"name": "AivisSpeech"/"name": "${{ matrix.package_name }}"/' package.json
$sed -i 's/"version": "999.999.999"/"version": "${{ env.AIVISSPEECH_EDITOR_VERSION }}"/' package.json
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ".node-version"
cache: "npm"
- name: Cache Electron
uses: actions/cache@v4
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@v4
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
run: npm ci
- name: Overwrite .env.production for Linux
if: startsWith(matrix.os, 'ubuntu-')
run: |
$sed -i 's|run.exe|./run|g' .env.production
- name: Overwrite .env.production for macOS
if: startsWith(matrix.os, 'macos-')
run: |
$sed -i 's|AivisSpeech-Engine/run.exe|../Resources/AivisSpeech-Engine/run|g' .env.production
- name: Generate public/licenses.json
run: npm run license:generate
- name: Define Code Signing Envs
if: startsWith(matrix.os, 'windows-') && github.event.inputs.code_signing == 'true'
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
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
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 -- --dir
- name: Reset Code Signing Envs
if: startsWith(matrix.os, 'windows-') && github.event.inputs.code_signing == 'true'
run: |
bash build/codesign_cleanup.bash
echo 'WIN_CERTIFICATE_SHA1=' >> $GITHUB_ENV
echo 'WIN_SIGNING_HASH_ALGORITHMS=' >> $GITHUB_ENV
echo 'SIGNTOOL_PATH=' >> $GITHUB_ENV
env:
THUMBPRINT_PATH: /tmp/esignercka_thumbprint.txt
- name: Rename NoEngine Prepackage
run: |
mv ${{ matrix.artifact_path }} ./prepackage
# Download AivisSpeech Engine
- name: Download AivisSpeech Engine
id: download-engine
uses: ./.github/actions/download-engine
with:
version: ${{ env.AIVISSPEECH_ENGINE_VERSION }}
dest: ${{ github.workspace }}/AivisSpeech-Engine
target: ${{ matrix.aivisspeech_engine_asset_name }}
token: ${{ secrets.ENGINE_DOWNLOADER_TOKEN }}
- name: Merge AivisSpeech Engine into prepackage/
if: startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'linux-')
run: |
mv AivisSpeech-Engine/ prepackage/AivisSpeech-Engine/
- name: Merge AivisSpeech Engine into prepackage/AivisSpeech.app/Contents/Resources/
if: startsWith(matrix.artifact_name, 'macos-')
run: |
mv AivisSpeech-Engine/ prepackage/AivisSpeech.app/Contents/Resources/AivisSpeech-Engine/
- name: Recover file permissions
if: startsWith(matrix.artifact_name, 'linux-') # linux
run: |
chmod +x "prepackage/${{ matrix.linux_executable_name }}"
chmod +x "prepackage/AivisSpeech-Engine/run"
- name: Recover file permissions for macOS build
if: startsWith(matrix.artifact_name, 'macos-') # macOS
run: |
chmod +x "prepackage/AivisSpeech.app/Contents/Resources/AivisSpeech-Engine/run"
chmod +x "prepackage/AivisSpeech.app/Contents/Frameworks/AivisSpeech Helper (GPU).app/Contents/MacOS/AivisSpeech Helper (GPU)"
chmod +x "prepackage/AivisSpeech.app/Contents/Frameworks/AivisSpeech Helper (Plugin).app/Contents/MacOS/AivisSpeech Helper (Plugin)"
chmod +x "prepackage/AivisSpeech.app/Contents/Frameworks/AivisSpeech Helper (Renderer).app/Contents/MacOS/AivisSpeech Helper (Renderer)"
chmod +x "prepackage/AivisSpeech.app/Contents/Frameworks/AivisSpeech Helper.app/Contents/MacOS/AivisSpeech Helper"
# NOTE: actions/upload-artifact@v4 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 AivisSpeech.app
if: startsWith(matrix.artifact_name, 'macos-')
run: mkdir -p prepackage/AivisSpeech.app/Contents/Resources/ja.lproj prepackage/AivisSpeech.app/Contents/Resources/en.lproj
- name: Ad hoc code signing
if: endsWith(matrix.installer_artifact_name, '-dmg') # macOS
run: codesign --force --deep -s - prepackage/AivisSpeech.app
- name: Create Linux tar.gz (without nvidia)
if: startsWith(matrix.artifact_name, 'linux-') && !contains(matrix.artifact_name, 'nvidia')
run: |
name="${{ matrix.compressed_artifact_name }}-${{ env.AIVISSPEECH_EDITOR_VERSION }}"
7z a -ttar $name.tar prepackage/
7z rn $name.tar prepackage/ AivisSpeech/
7z a -tgzip $name.tar.gz $name.tar
rm $name.tar
- name: Upload Linux tar.gz (without nvidia) to Artifacts
if: startsWith(matrix.artifact_name, 'linux-') && !contains(matrix.artifact_name, 'nvidia') && github.event.inputs.upload_artifact == 'true'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}-targz
path: |-
${{ matrix.compressed_artifact_name }}-${{ env.AIVISSPEECH_EDITOR_VERSION }}.tar.gz
- name: Upload Linux tar.gz (without nvidia) to Release Assets
if: startsWith(matrix.artifact_name, 'linux-') && !contains(matrix.artifact_name, 'nvidia') && (github.event.release.tag_name || github.event.inputs.version) != ''
uses: softprops/action-gh-release@v2
with:
prerelease: ${{ github.event.inputs.prerelease }}
tag_name: ${{ env.AIVISSPEECH_EDITOR_VERSION }}
files: |-
${{ matrix.compressed_artifact_name }}-${{ env.AIVISSPEECH_EDITOR_VERSION }}.tar.gz
target_commitish: ${{ github.sha }}
- name: Delete Linux tar.gz (without nvidia)
if: startsWith(matrix.artifact_name, 'linux-') && !contains(matrix.artifact_name, 'nvidia')
run: |
rm ${{ matrix.compressed_artifact_name }}-${{ env.AIVISSPEECH_EDITOR_VERSION }}.tar.gz
- name: Create Windows & Mac zip (without nvidia)
if: (startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'macos-')) && !contains(matrix.artifact_name, 'nvidia')
run: |
name="${{ matrix.compressed_artifact_name }}-${{ env.AIVISSPEECH_EDITOR_VERSION }}"
7z a -tzip $name.zip prepackage/
7z rn $name.zip prepackage/ AivisSpeech/
- name: Upload Windows & Mac zip (without nvidia) to Artifacts
if: (startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'macos-')) && !contains(matrix.artifact_name, 'nvidia') && github.event.inputs.upload_artifact == 'true'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}-zip
path: |-
${{ matrix.compressed_artifact_name }}-${{ env.AIVISSPEECH_EDITOR_VERSION }}.zip
- name: Upload Windows & Mac zip (without nvidia) to Release Assets
if: (startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'macos-')) && !contains(matrix.artifact_name, 'nvidia') && (github.event.release.tag_name || github.event.inputs.version) != ''
uses: softprops/action-gh-release@v2
with:
prerelease: ${{ github.event.inputs.prerelease }}
tag_name: ${{ env.AIVISSPEECH_EDITOR_VERSION }}
files: |-
${{ matrix.compressed_artifact_name }}-${{ env.AIVISSPEECH_EDITOR_VERSION }}.zip
target_commitish: ${{ github.sha }}
- name: Delete Windows & Mac zip (without nvidia)
if: (startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'macos-')) && !contains(matrix.artifact_name, 'nvidia')
run: |
rm ${{ matrix.compressed_artifact_name }}-${{ env.AIVISSPEECH_EDITOR_VERSION }}.zip
- name: Define Code Signing Envs
if: startsWith(matrix.os, 'windows-') && github.event.inputs.code_signing == 'true'
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
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.installer_artifact_name, '-nsis-web') || endsWith(matrix.installer_artifact_name, '-appimage') # windows and linux
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 -- --prepackaged prepackage/
- name: Build Electron (for macOS)
if: endsWith(matrix.installer_artifact_name, '-dmg') # macOS
env:
MACOS_ARTIFACT_NAME: ${{ matrix.macos_artifact_name }}
run: |
npm run electron:build -- --prepackaged prepackage/AivisSpeech.app
- name: Reset Code Signing Envs
if: startsWith(matrix.os, 'windows-') && github.event.inputs.code_signing == 'true'
run: |
bash build/codesign_cleanup.bash
echo 'WIN_CERTIFICATE_SHA1=' >> $GITHUB_ENV
echo 'WIN_SIGNING_HASH_ALGORITHMS=' >> $GITHUB_ENV
echo 'SIGNTOOL_PATH=' >> $GITHUB_ENV
env:
THUMBPRINT_PATH: /tmp/esignercka_thumbprint.txt
- name: Create Linux AppImage split
if: endsWith(matrix.installer_artifact_name, '-appimage')
run: |
cd dist_electron/
for appImageFile in *.AppImage; do
echo "Splitting ${appImageFile}"
# compressed to MyArtifact.AppImage.7z.001, MyArtifact.AppImage.7z.002, ...
7z -v1g a "${{ matrix.linux_appimage_7z_name }}.7z" "${appImageFile}"
# Output split archive name<TAB>size<TAB>hash list to myartifact.7z.txt
ls "${{ matrix.linux_appimage_7z_name }}.7z".* > archives_name.txt
stat --printf="%s\n" "${{ matrix.linux_appimage_7z_name }}.7z".* > archives_size.txt
md5sum "${{ matrix.linux_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.installer_artifact_name }}.7z.txt"
done
- name: Upload Linux AppImage split to Artifacts
if: endsWith(matrix.installer_artifact_name, '-appimage') && github.event.inputs.upload_artifact == 'true'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.installer_artifact_name }}-release
path: |-
dist_electron/*.7z.*
- name: Upload Linux AppImage split to Release Assets
if: endsWith(matrix.installer_artifact_name, '-appimage') && (github.event.release.tag_name || github.event.inputs.version) != ''
uses: softprops/action-gh-release@v2
with:
prerelease: ${{ github.event.inputs.prerelease }}
tag_name: ${{ env.AIVISSPEECH_EDITOR_VERSION }}
files: |-
dist_electron/*.7z.*
target_commitish: ${{ github.sha }}
- name: Upload macOS dmg to Artifacts
if: endsWith(matrix.installer_artifact_name, '-dmg') && github.event.inputs.upload_artifact == 'true'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.installer_artifact_name }}-release
path: |-
dist_electron/*.dmg
- name: Upload macOS dmg to Release Assets
if: endsWith(matrix.installer_artifact_name, '-dmg') && (github.event.release.tag_name || github.event.inputs.version) != ''
uses: softprops/action-gh-release@v2
with:
prerelease: ${{ github.event.inputs.prerelease }}
tag_name: ${{ env.AIVISSPEECH_EDITOR_VERSION }}
files: |-
dist_electron/*.dmg
target_commitish: ${{ github.sha }}
- name: Upload Windows NSIS Web to Artifacts
if: endsWith(matrix.installer_artifact_name, '-nsis-web') && github.event.inputs.upload_artifact == 'true'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.installer_artifact_name }}-release
path: |-
dist_electron/nsis-web/out/*.7z.*
dist_electron/nsis-web/*.exe
- name: Upload Windows NSIS Web to Release Assets
if: endsWith(matrix.installer_artifact_name, '-nsis-web') && (github.event.release.tag_name || github.event.inputs.version) != ''
uses: softprops/action-gh-release@v2
with:
prerelease: ${{ github.event.inputs.prerelease }}
tag_name: ${{ env.AIVISSPEECH_EDITOR_VERSION }}
files: |-
dist_electron/nsis-web/out/*.7z.*
dist_electron/nsis-web/*.exe
target_commitish: ${{ github.sha }}