From 6c55ef3d360a84111597563a1dc707bc0c152b70 Mon Sep 17 00:00:00 2001 From: aoirint Date: Sat, 9 Oct 2021 16:59:42 +0900 Subject: [PATCH] =?UTF-8?q?CPU=E7=89=88=E8=87=AA=E5=8B=95=E3=83=93?= =?UTF-8?q?=E3=83=AB=E3=83=89=E3=82=92=E6=9C=89=E5=8A=B9=E5=8C=96=20(#306)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * replace package name step * enable cpu matrix for upload to release job * fix comment * fix sed * use package name to split 7z * hyphen * replace product name * rename prepackage name * permission filename * fix space * hyphen * exe name * fix var ref * fix var ref * comment * fix chmod target * swap matrix order * comment * comment * rename AppImage: VOICEVOX.AppImage for GPU/CPU * rename tar.gz: {voicevox,voicevox-cpu}-version.tar.gz * rename AppImage.7z: {VOICEVOX,VOICEVOX-CPU}.AppImage.7z * rename tar.gz: {VOICEVOX,VOICEVOX-CPU}-version.tar.gz * linux installer: use file list in 7z to find AppImage filename * quote * fix tar.gz executable permission * quote * make nsis-web artifact flat --- .github/workflows/build.yml | 150 ++++++++++++++++++++++++++++-------- build/installer_linux.sh | 8 +- build/splitNsisArchive.js | 8 +- vue.config.js | 15 ++++ 4 files changed, 142 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7b7b2f16da..1911cded31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,19 +28,50 @@ jobs: matrix: artifact_name: - linux-noengine-prepackage + - linux-noengine-cpu-prepackage - windows-noengine-prepackage + - windows-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 os: ubuntu-18.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 + os: ubuntu-18.04 + # Windows NVIDIA GPU - artifact_name: windows-noengine-prepackage artifact_path: dist_electron/win-unpacked + package_name: voicevox + nsis_web_artifact_name: 'VOICEVOX Web Setup ${version}.${ext}' + 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}' os: windows-2019 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@master + # Rename executable file + - name: Replace package name + 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: Set output Node version id: node-version shell: bash @@ -103,6 +134,10 @@ jobs: # 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 }} run: npm run electron:build_pnever -- --dir - name: Upload NoEngine Prepackage @@ -128,25 +163,31 @@ jobs: # - ${{ env.VOICEVOX_ENGINE_VERSION }} os: [ubuntu-18.04] artifact_name: - - linux-cpu-prepackage - linux-nvidia-prepackage - - windows-cpu-prepackage + - linux-cpu-prepackage - windows-nvidia-prepackage + - windows-cpu-prepackage include: - - artifact_name: linux-cpu-prepackage - noengine_artifact_name: linux-noengine-prepackage - voicevox_engine_asset_name: linux-cpu - os: ubuntu-18.04 + # Linux NVIDIA GPU - artifact_name: linux-nvidia-prepackage noengine_artifact_name: linux-noengine-prepackage voicevox_engine_asset_name: linux-nvidia - os: ubuntu-18.04 - - artifact_name: windows-cpu-prepackage - noengine_artifact_name: windows-noengine-prepackage - voicevox_engine_asset_name: windows-cpu + linux_executable_name: voicevox + targz_name: VOICEVOX + # Linux CPU + - artifact_name: linux-cpu-prepackage + noengine_artifact_name: linux-noengine-cpu-prepackage + voicevox_engine_asset_name: linux-cpu + linux_executable_name: voicevox + targz_name: VOICEVOX-CPU + # Windows NVIDIA GPU - artifact_name: windows-nvidia-prepackage noengine_artifact_name: windows-noengine-prepackage voicevox_engine_asset_name: windows-nvidia + # Windows CPU + - artifact_name: windows-cpu-prepackage + noengine_artifact_name: windows-noengine-cpu-prepackage + voicevox_engine_asset_name: windows-cpu runs-on: ${{ matrix.os }} steps: @@ -269,8 +310,8 @@ jobs: if: startsWith(matrix.artifact_name, 'linux-') # linux shell: bash run: | - chmod +x prepackage/voicevox - chmod +x prepackage/run + chmod +x "prepackage/${{ matrix.linux_executable_name }}" + chmod +x "prepackage/run" - name: Set BUILD_IDENTIFIER env var if: startsWith(matrix.artifact_name, 'linux-') # linux @@ -296,7 +337,7 @@ jobs: shell: bash run: | mv prepackage VOICEVOX - tar cf voicevox-${{ env.BUILD_IDENTIFIER }}.tar.gz VOICEVOX/ + tar cf "${{ matrix.targz_name }}-${{ env.BUILD_IDENTIFIER }}.tar.gz" VOICEVOX/ - name: Show disk space (debug info) if: startsWith(matrix.artifact_name, 'linux-') # linux @@ -309,7 +350,7 @@ jobs: uses: actions/upload-artifact@v2 with: name: ${{ matrix.artifact_name }}-targz - path: voicevox-${{ env.BUILD_IDENTIFIER }}.tar.gz + path: "${{ matrix.targz_name }}-${{ env.BUILD_IDENTIFIER }}.tar.gz" build-distributable: @@ -324,28 +365,56 @@ jobs: fail-fast: false matrix: artifact_name: - # - linux-cpu-appimage - linux-nvidia-appimage - # - windows-cpu-nsis-web + - linux-cpu-appimage - windows-nvidia-nsis-web + - windows-cpu-nsis-web include: - # - artifact_name: linux-cpu-appimage - # engine_artifact_name: linux-cpu-prepackage - # os: ubuntu-18.04 + # 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 os: ubuntu-18.04 - # - artifact_name: windows-cpu-nsis-web - # engine_artifact_name: windows-cpu-prepackage - # os: windows-2019 + # 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 + os: ubuntu-18.04 + # Windows NVIDIA GPU - artifact_name: windows-nvidia-nsis-web engine_artifact_name: windows-nvidia-prepackage + package_name: voicevox + nsis_web_artifact_name: 'VOICEVOX Web Setup ${version}.${ext}' + 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}' os: windows-2019 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@master + # NOTE: If the CPU/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/GPU builds. + - name: Replace package name + 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: @@ -356,8 +425,8 @@ jobs: if: endsWith(matrix.artifact_name, '-appimage') # linux shell: bash run: | - chmod +x prepackage/voicevox - chmod +x prepackage/run + chmod +x "prepackage/${{ matrix.linux_executable_name }}" + chmod +x "prepackage/run" - name: Show disk space (debug info) shell: bash @@ -410,6 +479,10 @@ jobs: # NOTE: prepackage can be removed before splitting nsis-web archive - 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 }} run: npm run electron:build_pnever -- --prepackaged "prepackage/" - name: Show disk space (debug info) @@ -425,14 +498,21 @@ jobs: path: | dist_electron/*.AppImage + - 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/ + - name: Upload Windows NSIS Web artifact if: endsWith(matrix.artifact_name, '-nsis-web') uses: actions/upload-artifact@v2 with: name: ${{ matrix.artifact_name }} path: | - dist_electron/nsis-web/out/*.7z.* - dist_electron/nsis-web/*.exe + nsis-web-artifact/* upload-distributable-to-release: @@ -443,15 +523,17 @@ jobs: matrix: os: [ubuntu-18.04] artifact_name: - # - linux-cpu-appimage - linux-nvidia-appimage - # - windows-cpu-nsis-web + - linux-cpu-appimage - windows-nvidia-nsis-web + - windows-cpu-nsis-web include: - # - artifact_name: linux-cpu-appimage - artifact_name: linux-nvidia-appimage - # - artifact_name: windows-cpu-nsis-web + 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 runs-on: ${{ matrix.os }} steps: @@ -486,12 +568,12 @@ jobs: echo "Splitting ${appImageFile}" # compressed to MyArtifact.AppImage.7z.001, MyArtifact.AppImage.7z.002, ... - 7z -v1g a "${appImageFile}.7z" "${appImageFile}" + 7z -v1g a "${{ matrix.appimage_7z_name }}.7z" "${appImageFile}" # Output splitted archive namesizehash list to myartifact.7z.txt - ls ${appImageFile}.7z.* > archives_name.txt - stat --printf="%s\n" *.7z.* > archives_size.txt - md5sum *.7z.* | awk '{print $1}' | tr a-z A-Z > archives_hash.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 diff --git a/build/installer_linux.sh b/build/installer_linux.sh index 32432fc4d8..3aeff58bc8 100755 --- a/build/installer_linux.sh +++ b/build/installer_linux.sh @@ -229,12 +229,12 @@ rm -f "list.txt" # Extract desktop entry echo "Extacting desktop entry" -APPIMAGE=$(echo "${FIRST_ARCHIVE}" | sed 's/\(.*.AppImage\).*/\1/') +APPIMAGE=$(7z l -slt -ba "${FIRST_ARCHIVE}" | grep 'Path = ' | head -n1 | sed 's/Path = \(.*\)/\1/') chmod +x "${APPIMAGE}" -./${APPIMAGE} --appimage-extract '*.desktop' -./${APPIMAGE} --appimage-extract 'usr/share/icons/**' -./${APPIMAGE} --appimage-extract '*.png' # symbolic link to icon +"./${APPIMAGE}" --appimage-extract '*.desktop' +"./${APPIMAGE}" --appimage-extract 'usr/share/icons/**' +"./${APPIMAGE}" --appimage-extract '*.png' # symbolic link to icon # Install desktop entry echo "Installing desktop entry" diff --git a/build/splitNsisArchive.js b/build/splitNsisArchive.js index e7a82a201e..e86ea7d199 100644 --- a/build/splitNsisArchive.js +++ b/build/splitNsisArchive.js @@ -12,6 +12,12 @@ const createIni = (sizes, hashes) => { // target: electron-builder.Target exports.default = async function (target) { + const projectName = process.env.npm_package_name; + if (projectName === undefined) { + const ErrorMessage = "Project name is undefined."; + console.error(ErrorMessage); + throw ErrorMessage; + } const projectVersion = process.env.npm_package_version; if (projectVersion === undefined) { const ErrorMessage = "Project version is undefined."; @@ -19,7 +25,7 @@ exports.default = async function (target) { throw ErrorMessage; } const segmentSize = 1 * 1024 ** 3; // 1GB - const fileName = `voicevox-${projectVersion}-x64.nsis.7z`; // target file name + const fileName = `${projectName}-${projectVersion}-x64.nsis.7z`; // target file name const targetDirectory = target.outDir; // for nsis-web const outputDirectory = path.resolve(targetDirectory, "out"); const inputFile = path.resolve(targetDirectory, fileName); diff --git a/vue.config.js b/vue.config.js index 2796d9b530..70f3824cdc 100644 --- a/vue.config.js +++ b/vue.config.js @@ -6,6 +6,15 @@ const process = require("process"); const VOICEVOX_ENGINE_DIR = process.env.VOICEVOX_ENGINE_DIR ?? "../voicevox_engine/run.dist/"; +// ${productName} Web Setup ${version}.${ext} +const NSIS_WEB_ARTIFACT_NAME = process.env.NSIS_WEB_ARTIFACT_NAME; + +// ${productName}-${version}.${ext} +const LINUX_ARTIFACT_NAME = process.env.LINUX_ARTIFACT_NAME; + +// ${packageName} +const LINUX_EXECUTABLE_NAME = process.env.LINUX_EXECUTABLE_NAME; + module.exports = { configureWebpack: { devtool: "source-map", @@ -50,6 +59,8 @@ module.exports = { buildResources: "build", }, nsisWeb: { + artifactName: + NSIS_WEB_ARTIFACT_NAME !== "" ? NSIS_WEB_ARTIFACT_NAME : undefined, include: "build/installer.nsh", oneClick: false, allowToChangeInstallationDirectory: true, @@ -60,6 +71,10 @@ module.exports = { vPrefixedTagName: false, }, linux: { + artifactName: + LINUX_ARTIFACT_NAME !== "" ? LINUX_ARTIFACT_NAME : undefined, + executableName: + LINUX_EXECUTABLE_NAME !== "" ? LINUX_EXECUTABLE_NAME : undefined, icon: "public/icon.png", category: "AudioVideo", target: [