From 9cbaad444a715bbaa2278b6e4234da3133d17857 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 00:17:26 +0900 Subject: [PATCH 01/19] =?UTF-8?q?Add:=20=E3=82=B9=E3=83=9E=E3=83=9B?= =?UTF-8?q?=E7=89=88=E3=83=93=E3=83=AB=E3=83=89Workflow=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 120 +++++++++++++++++++++++++++++++ android/.gitignore | 3 + android/app/build.gradle | 10 +-- android/build-options.debug.json | 6 ++ android/debug.keystore | Bin 0 -> 3498 bytes capacitor.config.ts | 9 +++ 6 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 android/build-options.debug.json create mode 100644 android/debug.keystore diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 29fd051e0b..9ff048cb61 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,6 +56,7 @@ jobs: - windows-cpu-prepackage - windows-directml-prepackage - macos-cpu-prepackage + - android-cpu-prepackage include: # Linux NVIDIA GPU - artifact_name: linux-nvidia-prepackage @@ -489,3 +490,122 @@ jobs: dist_electron/nsis-web/out/*.7z.* dist_electron/nsis-web/*.exe target_commitish: ${{ github.sha }} + + build-and-upload-android: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + + - name: Replace package name & version + run: | + $sed -i 's/"name": "voicevox"/"name": "${{ matrix.package_name }}"/' package.json + # $sed -i 's/productName: "VOICEVOX"/productName: "${{ matrix.product_name }}"/' vue.config.js + + $sed -i 's/"version": "999.999.999"/"version": "${{ env.VOICEVOX_EDITOR_VERSION }}"/' package.json + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: ".node-version" + cache: "npm" + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'adopt' + java-version: '17' + cache: 'gradle' + + - name: Setup Android SDK + uses: android-actions/setup-android@v3 + + - name: Cache gradle + uses: actions/cache@v3 + with: + path: ./android/.gradle/configuration-cache + key: ${{ env.cache-version }}-gradle-configuration-cache + restore-keys: | + ${{ env.cache-version }}-gradle-configuration-cache + + - name: Install dependencies + run: npm ci + + - name: Checkout Product Version Resource + uses: actions/checkout@v3 + with: + repository: VOICEVOX/voicevox_resource + ref: ${{ env.VOICEVOX_RESOURCE_VERSION }} + path: resource + + - name: Create and replace software resources + run: | + rm build/README.txt + rm public/policy.md + { + cat resource/editor/README.md + echo + cat resource/editor/ACKNOWLEDGMENTS.md + } \ + > build/README.txt + cp build/README.txt public/policy.md + + cp resource/editor/PRIVACYPOLICY.md public/privacyPolicy.md + + - name: Replace .env.production infomations + run: | + # GTM ID + gtm_id=$(jq -er '.gtm_container_id' resource/editor/metas.json) + $sed -i 's/VITE_GTM_CONTAINER_ID=.*/VITE_GTM_CONTAINER_ID='"$gtm_id"'/' .env.production + + # Engine host + $sed -i 's|http://127.0.0.1:50021|local|g' .env.production + + - name: Generate public/licenses.json + run: npm run license:generate -- -o public/licenses.json + + - name: Setup Credentials (Debug) + if: github.event.inputs.code_signing == 'false' + run: | + cp android/build-options.debug.json android/build-options.json + + - name: Setup Credentials (Release) + if: github.event.inputs.code_signing == 'true' + run: | + cat < android/build-options.json + ${{ secrets.ANDROID_BUILD_OPTIONS }} + EOF + cat < android/keystore.jks + ${{ secrets.ANDROID_KEYSTORE }} + EOF + + - name: Build Android + run: | + npm run cap:build:android -- --androidreleasetype APK + npm run cap:build:android -- --androidreleasetype AAB + + - name: Rename + run: | + mkdir /tmp/build_artifacts + cp android/app/build/outputs/apk/release/app-release-signed.aab /tmp/build_artifacts/VOICEVOX-${{ env.VOICEVOX_EDITOR_VERSION }}.aab + cp android/app/build/outputs/apk/release/app-release-signed.apk /tmp/build_artifacts/VOICEVOX-${{ env.VOICEVOX_EDITOR_VERSION }}.apk + + - name: Upload Android binary to Artifacts + if: github.event.inputs.upload_artifact == 'true' + uses: actions/upload-artifact@v3 + with: + name: android-apk + path: |- + /tmp/build_artifacts/VOICEVOX-${{ env.VOICEVOX_EDITOR_VERSION }}.apk + /tmp/build_artifacts/VOICEVOX-${{ env.VOICEVOX_EDITOR_VERSION }}.aab + + - name: Upload Android binary to Release Assets + if: (github.event.release.tag_name || github.event.inputs.version) != '' + uses: softprops/action-gh-release@v1 + with: + prerelease: ${{ github.event.inputs.prerelease }} + tag_name: ${{ env.VOICEVOX_EDITOR_VERSION }} + files: |- + /tmp/build_artifacts/VOICEVOX-${{ env.VOICEVOX_EDITOR_VERSION }}.apk + /tmp/build_artifacts/VOICEVOX-${{ env.VOICEVOX_EDITOR_VERSION }}.aab + target_commitish: ${{ github.sha }} + diff --git a/android/.gitignore b/android/.gitignore index 15068d7ee7..cad3ca1f2a 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -103,3 +103,6 @@ app/src/main/res/xml/config.xml # Assets generated by build/ script app/src/main/assets/*.zip app/src/main/assets/*.sha256 + +# Credentials file +build-options.json diff --git a/android/app/build.gradle b/android/app/build.gradle index c2bcc3ce28..3fc7e2ccaa 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -36,11 +36,11 @@ android { } } -repositories { - flatDir { - dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs' - } -} +// repositories { +// flatDir { +// dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs' +// } +// } def urlZipFile = { name, path, url -> File zipFile = new File("$buildDir/download/${name}.zip") zipFile.parentFile.mkdirs() diff --git a/android/build-options.debug.json b/android/build-options.debug.json new file mode 100644 index 0000000000..56e3282dd9 --- /dev/null +++ b/android/build-options.debug.json @@ -0,0 +1,6 @@ +{ + "keystorePath": "./android/debug.keystore", + "keystorePassword": "android", + "keystoreAlias": "androiddebugkey", + "keystoreAliasPassword": "android" +} diff --git a/android/debug.keystore b/android/debug.keystore new file mode 100644 index 0000000000000000000000000000000000000000..a268aa2155ff4a29d275d4ecfc6a4f44b33cd8f3 GIT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V)qb9Fi&YD6Agh6jYuS)1p0v$@`sNLGw~v%Pbi#FMx2-7#V&w~ zXA&YI)l#!n7vh7v|Ti%oA2@j6GG)2EjaALP42if2Ck zVR9edn7m^|xxxE~uFPsUQ!c@{1(evaK7=LDlA0B**|{SWL~_jYQ0%FN6@j4U^NnI! zbP3mLogK^QWztP)dpX)Qf9pkBsI#3#A``(2T345k`rby;{lHeo14V`n1SI%6=!^p$ zA_`0$$cB0acN?D1LjAl>$PW6n8^UAX$c1%Q@glFi7`0RrkYKX3aw6|?lN|?HJX6G0 z6)QKYh=v+J_e*a~6{F&5VrWt=Ty2o3C}@6)5>$EgM~ID?OpltOi^R*PSj$>KF=q8x zZ=fK0X}$U?`->s@0iRaGhgq+^J=KRB2z11j$Ip7E&knT$K9KzO*POVohc21rRg;ZP zdhk}&&eT3>2YifAbdYTCwlL3A%iizL7ouQ`Kg!_!En9m2xT3F{T=F|AhMmEig?8Vj zV?_u{=vdca?xVOAttJl`ZSOy+(R2G!CX*@n^TifNvdM0>!6!)MhWp}YD{gn$>#%UoHyYjQ)EVcv>5H_c;1TxU# z`clC;+NG46Zc{I*@6kj@nY!xqM1=$!6&Dnq?mdE|w3Cx)XKTmzvt%V7P zW&@DoO%eVtd5`Iz4{?TGmT!~DPU;LWCp*G`NnEov?7XW*;X import { networkInterfaces } from "os"; +import fs from "fs"; import dotenv from "dotenv"; import { CapacitorConfig } from "@capacitor/cli"; @@ -12,6 +13,14 @@ const config: CapacitorConfig = { launchAutoHide: false, }, }, + android: { + buildOptions: { + signingType: "apksigner", + ...(fs.existsSync("./android/build-options.json") + ? JSON.parse(fs.readFileSync("./android/build-options.json", "utf-8")) + : {}), + }, + }, }; if (process.env.CAPACITOR_MODE === "serve") { From f6e2076532c6c7119538ee678e2b345bd0d9cfc6 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 00:25:23 +0900 Subject: [PATCH 02/19] =?UTF-8?q?Fix:=20sed=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9ff048cb61..f1e7878111 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,7 +56,6 @@ jobs: - windows-cpu-prepackage - windows-directml-prepackage - macos-cpu-prepackage - - android-cpu-prepackage include: # Linux NVIDIA GPU - artifact_name: linux-nvidia-prepackage @@ -555,10 +554,10 @@ jobs: run: | # GTM ID gtm_id=$(jq -er '.gtm_container_id' resource/editor/metas.json) - $sed -i 's/VITE_GTM_CONTAINER_ID=.*/VITE_GTM_CONTAINER_ID='"$gtm_id"'/' .env.production + sed -i 's/VITE_GTM_CONTAINER_ID=.*/VITE_GTM_CONTAINER_ID='"$gtm_id"'/' .env.production # Engine host - $sed -i 's|http://127.0.0.1:50021|local|g' .env.production + sed -i 's|http://127.0.0.1:50021|local|g' .env.production - name: Generate public/licenses.json run: npm run license:generate -- -o public/licenses.json From ccb8ff53cb0fc63b2ae341da1c8e5457d4786d2e Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 00:44:46 +0900 Subject: [PATCH 03/19] =?UTF-8?q?Fix:=20=E6=AE=8B=E3=82=8A=E3=81=AEsed?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f1e7878111..a53cae0c94 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -497,10 +497,10 @@ jobs: - name: Replace package name & version run: | - $sed -i 's/"name": "voicevox"/"name": "${{ matrix.package_name }}"/' package.json + sed -i 's/"name": "voicevox"/"name": "${{ matrix.package_name }}"/' package.json # $sed -i 's/productName: "VOICEVOX"/productName: "${{ matrix.product_name }}"/' vue.config.js - $sed -i 's/"version": "999.999.999"/"version": "${{ env.VOICEVOX_EDITOR_VERSION }}"/' package.json + sed -i 's/"version": "999.999.999"/"version": "${{ env.VOICEVOX_EDITOR_VERSION }}"/' package.json - name: Setup Node uses: actions/setup-node@v3 From 68acb987d3ebc05427b1961da5c8220e7370580a Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 00:53:31 +0900 Subject: [PATCH 04/19] =?UTF-8?q?Fix:=20=E7=BD=AE=E6=8F=9B=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a53cae0c94..ea4f63a129 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -495,11 +495,8 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Replace package name & version + - name: Replace package version run: | - sed -i 's/"name": "voicevox"/"name": "${{ matrix.package_name }}"/' package.json - # $sed -i 's/productName: "VOICEVOX"/productName: "${{ matrix.product_name }}"/' vue.config.js - sed -i 's/"version": "999.999.999"/"version": "${{ env.VOICEVOX_EDITOR_VERSION }}"/' package.json - name: Setup Node From 17d85969d20403c6c7184130435921c8d66c6518 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 00:59:30 +0900 Subject: [PATCH 05/19] =?UTF-8?q?Fix:=20chmod=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ea4f63a129..91bad00fcb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -576,6 +576,7 @@ jobs: - name: Build Android run: | + chmod +x ./android/gradlew npm run cap:build:android -- --androidreleasetype APK npm run cap:build:android -- --androidreleasetype AAB From 4bd9e3210cced96a474d57eccd73c40b081d2381 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 08:50:04 +0900 Subject: [PATCH 06/19] =?UTF-8?q?Fix:=20build-tools=E3=82=92PATH=E3=81=AB?= =?UTF-8?q?=E5=A2=97=E3=82=84=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91bad00fcb..da63bd4cce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -124,6 +124,14 @@ jobs: runs-on: ${{ matrix.os }} steps: + - uses: easimon/maximize-build-space@v10 + with: + remove-dotnet: true + remove-android: true + remove-haskell: true + remove-codeql: true + remove-docker-images: true + - uses: actions/checkout@v3 # NOTE: The default sed of macOS is BSD sed. @@ -508,13 +516,19 @@ jobs: - name: Setup Java uses: actions/setup-java@v4 with: - distribution: 'adopt' - java-version: '17' - cache: 'gradle' + distribution: "adopt" + java-version: "17" + cache: "gradle" - name: Setup Android SDK uses: android-actions/setup-android@v3 + - name: Add Android SDK to PATH + run: | + versions=($ANDROID_SDK_ROOT/build-tools/*) + latest_version=${versions[${#versions[@]}-1]} + echo "$latest_version" >> $GITHUB_PATH + - name: Cache gradle uses: actions/cache@v3 with: @@ -605,4 +619,3 @@ jobs: /tmp/build_artifacts/VOICEVOX-${{ env.VOICEVOX_EDITOR_VERSION }}.apk /tmp/build_artifacts/VOICEVOX-${{ env.VOICEVOX_EDITOR_VERSION }}.aab target_commitish: ${{ github.sha }} - From ae2d70900542882c548335d6c181db790b9504fd Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 08:53:55 +0900 Subject: [PATCH 07/19] =?UTF-8?q?Fix:=20ubuntu=E4=BB=A5=E5=A4=96=E3=81=A0?= =?UTF-8?q?=E3=81=A8=E8=B5=B0=E3=82=89=E3=81=AA=E3=81=84=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index da63bd4cce..f0f23117ab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -125,6 +125,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: easimon/maximize-build-space@v10 + if: startsWith(matrix.os, 'ubuntu-') with: remove-dotnet: true remove-android: true From 9ed72999a5b74935ce7acb97a3d4c5253369f8d2 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 08:56:28 +0900 Subject: [PATCH 08/19] =?UTF-8?q?Fix:=20keystore=E3=81=AE=E3=83=91?= =?UTF-8?q?=E3=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build-options.debug.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build-options.debug.json b/android/build-options.debug.json index 56e3282dd9..c38f4cd8b3 100644 --- a/android/build-options.debug.json +++ b/android/build-options.debug.json @@ -1,5 +1,5 @@ { - "keystorePath": "./android/debug.keystore", + "keystorePath": "./debug.keystore", "keystorePassword": "android", "keystoreAlias": "androiddebugkey", "keystoreAliasPassword": "android" From 065787945ccc29e8e9ba681558ecfae2fcde571d Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 09:01:17 +0900 Subject: [PATCH 09/19] =?UTF-8?q?Change:=20name=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f0f23117ab..b2c6824e44 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -524,7 +524,7 @@ jobs: - name: Setup Android SDK uses: android-actions/setup-android@v3 - - name: Add Android SDK to PATH + - name: Add build-tools to PATH run: | versions=($ANDROID_SDK_ROOT/build-tools/*) latest_version=${versions[${#versions[@]}-1]} From 340add2200d32bf1258261e335abf0c0fa1563eb Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 09:11:54 +0900 Subject: [PATCH 10/19] =?UTF-8?q?Change:=20rc=E3=81=98=E3=82=83=E3=81=AA?= =?UTF-8?q?=E3=81=84build-tools=E3=82=92=E4=BD=BF=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b2c6824e44..2520865633 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -124,14 +124,15 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: easimon/maximize-build-space@v10 + # https://github.com/easimon/maximize-build-space/blob/fc881a613ad2a34aca9c9624518214ebc21dfc0c/action.yml#L122-L136 + - name: Remove unnecessary tools if: startsWith(matrix.os, 'ubuntu-') - with: - remove-dotnet: true - remove-android: true - remove-haskell: true - remove-codeql: true - remove-docker-images: true + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf /opt/ghc + sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo docker image prune --all --force - uses: actions/checkout@v3 @@ -527,8 +528,17 @@ jobs: - name: Add build-tools to PATH run: | versions=($ANDROID_SDK_ROOT/build-tools/*) - latest_version=${versions[${#versions[@]}-1]} - echo "$latest_version" >> $GITHUB_PATH + build_tools_path=${versions[0]} + for version in "${versions[@]}"; do + if [ echo "$version" | grep -q 'rc' ]; then + continue + fi + build_tools_path=$version + done + + echo "Build tools path: $build_tools_path" + + echo "$build_tools_path" >> $GITHUB_PATH - name: Cache gradle uses: actions/cache@v3 From 3d19b3e6be835f49b387f0201ed9d432ad862bd1 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 09:25:26 +0900 Subject: [PATCH 11/19] =?UTF-8?q?Change:=20=E3=82=B9=E3=82=AF=E3=83=AA?= =?UTF-8?q?=E3=83=97=E3=83=88=E5=91=A8=E3=82=8A=E3=82=92=E8=A6=8B=E7=9B=B4?= =?UTF-8?q?=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 8 +++++--- README.md | 33 +++++++++++++++++++++++++-------- capacitor.config.ts | 23 +++++++++++++++++++---- 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2520865633..922b1a7a79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -549,7 +549,9 @@ jobs: ${{ env.cache-version }}-gradle-configuration-cache - name: Install dependencies - run: npm ci + run: | + npm ci + npm run mobile:install - name: Checkout Product Version Resource uses: actions/checkout@v3 @@ -602,8 +604,8 @@ jobs: - name: Build Android run: | chmod +x ./android/gradlew - npm run cap:build:android -- --androidreleasetype APK - npm run cap:build:android -- --androidreleasetype AAB + npm run mobile:build:android -- --androidreleasetype APK --signing-type apksigner + npm run mobile:build:android -- --androidreleasetype AAB --signing-type jarsigner - name: Rename run: | diff --git a/README.md b/README.md index 27761ea7dc..cda49a2a02 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Node.js の管理ツール ([nvs](https://github.com/jasongin/nvs)など)を利 ```bash npm ci +npm run mobile:install ``` また、Android・iOS 開発用のツールも必要です。[Capacitor: 環境設定](https://capacitorjs.jp/docs/getting-started/environment-setup)を参照してください。 @@ -26,13 +27,13 @@ npm ci PC のプライベート IP アドレスは自動で取得されますが、手動で設定する場合は`.env` 内で `CAPACITOR_ADDRESS` を指定してください。 ```bash -npm run cap:serve +npm run mobile:serve ``` または、以下のコマンドで Web 側の変更をビルドし、Capacitor のライブリロードなしで反映します。 ```bash -npm run cap:sync +npm run mobile:sync ``` ### Android 版 @@ -40,7 +41,7 @@ npm run cap:sync 以下のコマンドで Android Studio が起動します。起動後、Android Studio で実行ボタンを押してください。 ```bash -npm run cap:open:android +npm run mobile:open:android ``` [Capacitor Android ドキュメンテーション](https://capacitorjs.jp/docs/android) も参照してください。 @@ -53,14 +54,30 @@ TODO ### Android 版 +`apksigner` に PATH が通っている必要があります。 +`android/build-options.json` に keystore の情報を記述してください。 + +```jsonc +{ + // keystore のパス。 + "keystorePath": "./android/debug.keystore", + // keystore のパスワード。 + "keystorePassword": "android", + // keystore のエイリアス。 + "keystoreAlias": "androiddebugkey", + // keystore のエイリアスのパスワード。 + "keystoreAliasPassword": "android" +} +``` + +セットアップが完了したら以下のコマンドでビルドできます。 + ```bash ANDROID_HOME=/path/to/android-sdk -npm run cap:build:android -- \ - --keystorepath /path/to/keystore.jks \ - --keystorepass Password_here \ - --keystorealias TestKey \ - --keystorealiaspass Password_here +npm run mobile:build:android -- \ + --androidreleasetype APK + # --androidreleasetype AAB ``` ### iOS/iPadOS 版 diff --git a/capacitor.config.ts b/capacitor.config.ts index 39e08d557d..92aadb72ff 100644 --- a/capacitor.config.ts +++ b/capacitor.config.ts @@ -1,9 +1,24 @@ /// import { networkInterfaces } from "os"; import fs from "fs"; +import path from "path"; import dotenv from "dotenv"; import { CapacitorConfig } from "@capacitor/cli"; +let keystorePath = ""; +let keystorePassword = ""; +let keystoreAlias = ""; +let keystoreAliasPassword = ""; +if (fs.existsSync("./android/build-options.json")) { + const buildOptions = JSON.parse( + fs.readFileSync("./android/build-options.json", "utf-8") + ); + keystorePath = path.resolve(buildOptions.keystorePath); + keystorePassword = buildOptions.keystorePassword; + keystoreAlias = buildOptions.keystoreAlias; + keystoreAliasPassword = buildOptions.keystoreAliasPassword; +} + const config: CapacitorConfig = { appId: "jp.hiroshiba.voicevox", appName: "VOICEVOX", @@ -15,10 +30,10 @@ const config: CapacitorConfig = { }, android: { buildOptions: { - signingType: "apksigner", - ...(fs.existsSync("./android/build-options.json") - ? JSON.parse(fs.readFileSync("./android/build-options.json", "utf-8")) - : {}), + keystorePath, + keystorePassword, + keystoreAlias, + keystoreAliasPassword, }, }, }; From 796e47a1f4eab5a14cb13d42de695bfa54857e59 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 09:33:01 +0900 Subject: [PATCH 12/19] =?UTF-8?q?Change:=20package.json=E3=81=AEcap:?= =?UTF-8?q?=E3=82=92=E5=A4=89=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +---- package.json | 15 ++++++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index cda49a2a02..fb22855f06 100644 --- a/README.md +++ b/README.md @@ -59,13 +59,10 @@ TODO ```jsonc { - // keystore のパス。 + // 相対パスはプロジェクトルートから解決されます。 "keystorePath": "./android/debug.keystore", - // keystore のパスワード。 "keystorePassword": "android", - // keystore のエイリアス。 "keystoreAlias": "androiddebugkey", - // keystore のエイリアスのパスワード。 "keystoreAliasPassword": "android" } ``` diff --git a/package.json b/package.json index d8c445ca3b..3a3e4a9107 100644 --- a/package.json +++ b/package.json @@ -28,18 +28,19 @@ "electron:build_pnever": "cross-env VITE_TARGET=electron vite build && electron-builder --config electron-builder.config.js --publish never", "electron:build_pnever_prepackaged": "cross-var electron-builder --config electron-builder.config.js --publish never --prepackaged $PREPACKAGED", "electron:serve": "cross-env VITE_TARGET=electron vite", - "postinstall": "electron-builder install-app-deps && node build/download7z.js && ts-node --transpileOnly build/downloadMobileAssets.mts && node build/generateSpeakerInfo.js", + "postinstall": "electron-builder install-app-deps && node build/download7z.js", "browser:serve": "cross-env VITE_TARGET=browser vite", "browser:build": "cross-env VITE_TARGET=browser vite build", "postuninstall": "electron-builder install-app-deps", "license:generate": "node build/generateLicenses.js", "license:merge": "node build/mergeLicenses.js", - "cap:serve": "cross-env CAPACITOR_MODE=serve cap sync && cross-env VITE_TARGET=mobile vite --host 0.0.0.0", - "cap:sync": "cross-env VITE_TARGET=mobile vite build && cross-env CAPACITOR_MODE=build cap sync", - "cap:build:android": "npm run cap:sync && npx cap build android", - "cap:build:ios": "npm run cap:sync && npx cap build ios", - "cap:open:android": "npx cap open android", - "cap:open:ios": "npx cap open ios", + "mobile:install": "ts-node --transpileOnly build/downloadMobileAssets.mts && node build/generateSpeakerInfo.js", + "mobile:serve": "cross-env CAPACITOR_MODE=serve cap sync && cross-env VITE_TARGET=mobile vite --host 0.0.0.0", + "mobile:sync": "cross-env VITE_TARGET=mobile vite build && cross-env CAPACITOR_MODE=build cap sync", + "mobile:build:android": "npm run mobile:sync && npx cap build android", + "mobile:build:ios": "npm run mobile:sync && npx cap build ios", + "mobile:open:android": "npx cap open android", + "mobile:open:ios": "npx cap open ios", "generate-icons": "npx matex -r ./build/matexRecipes.yml -o public" }, "dependencies": { From 12ebe9f8265fd820f93db5f09c61f8623ac82175 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 09:42:14 +0900 Subject: [PATCH 13/19] =?UTF-8?q?Fix:=20keystore=E3=81=AE=E3=83=91?= =?UTF-8?q?=E3=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build-options.debug.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build-options.debug.json b/android/build-options.debug.json index c38f4cd8b3..56e3282dd9 100644 --- a/android/build-options.debug.json +++ b/android/build-options.debug.json @@ -1,5 +1,5 @@ { - "keystorePath": "./debug.keystore", + "keystorePath": "./android/debug.keystore", "keystorePassword": "android", "keystoreAlias": "androiddebugkey", "keystoreAliasPassword": "android" From 8c550a51c32143f172c5f06da96c2ee52b802c2a Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 09:50:12 +0900 Subject: [PATCH 14/19] =?UTF-8?q?Fix:=20Android=E7=89=88=E3=83=93=E3=83=AB?= =?UTF-8?q?=E3=83=89=E3=81=A7=E3=82=82=E8=A6=81=E3=82=89=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=83=84=E3=83=BC=E3=83=AB=E3=82=92=E6=B6=88=E3=81=99=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 922b1a7a79..7df1e20882 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -503,6 +503,13 @@ jobs: build-and-upload-android: runs-on: ubuntu-20.04 steps: + - name: Remove unnecessary tools + if: startsWith(matrix.os, 'ubuntu-') + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo docker image prune --all --force - uses: actions/checkout@v3 - name: Replace package version From 12ea1e3a2541bee623127aac639877bc324648cf Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 09:58:23 +0900 Subject: [PATCH 15/19] =?UTF-8?q?Fix:=20if=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7df1e20882..f39f07c212 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -504,7 +504,6 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Remove unnecessary tools - if: startsWith(matrix.os, 'ubuntu-') run: | sudo rm -rf /usr/share/dotnet sudo rm -rf /opt/ghc From bf95bdaeb71e32028637d3a288709172ff22a8b0 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 10:08:00 +0900 Subject: [PATCH 16/19] =?UTF-8?q?Fix:=20=E3=83=91=E3=82=B9=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f39f07c212..da9b045a2e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -616,7 +616,7 @@ jobs: - name: Rename run: | mkdir /tmp/build_artifacts - cp android/app/build/outputs/apk/release/app-release-signed.aab /tmp/build_artifacts/VOICEVOX-${{ env.VOICEVOX_EDITOR_VERSION }}.aab + cp android/app/build/outputs/bundle/release/app-release-signed.aab /tmp/build_artifacts/VOICEVOX-${{ env.VOICEVOX_EDITOR_VERSION }}.aab cp android/app/build/outputs/apk/release/app-release-signed.apk /tmp/build_artifacts/VOICEVOX-${{ env.VOICEVOX_EDITOR_VERSION }}.apk - name: Upload Android binary to Artifacts From 1873662b41185904c01050b9ef12bc5ed37ccbb0 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 10:17:21 +0900 Subject: [PATCH 17/19] =?UTF-8?q?Add:=20=E3=83=A1=E3=83=A2=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index da9b045a2e..3aee1dee44 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -600,6 +600,9 @@ jobs: - name: Setup Credentials (Release) if: github.event.inputs.code_signing == 'true' run: | + # メモ: + # ANDROID_BUILD_OPTIONSはbuild-options.jsonを、 + # ANDROID_KEYSTOREはkeystore.jksをbase64エンコードしたものを想定 cat < android/build-options.json ${{ secrets.ANDROID_BUILD_OPTIONS }} EOF From 3448636a2d16f901fa2b9c85e57fe650c431f7de Mon Sep 17 00:00:00 2001 From: Nanashi Date: Sun, 31 Mar 2024 10:36:26 +0900 Subject: [PATCH 18/19] =?UTF-8?q?Fix:=20=E3=83=90=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E5=A4=89=E3=81=88=E5=BF=98=E3=82=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3aee1dee44..67d396fbdd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -514,6 +514,8 @@ jobs: - name: Replace package version run: | sed -i 's/"version": "999.999.999"/"version": "${{ env.VOICEVOX_EDITOR_VERSION }}"/' package.json + sed -i 's/versionCode 1/versionCode ${{ github.run_number }}/' android/app/build.gradle + sed -E -i 's/versionName ".+"/versionName "${{ env.VOICEVOX_EDITOR_VERSION }}"/' android/app/build.gradle - name: Setup Node uses: actions/setup-node@v3 From a941a68ad0f5573fe9b3d41f75499e63f5876a46 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 31 Mar 2024 11:11:55 +0900 Subject: [PATCH 19/19] =?UTF-8?q?Fix:=20versionVersionGet=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 3 ++- src/backend/mobile/engine/info.ts | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 3fc7e2ccaa..989ea50134 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -5,8 +5,9 @@ android { ndkVersion '25.2.9519653' namespace 'jp.hiroshiba.voicevox' - compileSdkVersion rootProject.ext.compileSdkVersion defaultConfig { + compileSdk rootProject.ext.compileSdkVersion + applicationId "jp.hiroshiba.voicevox" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion diff --git a/src/backend/mobile/engine/info.ts b/src/backend/mobile/engine/info.ts index 5d8f66df54..e67d25c759 100644 --- a/src/backend/mobile/engine/info.ts +++ b/src/backend/mobile/engine/info.ts @@ -9,8 +9,7 @@ const infoProvider: ApiProvider = ({ corePlugin }) => { return { async versionVersionGet() { - // 何故か""で囲まれているのを再現。直ったら消す。 - return JSON.stringify(corePlugin.getVersion()); + return await corePlugin.getVersion().then((res) => res.value); }, async engineManifestEngineManifestGet() { if (!engineManifest) {