Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS用アプリケーションとdmgファイル、zipファイルの自動ビルド #570

Merged
merged 34 commits into from
Dec 12, 2021
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
052dfb9
add build steps for macOS to build-noengine-prepackage
PickledChair Dec 10, 2021
3b6cc08
run build.yml on every push (for test-build)
PickledChair Dec 10, 2021
b795b48
sedコマンドに与える正規表現を修正
PickledChair Dec 10, 2021
c32d1c4
大きいサイズのアイコンをmacOS向けに用意
PickledChair Dec 10, 2021
91d5439
fix artifact_path of macOS
PickledChair Dec 10, 2021
9cf6f1d
add build steps for macOS to build-engine-prepackage
PickledChair Dec 10, 2021
8ebb77f
fix app.asar path of macOS
PickledChair Dec 10, 2021
aaa9986
change each version of npm and electron-builder for macOS
PickledChair Dec 10, 2021
2c1349d
npmのダウングレードのタイミングを変更
PickledChair Dec 10, 2021
977df27
npmとelectron-builderのバージョン変更をコメントアウト
PickledChair Dec 10, 2021
d51cf79
clear cache for test
PickledChair Dec 11, 2021
eaa77e8
実行権限を付与するファイルを追加
PickledChair Dec 11, 2021
382bef7
make the distribution for macOS
PickledChair Dec 11, 2021
3250900
fix quote
PickledChair Dec 11, 2021
010707e
macos_executable_nameの設定し忘れを修正
PickledChair Dec 11, 2021
9e16b88
trivial change
PickledChair Dec 11, 2021
742342d
dmgの名前にバージョン番号を追加
PickledChair Dec 11, 2021
ce10c89
キャッシュの設定をもとに戻す
PickledChair Dec 11, 2021
3352769
build-engine-prepackageにおいてmacOS向けバイナリへの実行権限付与をしない
PickledChair Dec 11, 2021
f1d7c21
run build.yml on main push
PickledChair Dec 11, 2021
392ba2f
macOSにおいてBSD sedではなくGNU sedを使用
PickledChair Dec 11, 2021
decb994
vue.config.jsのmacOS向けの設定についてコメントを追加
PickledChair Dec 11, 2021
f2cc68e
trivial change
PickledChair Dec 11, 2021
2dd0c8a
Merge licenses.jsonのstepを全OSで共通化
PickledChair Dec 11, 2021
41100fd
run build.yml on every push (for test)
PickledChair Dec 11, 2021
971ed3e
add shell option setting for alias
PickledChair Dec 11, 2021
f55bfe4
aliasがうまく働かないのでsedのコマンド名の設定に変数を使う
PickledChair Dec 11, 2021
f5b858b
trivial change
PickledChair Dec 12, 2021
ddfee95
macOS向けにzipを作成
PickledChair Dec 12, 2021
95e0b9c
mac向けzipの名前を変更
PickledChair Dec 12, 2021
f93fd4e
macOS向けzipをReleasesのassetsにアップロード
PickledChair Dec 12, 2021
1c40489
fix comment
PickledChair Dec 12, 2021
be9d065
run build.yml on main push
PickledChair Dec 12, 2021
1b4fc08
fix comment
PickledChair Dec 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 126 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- linux-noengine-cpu-prepackage
- windows-noengine-prepackage
- windows-noengine-cpu-prepackage
- macos-noengine-cpu-prepackage
include:
# Linux NVIDIA GPU
- artifact_name: linux-noengine-prepackage
Expand Down Expand Up @@ -55,20 +56,50 @@ jobs:
package_name: voicevox-cpu
nsis_web_artifact_name: 'VOICEVOX-CPU Web Setup ${version}.${ext}'
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}'
os: macos-11

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master

# Rename executable file
- name: Replace package name
- name: Replace package name (for Windows and Ubuntu)
if: startsWith(matrix.os, 'windows-') || startsWith(matrix.os, 'ubuntu-')
shell: bash
run: |
# GPU: "name": "voicevox" => "name": "voicevox"
# CPU: "name": "voicevox" => "name": "voicevox-cpu"
sed -i 's/"name": "voicevox"/"name": "${{ matrix.package_name }}"/' package.json
# sed -i 's/productName: "VOICEVOX"/productName: "${{ matrix.product_name }}"/' vue.config.js

# Rename executable file
# NOTE: The sed command of macOS is BSD sed,
# so you cannot omit the backup extension after the -i option.
- name: Replace package name (for macOS)
if: startsWith(matrix.os, 'macos-')
shell: bash
run: |
# GPU: "name": "voicevox" => "name": "voicevox"
# CPU: "name": "voicevox" => "name": "voicevox-cpu"
sed -i '' 's/"name": "voicevox"/"name": "${{ matrix.package_name }}"/' package.json
# sed -i '' 's/productName: "VOICEVOX"/productName: "${{ matrix.product_name }}"/' vue.config.js

- name: Replace the extraFiles setting in vue.config.js for macOS
if: startsWith(matrix.os, 'macos-')
shell: bash
run: |
sed -i '' 's|from: "build/README.txt", to: "README.txt"|from: "build/README.txt", to: "MacOS/README.txt"|' vue.config.js
sed -i '' 's|from: ".env.production", to: ".env"|from: ".env.production", to: "MacOS/.env"|' vue.config.js
str_config=$(cat vue.config.js)
str_config_2=${str_config//$'\n'/\\\\n}
echo $str_config_2 | sed -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: Set output Node version
id: node-version
shell: bash
Expand Down Expand Up @@ -112,8 +143,8 @@ jobs:
run: |
df -h

- name: Overwrite .env.production for Linux
if: startsWith(matrix.os, 'ubuntu-')
- name: Overwrite .env.production for Linux and macOS
if: startsWith(matrix.os, 'ubuntu-') || startsWith(matrix.os, 'macos-')
shell: bash
run: |
echo "ENGINE_PATH=./run" > .env.production
Expand Down Expand Up @@ -186,6 +217,7 @@ jobs:
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 }}
run: npm run electron:build_pnever -- --dir

- name: Upload NoEngine Prepackage
Expand Down Expand Up @@ -215,6 +247,7 @@ jobs:
- linux-cpu-prepackage
- windows-nvidia-prepackage
- windows-cpu-prepackage
- macos-cpu-prepackage
include:
# Linux NVIDIA GPU
- artifact_name: linux-nvidia-prepackage
Expand All @@ -236,6 +269,11 @@ jobs:
- artifact_name: windows-cpu-prepackage
noengine_artifact_name: windows-noengine-cpu-prepackage
voicevox_engine_asset_name: windows-cpu
# macOS CPU
- artifact_name: macos-cpu-prepackage
noengine_artifact_name: macos-noengine-cpu-prepackage
macos_executable_name: VOICEVOX
voicevox_engine_asset_name: macos-x64

runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -323,6 +361,7 @@ jobs:
rm -rf voicevox_engine/download voicevox_engine/tmp

- name: Merge licenses.json (ENGINE, VOICEVOX)
if: startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'linux-')
shell: bash
run: |
# Unpack asar
Expand All @@ -336,12 +375,35 @@ jobs:
asar pack prepackage/resources/app prepackage/resources/app.asar
rm -rf prepackage/resources/app

- name: Merge licenses.json (ENGINE, VOICEVOX) (macOS)
if: startsWith(matrix.artifact_name, 'macos-')
shell: bash
run: |
# Unpack asar
asar extract prepackage/VOICEVOX.app/Contents/Resources/app.asar prepackage/VOICEVOX.app/Contents/Resources/app
rm prepackage/VOICEVOX.app/Contents/Resources/app.asar

mv voicevox_engine/voicevox_engine/licenses.json engine_licenses.json
npm run license:merge -- -o prepackage/VOICEVOX.app/Contents/Resources/app/licenses.json -i engine_licenses.json -i prepackage/VOICEVOX.app/Contents/Resources/app/licenses.json

# Repack asar
asar pack prepackage/VOICEVOX.app/Contents/Resources/app prepackage/VOICEVOX.app/Contents/Resources/app.asar
rm -rf prepackage/VOICEVOX.app/Contents/Resources/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: |
Expand Down Expand Up @@ -417,6 +479,7 @@ jobs:
- linux-cpu-appimage
- windows-nvidia-nsis-web
- windows-cpu-nsis-web
- macos-cpu-dmg
include:
# Linux NVIDIA GPU
- artifact_name: linux-nvidia-appimage
Expand Down Expand Up @@ -444,6 +507,13 @@ jobs:
package_name: voicevox-cpu
nsis_web_artifact_name: 'VOICEVOX-CPU Web Setup ${version}.${ext}'
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
os: macos-11

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -455,14 +525,27 @@ jobs:
# 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/GPU builds.
- name: Replace package name
- name: Replace package name (for Windows and Ubuntu)
if: endsWith(matrix.artifact_name, '-nsis-web') || endsWith(matrix.artifact_name, '-appimage')
shell: bash
run: |
# GPU: "name": "voicevox" => "name": "voicevox"
# CPU: "name": "voicevox" => "name": "voicevox-cpu"
sed -i 's/"name": "voicevox"/"name": "${{ matrix.package_name }}"/' package.json
# sed -i 's/productName: "VOICEVOX"/productName: "${{ matrix.product_name }}"/' vue.config.js

# Rename executable file
# NOTE: The sed command of macOS is BSD sed,
# so you cannot omit the backup extension after the -i option.
- name: Replace package name (for macOS)
if: endsWith(matrix.os, '-dmg')
shell: bash
run: |
# GPU: "name": "voicevox" => "name": "voicevox"
# CPU: "name": "voicevox" => "name": "voicevox-cpu"
sed -i '' 's/"name": "voicevox"/"name": "${{ matrix.package_name }}"/' package.json
# sed -i '' 's/productName: "VOICEVOX"/productName: "${{ matrix.product_name }}"/' vue.config.js

- name: Download and extract engine-prepackage artifact
uses: actions/download-artifact@v2
with:
Expand All @@ -476,6 +559,17 @@ jobs:
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"

- name: Show disk space (debug info)
shell: bash
run: |
Expand Down Expand Up @@ -526,13 +620,21 @@ jobs:

# 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: Show disk space (debug info)
shell: bash
run: |
Expand All @@ -546,6 +648,14 @@ jobs:
path: |
dist_electron/*.AppImage

- name: Upload macOS dmg artifact
if: endsWith(matrix.artifact_name, '-dmg')
uses: actions/upload-artifact@v2
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
Expand Down Expand Up @@ -586,13 +696,15 @@ jobs:
- linux-cpu-appimage
- windows-nvidia-nsis-web
- windows-cpu-nsis-web
- macos-cpu-dmg
include:
- artifact_name: linux-nvidia-appimage
appimage_7z_name: VOICEVOX.AppImage
- artifact_name: linux-cpu-appimage
appimage_7z_name: VOICEVOX-CPU.AppImage
- artifact_name: windows-nvidia-nsis-web
- artifact_name: windows-cpu-nsis-web
- artifact_name: macos-cpu-dmg

runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -680,3 +792,13 @@ jobs:
tag: ${{ github.ref }} # == github.event.release.tag_name
file_glob: true
file: artifact/*.exe

# macOS dmg
- name: Upload macOS dmg to Release assets
if: endsWith(matrix.artifact_name, '-dmg')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }} # == github.event.release.tag_name
file_glob: true
file: artifact/*.dmg
Binary file added public/icon-mac.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const LINUX_ARTIFACT_NAME = process.env.LINUX_ARTIFACT_NAME;
// ${packageName}
const LINUX_EXECUTABLE_NAME = process.env.LINUX_EXECUTABLE_NAME;

// ${productName}-${version}.${ext}
const MACOS_ARTIFACT_NAME = process.env.MACOS_ARTIFACT_NAME;

module.exports = {
configureWebpack: {
devtool: "source-map",
Expand Down Expand Up @@ -85,6 +88,18 @@ module.exports = {
},
],
},
mac: {
artifactName:
MACOS_ARTIFACT_NAME !== "" ? MACOS_ARTIFACT_NAME : undefined,
icon: "public/icon-mac.png",
category: "public.app-category.utilities",
target: [
{
target: "dmg",
arch: ["x64"],
},
],
},
},
},
},
Expand Down