Skip to content

Commit

Permalink
Add: スマホ版ビルドWorkflowを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed Mar 30, 2024
1 parent c30afd0 commit 9cbaad4
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 5 deletions.
120 changes: 120 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 <<EOF > android/build-options.json
${{ secrets.ANDROID_BUILD_OPTIONS }}
EOF
cat <<EOF | base64 -d > 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 }}

3 changes: 3 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions android/build-options.debug.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"keystorePath": "./android/debug.keystore",
"keystorePassword": "android",
"keystoreAlias": "androiddebugkey",
"keystoreAliasPassword": "android"
}
Binary file added android/debug.keystore
Binary file not shown.
9 changes: 9 additions & 0 deletions capacitor.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="@capacitor/splash-screen" />
import { networkInterfaces } from "os";
import fs from "fs";
import dotenv from "dotenv";
import { CapacitorConfig } from "@capacitor/cli";

Expand All @@ -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") {
Expand Down

0 comments on commit 9cbaad4

Please sign in to comment.