From ae8d2473284e3304420e790f3a833de24cfb1c3f Mon Sep 17 00:00:00 2001 From: Nanashi Date: Mon, 9 Oct 2023 14:52:34 +0900 Subject: [PATCH] =?UTF-8?q?Java=20API=EF=BC=9A=E3=83=93=E3=83=AB=E3=83=89W?= =?UTF-8?q?orkflow=E3=82=92=E8=BF=BD=E5=8A=A0=20(#621)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build_and_deploy.yml | 101 +++++++++++++++++- crates/voicevox_core_java_api/Cargo.toml | 3 + .../lib/build-android.gradle | 20 ++++ .../voicevox_core_java_api/lib/build.gradle | 14 +++ 4 files changed, 137 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 08745bf63..c9ae3e793 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -257,6 +257,9 @@ 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: Swatinem/rust-cache@v2 + if: github.event.inputs.is_production != 'true' - name: build voicevox_core_c_api shell: bash run: | @@ -275,6 +278,7 @@ jobs: if: matrix.whl_local_version id: build-voicevox-core-python-api run: | + rm -rf ./target/wheels pip install -r ./crates/voicevox_core_python_api/requirements.txt function build() { maturin build --manifest-path ./crates/voicevox_core_python_api/Cargo.toml --features ${{ matrix.features }}, --target ${{ matrix.target }} --release @@ -287,6 +291,17 @@ jobs: echo "whl=$(find ./target/wheels -type f)" >> "$GITHUB_OUTPUT" env: ORT_USE_CUDA: ${{ matrix.use_cuda }} + - name: build voicevox_core_java_api + if: "contains(matrix.target, 'android')" + 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 +316,9 @@ 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 - name: Code signing (Windows) if: startsWith(matrix.os, 'windows') && github.event.inputs.code_signing == 'true' run: | @@ -311,7 +329,7 @@ jobs: ESIGNERCKA_TOTP_SECRET: ${{ secrets.ESIGNERCKA_TOTP_SECRET }} - 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 }} @@ -337,6 +355,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, 'android') + 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 と同じ @@ -392,6 +416,81 @@ jobs: ${{ env.ASSET_NAME }}.zip target_commitish: ${{ github.sha }} + build_java_package: + 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" + 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" -p voicevox_core_java_api + + - 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: Print tree + run: tree artifact + + - name: Build voicevoxcore-android + run: | + rm -rf crates/voicevox_core_java_api/lib/src/main/resources/dll + cat <