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

このリポジトリで製品ビルドを可能にする #527

Merged
merged 16 commits into from
Jun 20, 2023
Merged
82 changes: 69 additions & 13 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
name: build and deploy workflow

# 製品版もビルドできる。製品版ビルド時の違いは以下の3点
# 1. production環境を使う
# 2. 製品版リポジトリのコードをmergeする
# 3. RESOURCEリポジトリからモデルをダウンロードして置き換える

on:
workflow_dispatch:
inputs:
Expand All @@ -9,6 +15,12 @@ on:
description: "コード署名する"
type: boolean
required: false
default: false
is_production:
description: "製品版をビルドする"
type: boolean
required: false
default: false
Comment on lines +18 to +23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OSS版バイナリに署名することはないので二つのboolパラメータを統合して三値にした方がいいのではないかと思ったのですが、code_signingはもうcodesign.bashを実行するか否かに使われていないので、OSS版バイナリに署名しても事故ではないのならcode_signingis_productionは排反でもいいと思います。

Copy link
Member Author

@Hiroshiba Hiroshiba Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ちょっと僕が勘違いしてるかもなのですが、code_signing引数でcodesign.bashを実行するかどうか制御してます。
https://github.com/Hiroshiba/voicevox_core/blob/45a9682b8d59fc99a634b2f27af516f7ba885d92/.github/workflows/build_and_deploy.yml#L239

production environmentを使うかどうかはproduction引数で制御してます。
production environmentを使うけど、コード署名はしない(実験版リリース)というケースを想定してます。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

気になったのはis_production && !code_signingのケースでした。ダミー音声版を署名したい場合があるのかなと思った次第です。ただcodesign.bash自体がActions上で動くかどうかを確かめたいというケースはありそうですね...

is_production code_signing
false 製品版を署名 (リリース) ダミー音声版をビルドするだけ (普段のCI)
true 製品版を無署名 (お試しビルド) ダミー音声版をビルドだけして、それに署名 (?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

署名するテストをしたいときは、今まで通りenvironmentを使わずにsecretsを設定すれば可能です。
(environmentはsecretsのサブセットを持っているだけ)

Copy link
Member

@qryxip qryxip Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なるほどこの状態でもできるんですね。

(↑の表のis_production、上下逆でした... あとis_production && !code_signingじゃなくて!is_production && code_signing...)

release:
types:
- published
Expand All @@ -18,15 +30,14 @@ on:
- "*"
- "**/*"
env:
VOICEVOX_RESOURCE_VERSION: "0.15.0-preview.1"
VOICEVOX_FAT_RESOURCE_VERSION: "0.15.0-preview.0"
# releaseタグ名か、workflow_dispatchでのバージョン名か、'0.0.0'が入る
VERSION: ${{ github.event.release.tag_name || github.event.inputs.version || '0.0.0' }}

# Raw character weights are not public.
# Skip uploading to GitHub Release on public repo.
SKIP_UPLOADING_RELEASE_ASSET: ${{ secrets.SKIP_UPLOADING_RELEASE_ASSET || '1' }}
PRODUCTION_REPOSITORY_TAG: "0.15.0-preview.0" # 製品版のタグ名
jobs:
build_and_deploy:
environment: ${{ github.event.inputs.code_signing == 'true' && 'code_signing' || '' }} # コード署名用のenvironment
environment: ${{ github.event.inputs.is_production == 'true' && 'production' || '' }} # 製品版のenvironment
strategy:
matrix:
include:
Expand Down Expand Up @@ -111,7 +122,22 @@ jobs:
use_cuda: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3 # 製品版ではない場合
if: ${{ github.event.inputs.is_production != 'true' }}
- uses: actions/checkout@v3 # 製品版の場合
if: ${{ github.event.inputs.is_production == 'true' }}
with:
fetch-depth: 0 # 全履歴取得
token: ${{ secrets.PRODUCTION_GITHUB_TOKEN }}
- name: Merge production branch
if: github.event.inputs.is_production == 'true'
shell: bash
run: |
(
git remote add private ${{ secrets.PRODUCTION_REPOSITORY_URL }}
git fetch private refs/tags/${{ env.PRODUCTION_REPOSITORY_TAG }}
git -c user.name=dummy -c [email protected] merge FETCH_HEAD
) > /dev/null 2>&1
- name: Set up Python 3.8
if: matrix.whl_local_version
uses: actions/setup-python@v4
Expand All @@ -138,6 +164,26 @@ jobs:
run: |
echo "$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin" >> "$GITHUB_PATH"
echo "AR_${{ matrix.target }}=llvm-ar" >> "$GITHUB_ENV"
- name: Checkout VOICEVOX RESOURCE
if: github.event.inputs.is_production == 'true'
uses: actions/checkout@v3
with:
repository: VOICEVOX/voicevox_resource
ref: ${{ env.VOICEVOX_RESOURCE_VERSION }}
path: download/resource
- name: Checkout VOICEVOX FAT RESOURCE
if: github.event.inputs.is_production == 'true'
uses: actions/checkout@v3
with:
repository: VOICEVOX/voicevox_fat_resource
ref: ${{ env.VOICEVOX_FAT_RESOURCE_VERSION }}
path: download/fat_resource
- name: Raplace resource
if: github.event.inputs.is_production == 'true'
shell: bash
run: |
mv -f download/resource/core/README.md ./README.md
rm -r ./model; mv download/fat_resource/core/model ./model
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: Install cargo-edit
Expand All @@ -149,7 +195,13 @@ jobs:
cargo set-version "$VERSION" --exclude voicevox_core_python_api --exclude download --exclude xtask
if ${{ !!matrix.whl_local_version }}; then cargo set-version "$VERSION+"${{ matrix.whl_local_version }} -p voicevox_core_python_api; fi
- name: build voicevox_core_c_api
run: cargo build -p voicevox_core_c_api -vv --features ${{ matrix.features }}, --target ${{ matrix.target }} --release
shell: bash
run: |
if [[ "${{ github.event.inputs.is_production }}" != "true" ]]; then
cargo build -p voicevox_core_c_api -vv --features ${{ matrix.features }}, --target ${{ matrix.target }} --release
else
cargo build -p voicevox_core_c_api -vv --features ${{ matrix.features }}, --target ${{ matrix.target }} --release > /dev/null 2>&1
fi
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
env:
RUSTFLAGS: -C panic=abort
ORT_USE_CUDA: ${{ matrix.use_cuda }}
Expand All @@ -159,7 +211,11 @@ jobs:
shell: bash
run: |
pip install -r ./crates/voicevox_core_python_api/requirements.txt
maturin build --manifest-path ./crates/voicevox_core_python_api/Cargo.toml --features ${{ matrix.features }}, --target ${{ matrix.target }} --release
if [[ "${{ github.event.inputs.is_production }}" != "true" ]]; then
maturin build --manifest-path ./crates/voicevox_core_python_api/Cargo.toml --features ${{ matrix.features }}, --target ${{ matrix.target }} --release
else
maturin build --manifest-path ./crates/voicevox_core_python_api/Cargo.toml --features ${{ matrix.features }}, --target ${{ matrix.target }} --release > /dev/null 2>&1
fi
echo "whl=$(find ./target/wheels -type f)" >> "$GITHUB_OUTPUT"
env:
ORT_USE_CUDA: ${{ matrix.use_cuda }}
Expand Down Expand Up @@ -188,7 +244,7 @@ jobs:
CERT_BASE64: ${{ secrets.CERT_BASE64 }}
CERT_PASSWORD: ${{ secrets.CERT_PASSWORD }}
- name: Upload artifact to build XCFramework
if: contains(matrix.target, 'ios')
if: contains(matrix.target, 'ios')
uses: actions/upload-artifact@v2
with:
name: voicevox_core-${{ matrix.target }}
Expand All @@ -208,7 +264,7 @@ jobs:
${{ env.ASSET_NAME }}.zip
target_commitish: ${{ github.sha }}
- name: Upload Python whl to Release
if: env.VERSION != '0.0.0' && env.SKIP_UPLOADING_RELEASE_ASSET == '0' && matrix.whl_local_version
if: env.VERSION != '0.0.0' && matrix.whl_local_version
uses: softprops/action-gh-release@v1
with:
prerelease: true
Expand Down Expand Up @@ -269,7 +325,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Upload to Release
if: env.VERSION != '0.0.0' && env.SKIP_UPLOADING_RELEASE_ASSET == '0'
if: env.VERSION != '0.0.0'
uses: softprops/action-gh-release@v1
with:
prerelease: true
Expand All @@ -278,7 +334,7 @@ jobs:
scripts/downloads/*
target_commitish: ${{ github.sha }}
deploy_precompiled_downloader:
environment: ${{ github.event.inputs.code_signing == 'true' && 'code_signing' || '' }} # コード署名用のenvironment
environment: ${{ github.event.inputs.is_production == 'true' && 'code_signing' || '' }} # コード署名用のenvironment
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
strategy:
matrix:
include:
Expand Down Expand Up @@ -329,7 +385,7 @@ jobs:
CERT_BASE64: ${{ secrets.CERT_BASE64 }}
CERT_PASSWORD: ${{ secrets.CERT_PASSWORD }}
- name: Upload to Release
if: env.VERSION != '0.0.0' && env.SKIP_UPLOADING_RELEASE_ASSET == '0'
if: env.VERSION != '0.0.0'
uses: softprops/action-gh-release@v1
with:
prerelease: true
Expand Down