Skip to content

Commit

Permalink
Releasesにアップロードされるzipの構造を変更 (VOICEVOX#117)
Browse files Browse the repository at this point in the history
* releasesにuploadするzipの構造を変更

* artifactsディレクトリ以下にcoreディレクトリがあれば一時的に名前変更してから戻す

* coreをartifactとしてアップロードしないように変更

* changed the artifact to include header and version files

* change the structure of the artifact

* define and use ZIP_NAME

* fix artifact path

* define ASSET_NAME instead of ZIP_NAME and add it into GITHUB_ENV

* move release steps into build job

* use Compress-Archive commandlet on Windows

* fix archiving method on linux and mac

* create archive file in root directory

* edit comment

* サンプルのREADMEに記載のzipファイル名を更新
  • Loading branch information
PickledChair authored and y-chan committed Jul 11, 2022
1 parent 26e25d3 commit 19c2cfa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 64 deletions.
90 changes: 27 additions & 63 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,91 +255,55 @@ jobs:
pip install -r requirements.txt
python setup.py test
- name: Organize artifact
- name: Set BUILD_IDENTIFIER env var
shell: bash
run: |
mkdir artifact
echo "BUILD_IDENTIFIER=${GITHUB_REF##*/}" >> $GITHUB_ENV
# remove files with duplicate names to create a flat release archive
rm -vf core/lib/core.h
- name: Set ASSET_NAME env var
shell: bash
run: |
echo "ASSET_NAME=voicevox_core-${{ matrix.artifact_name }}-${{ env.BUILD_IDENTIFIER }}" >> $GITHUB_ENV
- name: Organize artifact
shell: bash
run: |
mkdir -p "artifact/${{ env.ASSET_NAME }}"
# copy Windows DLL if exists
cp -v core/lib/core* artifact/ || true
# copy core.h (and Windows DLL if exists)
cp -v core/lib/core* "artifact/${{ env.ASSET_NAME }}" || true
# copy Linux/macOS shared library if exists
cp -v core/lib/libcore* artifact/ || true
cp -v core/lib/libcore* "artifact/${{ env.ASSET_NAME }}" || true
echo "${{ env.BUILD_IDENTIFIER }}" > "artifact/${{ env.ASSET_NAME }}/VERSION"
# Upload
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.artifact_name }}-cpp-shared
path: artifact/*
path: artifact/${{ env.ASSET_NAME }}/*
retention-days: 7

# Create core.zip
upload-to-release-cpp-shared:
if: github.event.release.tag_name != ''
needs: [build-cpp-shared]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set BUILD_IDENTIFIER env var
- name: Archive artifact
if: github.event.release.tag_name != '' && !startsWith(matrix.os, 'windows-')
shell: bash
run: |
echo "BUILD_IDENTIFIER=${GITHUB_REF##*/}" >> $GITHUB_ENV
cd artifact
zip -r "../${{ env.ASSET_NAME }}.zip" "${{ env.ASSET_NAME }}"
- name: Install dependencies
- name: Archive artifact (Windows)
if: github.event.release.tag_name != '' && startsWith(matrix.os, 'windows-')
run: |
sudo apt-get update
sudo apt-get install -y \
zip
- name: Download and extract artifact
uses: actions/download-artifact@v2
with:
path: artifacts/

- name: Rearchive artifacts
run: |
mkdir release
readarray -t MAPPINGS <<EOF
windows-x64-cuda
windows-x64-directml
windows-x64-cpu
windows-x86-cpu
windows-arm64-cpu
windows-arm-cpu
osx-universal2-cpu
linux-x64-gpu
linux-x64-cpu
linux-armhf-cpu
linux-arm64-cpu
EOF
for KND in "${MAPPINGS[@]}"; do
cp core/src/core.h "artifacts/${KND}-cpp-shared"
echo "${{ env.BUILD_IDENTIFIER }}" > "artifacts/${KND}-cpp-shared/VERSION"
cd "artifacts/${KND}-cpp-shared"
zip -r "../../release/${KND}-cpp-shared.zip" *
cd -
done
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: core
path: artifacts/*
powershell Compress-Archive -Path "artifact/${{ env.ASSET_NAME }}" -DestinationPath "${{ env.ASSET_NAME }}.zip"
- name: Upload to Release
if: env.SKIP_UPLOADING_RELEASE_ASSET == '0'
if: github.event.release.tag_name != '' && env.SKIP_UPLOADING_RELEASE_ASSET == '0'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }} # ==> github.event.release.tag_name
file: release/*.zip
file_glob: true
file: ${{ env.ASSET_NAME }}.zip

build-win-cpp-example:
runs-on: windows-latest
Expand Down
2 changes: 1 addition & 1 deletion example/cpp/windows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Visual Studio Installerを使用しインストールしてください。
ビルドして実行するには、「core.dll」「core.lib」「Open JTalk辞書フォルダ」が必要です。
以下はDebug x64でビルドする場合です。他の構成・プラットフォーム向けにビルドする場合は、適宜読み替えてください。

Releasesから「windows-x64-cpu-cpp-shared.zip」をダウンロードします。
Releasesから「voicevox_core-windows-x64-cpu-{バージョン名}.zip」をダウンロードします。
zipファイルを展開し、展開されたフォルダに含まれているdllファイルを「core.dll」にリネームします。
出力フォルダを作成するために、一度ビルドします。「windows_example.sln」をVisual Studioで開き、メニューの「ビルド」→「ソリューションのビルド」を押します。
この段階では、ビルドは失敗します。「bin」フォルダと「lib」フォルダが生成されていればOKです。
Expand Down

0 comments on commit 19c2cfa

Please sign in to comment.