From 5bce552e976ecc0ab1c07a42d0fcf0a0d5cdabd3 Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Mon, 24 Apr 2023 02:47:15 +0900 Subject: [PATCH] =?UTF-8?q?Github=20Actions=E3=81=A7=E3=81=AE=E3=83=93?= =?UTF-8?q?=E3=83=AB=E3=83=89=E3=81=AEupload/download=E5=9B=9E=E6=95=B0?= =?UTF-8?q?=E3=82=92=E5=B0=91=E3=81=AA=E3=81=8F=E3=81=97=E3=81=A6=E3=83=93?= =?UTF-8?q?=E3=83=AB=E3=83=89=E6=99=82=E9=96=93=E3=82=92=E7=9F=AD=E3=81=8F?= =?UTF-8?q?=E3=81=99=E3=82=8B=20(#668)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 142 +++++++++++------------------------- 1 file changed, 44 insertions(+), 98 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6ace2eaf9..7a8a545aa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,10 @@ on: code_signing: description: "コード署名する" type: boolean + upload_artifact: + description: "デバッグ用に成果物をartifactにアップロードするか" + type: boolean + default: false env: PYTHON_VERSION: "3.11.3" @@ -40,7 +44,7 @@ jobs: : # release タグ名, または workflow_dispatch でのバージョン名, または 'latest' echo "version_or_latest=${{ github.event.release.tag_name || github.event.inputs.version || 'latest' }}" >> $GITHUB_OUTPUT - build-all: + build-and-upload: needs: [config] environment: ${{ github.event.inputs.code_signing == 'true' && 'code_signing' || '' }} # コード署名用のenvironment strategy: @@ -96,22 +100,20 @@ jobs: id: vars shell: bash run: | - echo "artifact_name=voicevox_engine-${{ matrix.target }}-${{ needs.config.outputs.version_or_latest }}-${{ github.sha }}" >> $GITHUB_OUTPUT + echo "package_name=voicevox_engine-${{ matrix.target }}-${{ needs.config.outputs.version }}" >> $GITHUB_OUTPUT - uses: actions/checkout@v3 - - name: Show disk space (debug info) - shell: bash - run: | - df -h - - # 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. + # NOTE: The default 'sed' and 'split' of macOS is BSD 'sed' and 'split'. + # There is a difference in specification between BSD 'sed' and 'split' and GNU 'sed' and 'split', + # so you need to install GNU 'sed' and 'split'. - name: Install GNU sed on macOS if: startsWith(matrix.os, 'macos-') shell: bash - run: brew install gnu-sed + run: | + brew install gnu-sed coreutils + echo "/usr/local/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH + echo "/usr/local/opt/coreutils/libexec/gnubin" >> $GITHUB_PATH # ONNX Runtime providersとCUDA周りをリンクするために使う - name: Install patchelf @@ -166,12 +168,6 @@ jobs: rm -f download/cuda/bin/libcudart.so.*.*.* fi - - name: Show disk space (debug info) - if: matrix.cuda_version != '' - shell: bash - run: | - df -h - # Download cuDNN - name: Export cuDNN url to calc hash if: matrix.cudnn_url != '' @@ -246,12 +242,6 @@ jobs: mv download/zlib/dll_${{ matrix.architecture }}/zlibwapi.dll download/zlib/zlibwapi.dll rm -r download/zlib/dll_${{ matrix.architecture }} - - name: Show disk space (debug info) - if: matrix.cudnn_url != '' - shell: bash - run: | - df -h - - name: Setup MSVC if: startsWith(matrix.os, 'windows-') uses: ilammy/msvc-dev-cmd@v1 @@ -363,11 +353,6 @@ jobs: tar xf "download/onnxruntime.tgz" -C "download/onnxruntime" --strip-components 1 rm download/onnxruntime.tgz - - name: Show disk space (debug info) - shell: bash - run: | - df -h - # Download VOICEVOX RESOURCE - name: Prepare VOICEVOX RESOURCE cache uses: actions/cache@v3 @@ -436,11 +421,6 @@ jobs: # FIXME: VOICEVOX (editor) cannot build without licenses.json cp engine_manifest_assets/dependency_licenses.json licenses.json - - name: Show disk space (debug info) - shell: bash - run: | - df -h - - name: Build run.py with PyInstaller shell: bash run: | @@ -450,30 +430,22 @@ jobs: mv -f engine_manifest.json.tmp engine_manifest.json # Replace version & specify dynamic libraries - if [[ ${{ matrix.os }} == macos-* ]]; then - gsed -i "s/__version__ = \"latest\"/__version__ = \"${{ needs.config.outputs.version_or_latest }}\"/" voicevox_engine/__init__.py + sed -i "s/__version__ = \"latest\"/__version__ = \"${{ needs.config.outputs.version_or_latest }}\"/" voicevox_engine/__init__.py + if [[ ${{ matrix.os }} == windows-* ]]; then + LIBCORE_PATH=download/core/voicevox_core.dll + LIBONNXRUNTIME_PATH=download/onnxruntime/lib/onnxruntime.dll + elif [[ ${{ matrix.os }} == macos-* ]]; then LIBCORE_PATH=download/core/libvoicevox_core.dylib LIBONNXRUNTIME_PATH=download/onnxruntime/lib/libonnxruntime.dylib else - sed -i "s/__version__ = \"latest\"/__version__ = \"${{ needs.config.outputs.version_or_latest }}\"/" voicevox_engine/__init__.py - if [[ ${{ matrix.os }} == windows-* ]]; then - LIBCORE_PATH=download/core/voicevox_core.dll - LIBONNXRUNTIME_PATH=download/onnxruntime/lib/onnxruntime.dll - else - LIBCORE_PATH=download/core/libvoicevox_core.so - LIBONNXRUNTIME_PATH=download/onnxruntime/lib/libonnxruntime.so - fi + LIBCORE_PATH=download/core/libvoicevox_core.so + LIBONNXRUNTIME_PATH=download/onnxruntime/lib/libonnxruntime.so fi LIBCORE_PATH="$LIBCORE_PATH" \ LIBONNXRUNTIME_PATH="$LIBONNXRUNTIME_PATH" \ pyinstaller --noconfirm run.spec - - name: Show disk space (debug info) - shell: bash - run: | - df -h - - name: Create artifact directory with symlink if: startsWith(matrix.os, 'windows-') shell: bash @@ -546,56 +518,16 @@ jobs: CERT_BASE64: ${{ secrets.CERT_BASE64 }} CERT_PASSWORD: ${{ secrets.CERT_PASSWORD }} - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.vars.outputs.artifact_name }} - path: dist/run/ - - upload-to-release: - if: needs.config.outputs.version != '' - needs: [config, build-all] - runs-on: ubuntu-latest - strategy: - matrix: - target: - - macos-x64 - - linux-cpu - - linux-nvidia - - windows-cpu - - windows-directml - - windows-nvidia - steps: - - name: declare variables - id: vars + - name: Rearchive and split artifact shell: bash run: | - echo "package_name=voicevox_engine-${{ matrix.target }}-${{ needs.config.outputs.version }}" >> $GITHUB_OUTPUT - : # this is exactly same as `steps.vars.outputs.artifact_name` in `build-all` job, - : # but since we cannot get the job outputs of matrix builds correctly, we need to redefine here. - echo "artifact_name=voicevox_engine-${{ matrix.target }}-${{ needs.config.outputs.version_or_latest }}-${{ github.sha }}" >> $GITHUB_OUTPUT - - - uses: actions/checkout@v3 - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y \ - p7zip-full + mv dist/run/ "${{ matrix.target }}/" - - name: Download and extract artifact - uses: actions/download-artifact@v3 - with: - name: ${{ steps.vars.outputs.artifact_name }} - path: ${{ matrix.target }}/ - - - name: Rearchive and split artifact - run: | # Compress to artifact.7z.001, artifact.7z.002, ... 7z -r -v1900m a "${{ steps.vars.outputs.package_name }}.7z" "${{ matrix.target }}/" # Compress to artifact.001.vvppp,artifact.002.vvppp, ... - (cd "${{ matrix.target }}" && zip -r - . > ../compressed.zip) + (cd "${{ matrix.target }}" && 7z -r a "../compressed.zip") split -b 1900M --numeric-suffixes=1 -a 3 --additional-suffix .vvppp ./compressed.zip ./${{ steps.vars.outputs.package_name }}. # Rename to artifact.vvpp if there are only artifact.001.vvppp @@ -609,21 +541,35 @@ jobs: ls ${{ steps.vars.outputs.package_name }}*.vvppp ${{ steps.vars.outputs.package_name }}.vvpp > archives_vvpp.txt || true mv archives_vvpp.txt "${{ steps.vars.outputs.package_name }}.vvpp.txt" - - name: Upload splitted archives to Release assets - uses: softprops/action-gh-release@v1 + - name: Upload to artifact + if: github.event.inputs.upload_artifact + uses: actions/upload-artifact@v3 with: - prerelease: ${{ github.event.inputs.prerelease }} - tag_name: ${{ needs.config.outputs.version }} - files: |- + name: ${{ steps.vars.outputs.package_name }} + path: | ${{ steps.vars.outputs.package_name }}.7z.* ${{ steps.vars.outputs.package_name }}.vvpp ${{ steps.vars.outputs.package_name }}*.vvppp ${{ steps.vars.outputs.package_name }}.vvpp.txt - target_commitish: ${{ github.sha }} + + - name: Upload to Release assets + if: needs.config.outputs.version != '' + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + prerelease: ${{ github.event.inputs.prerelease }} + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ needs.config.outputs.version }} + artifacts: > + ${{ steps.vars.outputs.package_name }}.7z.*, + ${{ steps.vars.outputs.package_name }}.vvpp, + ${{ steps.vars.outputs.package_name }}*.vvppp, + ${{ steps.vars.outputs.package_name }}.vvpp.txt + commit: ${{ github.sha }} run-release-test-workflow: if: needs.config.outputs.version != '' - needs: [config, upload-to-release] + needs: [config, build-and-upload] uses: ./.github/workflows/release-test.yml with: version: ${{ needs.config.outputs.version }}