-
Notifications
You must be signed in to change notification settings - Fork 119
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
Java API:ビルドWorkflowを追加 #621
Changes from 33 commits
2979fb9
92555bd
fb00418
3bd192c
4186e79
55fc8ec
5baf16e
81283e7
5db3d3d
a50ecbd
f092e36
d3864d3
3e52b1e
0c3b789
04648de
c1b911e
8f65c16
7114365
654449f
bf27296
2aa021b
4594d6f
41c0988
eae0b85
15f23cf
78ea083
02c4be5
264235c
4db59ff
502d06e
f958e5d
af7d583
0c220de
0e88e3c
8c49cb5
53af4ff
d236789
83f4d63
bc7e246
f9743f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -257,6 +257,16 @@ jobs: | |
run: | | ||
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: cache target | ||
uses: actions/cache@v3 | ||
if: github.event.inputs.is_production != 'true' | ||
with: | ||
path: | | ||
~/.cargo | ||
target | ||
key: ${{ matrix.artifact_name }}-rust-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ matrix.artifact_name }}-rust- | ||
- name: build voicevox_core_c_api | ||
shell: bash | ||
run: | | ||
|
@@ -284,9 +294,21 @@ jobs: | |
else | ||
build > /dev/null 2>&1 | ||
fi | ||
echo "whl=$(find ./target/wheels -type f)" >> "$GITHUB_OUTPUT" | ||
ls -l ./target/wheels | ||
sevenc-nanashi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo "whl=$(find ./target/wheels -type f | head -1)" >> "$GITHUB_OUTPUT" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. これなんで必要になった感じでしょう 👀 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 分からないですね…なぜか落ちるようになりました There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. もしかしたらキャッシュが原因かなと思いました。やっぱキャッシュむずい!!!!!!!!!!!!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. あー!その可能性はありますね |
||
env: | ||
ORT_USE_CUDA: ${{ matrix.use_cuda }} | ||
- name: build voicevox_core_java_api | ||
if: "!endsWith(matrix.target, 'ios')" | ||
run: | | ||
function build() { | ||
cargo build -p voicevox_core_java_api -vv --features ${{ matrix.features }}, --target ${{ matrix.target }} --release | ||
} | ||
if ${{ github.event.inputs.is_production != 'true' }}; then | ||
build | ||
else | ||
build > /dev/null 2>&1 | ||
fi | ||
- name: Set ASSET_NAME env var | ||
run: echo "ASSET_NAME=voicevox_core-${{ matrix.artifact_name }}-${{ env.VERSION }}" >> "$GITHUB_ENV" | ||
- name: Organize artifact | ||
|
@@ -301,6 +323,11 @@ jobs: | |
cp -v README.md "artifact/${{ env.ASSET_NAME }}/README.txt" | ||
cp -vr model "artifact/${{ env.ASSET_NAME }}/" | ||
echo "${{ env.VERSION }}" > "artifact/${{ env.ASSET_NAME }}/VERSION" | ||
|
||
mkdir java_artifact | ||
cp -v target/${{ matrix.target }}/release/libvoicevox_core_java_api.so java_artifact/ || true | ||
cp -v target/${{ matrix.target }}/release/libvoicevox_core_java_api.dylib java_artifact/ || true | ||
cp -v target/${{ matrix.target }}/release/voicevox_core_java_api.dll java_artifact/ || true | ||
- name: Code signing (Windows) | ||
if: startsWith(matrix.os, 'windows') && github.event.inputs.code_signing == 'true' | ||
run: | | ||
|
@@ -310,7 +337,7 @@ jobs: | |
CERT_PASSWORD: ${{ secrets.CERT_PASSWORD }} | ||
- name: Upload artifact to build XCFramework | ||
if: contains(matrix.target, 'ios') | ||
uses: actions/upload-artifact@v2 | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: voicevox_core-${{ matrix.target }} | ||
path: artifact/${{ env.ASSET_NAME }} | ||
|
@@ -336,6 +363,12 @@ jobs: | |
files: |- | ||
${{ steps.build-voicevox-core-python-api.outputs.whl }} | ||
target_commitish: ${{ github.sha }} | ||
- name: Upload voicevox_core_java_api artifact | ||
if: env.VERSION != '0.0.0' && !contains(matrix.target, 'ios') | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: voicevox_core_java_api-${{ matrix.artifact_name }} | ||
path: java_artifact | ||
|
||
build_xcframework: | ||
if: ${{ !(github.event_name != 'release' && github.event_name != 'workflow_dispatch') }} # !env.IS_SIMPLE_TEST と同じ | ||
|
@@ -391,6 +424,175 @@ jobs: | |
${{ env.ASSET_NAME }}.zip | ||
target_commitish: ${{ github.sha }} | ||
|
||
build_java_api: | ||
sevenc-nanashi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
runs-on: ubuntu-latest | ||
if: ${{ !(github.event_name != 'release' && github.event_name != 'workflow_dispatch') }} # !env.IS_SIMPLE_TEST と同じ | ||
needs: | ||
- build_and_deploy | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Rust | ||
uses: ./.github/actions/rust-toolchain-from-file | ||
- name: Set up Java | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: "17" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Android Gradle Pluginは17以上じゃないと動かなかったので。 |
||
distribution: "adopt" | ||
- uses: nttld/setup-ndk@v1 | ||
id: setup-ndk | ||
with: | ||
ndk-version: r25b | ||
- name: Install cargo-binstall | ||
uses: taiki-e/install-action@cargo-binstall | ||
- name: Install cargo-edit | ||
run: cargo binstall cargo-edit@^0.11 --no-confirm | ||
- name: set cargo version | ||
run: | | ||
cargo set-version "$VERSION" --exclude voicevox_core_python_api --exclude download --exclude xtask | ||
sevenc-nanashi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: "Download artifact (windows-x64-cpu)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. かなり混沌としてるので何とかしたい(何とかできなさそうな感じはする) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. github cli使ってダウンロードするところからgradle叩くところまでをシェルスクリプトにして実行、とかですかねぇ 😇 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. github cliは実行中のArtifactを落とせないっぽみがありました(記憶違いかも) |
||
uses: actions/download-artifact@v3 | ||
with: | ||
name: voicevox_core_java_api-windows-x64-cpu | ||
path: artifact/windows-x64-cpu | ||
|
||
- name: "Download artifact (windows-x64-directml)" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: voicevox_core_java_api-windows-x64-directml | ||
path: artifact/windows-x64-directml | ||
|
||
- name: "Download artifact (windows-x64-cuda)" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: voicevox_core_java_api-windows-x64-cuda | ||
path: artifact/windows-x64-cuda | ||
|
||
- name: "Download artifact (windows-x86-cpu)" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: voicevox_core_java_api-windows-x86-cpu | ||
path: artifact/windows-x86-cpu | ||
|
||
- name: "Download artifact (linux-x64-cpu)" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: voicevox_core_java_api-linux-x64-cpu | ||
path: artifact/linux-x64-cpu | ||
|
||
- name: "Download artifact (linux-x64-gpu)" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: voicevox_core_java_api-linux-x64-gpu | ||
path: artifact/linux-x64-gpu | ||
|
||
- name: "Download artifact (linux-arm64-cpu)" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: voicevox_core_java_api-linux-arm64-cpu | ||
path: artifact/linux-arm64-cpu | ||
|
||
- name: "Download artifact (android-arm64-cpu)" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: voicevox_core_java_api-android-arm64-cpu | ||
path: artifact/android-arm64-cpu | ||
|
||
- name: "Download artifact (android-x86_64-cpu)" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: voicevox_core_java_api-android-x86_64-cpu | ||
path: artifact/android-x86_64-cpu | ||
|
||
- name: "Download artifact (osx-arm64-cpu)" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: voicevox_core_java_api-osx-arm64-cpu | ||
path: artifact/osx-arm64-cpu | ||
|
||
- name: "Download artifact (osx-x64-cpu)" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: voicevox_core_java_api-osx-x64-cpu | ||
path: artifact/osx-x64-cpu | ||
- name: Print tree | ||
run: tree artifact | ||
|
||
- name: Build voicevoxcore | ||
run: | | ||
cat <<EOF | while read -r line; do | ||
windows-x64-cpu|windows-x64 | ||
windows-x86-cpu|windows-x86 | ||
linux-x64-cpu|linux-x64 | ||
linux-arm64-cpu|linux-arm64 | ||
osx-x64-cpu|macos-x64 | ||
osx-arm64-cpu|macos-arm64 | ||
EOF | ||
IFS='|' read -r artifact_name target <<< "$line" | ||
mkdir "crates/voicevox_core_java_api/lib/src/main/resources/dll/${target}/" | ||
cp -v "artifact/$artifact_name"/* "crates/voicevox_core_java_api/lib/src/main/resources/dll/${target}/" | ||
done | ||
|
||
cd crates/voicevox_core_java_api | ||
OS=desktop DEVICE=cpu gradle publishToMavenLocal | ||
|
||
- name: Build voicevoxcore-directml | ||
run: | | ||
cat <<EOF | while read -r line; do | ||
windows-x64-directml|windows-x64 | ||
EOF | ||
IFS='|' read -r artifact_name target <<< "$line" | ||
cp -v "artifact/$artifact_name"/* "crates/voicevox_core_java_api/lib/src/main/resources/dll/${target}/" | ||
done | ||
|
||
cd crates/voicevox_core_java_api | ||
OS=desktop DEVICE=directml gradle publishToMavenLocal | ||
|
||
- name: Build voicevoxcore-cuda | ||
run: | | ||
cat <<EOF | while read -r line; do | ||
windows-x64-cuda|windows-x64 | ||
linux-x64-gpu|linux-x64 | ||
EOF | ||
IFS='|' read -r artifact_name target <<< "$line" | ||
cp -v "artifact/$artifact_name"/* "crates/voicevox_core_java_api/lib/src/main/resources/dll/${target}/" | ||
done | ||
|
||
cd crates/voicevox_core_java_api | ||
OS=desktop DEVICE=cuda gradle publishToMavenLocal | ||
|
||
- name: Build voicevoxcore-android | ||
run: | | ||
rm -rf crates/voicevox_core_java_api/lib/src/main/resources/dll | ||
cat <<EOF | while read -r line; do | ||
android-arm64-cpu|arm64-v8a | ||
android-x86_64-cpu|x86_64 | ||
EOF | ||
IFS='|' read -r artifact_name target <<< "$line" | ||
mkdir "crates/voicevox_core_java_api/lib/src/main/resources/jniLibs/${target}/" | ||
cp -v "artifact/$artifact_name"/* "crates/voicevox_core_java_api/lib/src/main/resources/jniLibs/${target}/" | ||
done | ||
|
||
cp ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so crates/voicevox_core_java_api/lib/src/main/resources/jniLibs/arm64-v8a/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stdc++_shared.soがないとロード時にクラッシュするので。 |
||
cp ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/libc++_shared.so crates/voicevox_core_java_api/lib/src/main/resources/jniLibs/x86_64/ | ||
|
||
cd crates/voicevox_core_java_api | ||
OS=android DEVICE=cpu gradle publishToMavenLocal | ||
|
||
- name: Package | ||
run: | | ||
cd ~/.m2/repository | ||
rm -rf dev || true | ||
zip -r /tmp/java_packages.zip . | ||
|
||
- name: Upload to Release | ||
if: env.VERSION != '0.0.0' && env.SKIP_UPLOADING_RELEASE_ASSET == '0' | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
prerelease: true | ||
tag_name: ${{ env.VERSION }} | ||
files: |- | ||
/tmp/java_packages.zip | ||
target_commitish: ${{ github.sha }} | ||
download_test: | ||
sevenc-nanashi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
needs: [config, build_and_deploy] | ||
if: needs.config.outputs.deploy == 'true' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
結構早くなる感じでしょうか?
(キャッシュ、すぐバグにつながる印象があるのでちょっと避けたいなという思いがあります 😇 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5分くらいですね。
ビルドにスピードが求められるのはWorkflowテストくらいなので製品版ビルドでは無効化しています
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほどです、確かに5分短縮は嬉しいのですが・・・。
キャッシュのキーってこのリポジトリ全てで共通なグローバル変数で、かつ未来方向と過去方向にもちゃんと一意になっているかを意識し続けないといけないため、相当気を使うんですよね・・・。
これ以降のコードがキャッシュファイルがあることを想定して書く必要もあり、かつそうなっていない気がするので、できれば避けたい気持ちがあります。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/Swatinem/rust-cacheではなく
actions/cache
を使っている理由はあったりしますでしょうか?(キーとしてはCargo.lock以外にもrust-toolchainだったりあるかなと思った次第で、rust-cacheはそれも含んでくれます)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ないですね、そっちにしてみました。(まぁキャッシュ自体を消す可能性もありますが)