Skip to content

VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.

ci(android): add Play internal testing upload workflow

velixiob3a6cb582045
diff --git a/.github/workflows/android-play-internal.yml b/.github/workflows/android-play-internal.yml
new file mode 100644
index 000000000..067ee5d31
--- /dev/null
+++ b/.github/workflows/android-play-internal.yml
@@ -0,0 +1,106 @@
+# Android Play internal testing — signs the companion app with the Play upload
+# key and uploads it to the Play Console internal testing track, the Android
+# counterpart of ios-testflight.yml. Owner-dispatched from `main` only; nothing
+# is sent for production review (see docs/mobile.md → Play internal testing).
+
+name: Android Play internal testing
+
+on:
+ workflow_dispatch:
+ inputs:
+ status:
+ description: "Release status: draft until the app's first Play Console release is rolled out"
+ type: choice
+ options: [completed, draft]
+ default: completed
+
+permissions:
+ contents: read
+
+concurrency:
+ group: android-play-internal
+ cancel-in-progress: false
+
+jobs:
+ play-internal:
+ if: github.ref == 'refs/heads/main'
+ runs-on: ubuntu-24.04
+ timeout-minutes: 40
+ # Holds the Play secrets; restrict it to `main` in repository settings.
+ environment: google-play
+ defaults:
+ run:
+ working-directory: mobile/android
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+ with:
+ persist-credentials: false
+
+ - name: Require signing and upload credentials
+ env:
+ KEYSTORE: ${{ secrets.ANDROID_UPLOAD_KEYSTORE }}
+ KEYSTORE_PASSWORD: ${{ secrets.ANDROID_UPLOAD_KEYSTORE_PASSWORD }}
+ KEY_ALIAS: ${{ secrets.ANDROID_UPLOAD_KEY_ALIAS }}
+ KEY_PASSWORD: ${{ secrets.ANDROID_UPLOAD_KEY_PASSWORD }}
+ SERVICE_ACCOUNT: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
+ run: |
+ for name in KEYSTORE KEYSTORE_PASSWORD KEY_ALIAS KEY_PASSWORD SERVICE_ACCOUNT; do
+ test -n "${!name}" || { echo "Missing $name; see docs/mobile.md → Play internal testing"; exit 1; }
+ done
+
+ - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
+ with:
+ distribution: temurin
+ java-version: "21"
+
+ - uses: gradle/actions/setup-gradle@42ebad84b0585498c0413b0967cf4e80ec0e1d19 # v4.4.1
+
+ - name: SDK location
+ run: printf 'sdk.dir=%s\n' "$ANDROID_HOME" > local.properties
+
+ - name: Write upload keystore
+ env:
+ KEYSTORE: ${{ secrets.ANDROID_UPLOAD_KEYSTORE }}
+ run: |
+ umask 077
+ printf '%s' "$KEYSTORE" | base64 --decode > "$RUNNER_TEMP/upload.jks"
+
+ - name: Build signed bundle
+ env:
+ VOICESTUDIO_ANDROID_KEYSTORE: ${{ runner.temp }}/upload.jks
+ VOICESTUDIO_ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_UPLOAD_KEYSTORE_PASSWORD }}
+ VOICESTUDIO_ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_UPLOAD_KEY_ALIAS }}
+ VOICESTUDIO_ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_UPLOAD_KEY_PASSWORD }}
+ run: |
+ # Unique and increasing per upload, including reruns of the same run.
+ export VOICESTUDIO_ANDROID_VERSION_CODE=$(( GITHUB_RUN_NUMBER * 10 + GITHUB_RUN_ATTEMPT ))
+ ./gradlew --no-daemon :app:bundleRelease
+
+ - name: Verify bundle signature
+ run: |
+ AAB=app/build/outputs/bundle/release/app-release.aab
+ jarsigner -verify -strict "$AAB" | grep -q 'jar verified'
+ keytool -printcert -jarfile "$AAB" | grep -q 'Owner:'
+ if keytool -printcert -jarfile "$AAB" | grep -q 'CN=Android Debug'; then
+ echo "Bundle is debug-signed"; exit 1
+ fi
+
+ # Kept for the Play Console's one-time manual first upload.
+ - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
+ with:
+ name: VoiceStudio-android-play
+ path: mobile/android/app/build/outputs/bundle/release/app-release.aab
+ retention-days: 7
+
+ - name: Upload to Play internal testing
+ uses: r0adkll/upload-google-play@e738b9dd8f2476ea806d921b64aacd24f34515a5 # v1.1.5
+ with:
+ serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
+ packageName: com.voicestudio.mobile
+ releaseFiles: mobile/android/app/build/outputs/bundle/release/app-release.aab
+ track: internal
+ status: ${{ inputs.status }}
+
+ - name: Remove upload keystore
+ if: always()
+ run: rm -f "$RUNNER_TEMP/upload.jks"
diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml
index 1ca821e80..7d1040aae 100644
--- a/.github/workflows/mobile.yml
+++ b/.github/workflows/mobile.yml
@@ -57,6 +57,14 @@ jobs:
- name: Build, unit tests, lint
run: ./gradlew --no-daemon assembleDebug assembleDebugAndroidTest testDebugUnitTest lint
+ # A Beta channel version (X.Y.Z-beta.N) must configure too, not only the checked-in one.
+ - name: Beta version configures
+ run: |
+ node -e 'const f="../../package.json",p=require(f);p.version=p.version.replace(/-.*/,"")+"-beta.1";require("fs").writeFileSync(f,JSON.stringify(p,null,2)+"\n")'
+ ./gradlew --no-daemon -q :app:printAppVersion | tee "$RUNNER_TEMP/version.txt"
+ grep -qE '^versionName=[0-9]+\.[0-9]+\.[0-9]+-beta\.1 versionCode=[0-9]+$' "$RUNNER_TEMP/version.txt"
+ git checkout -- ../../package.json
+
- name: Upload reports on failure
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d9bce6251..ba32df9b5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -66,6 +66,7 @@ metadata and the backend fallback mirror it.
- New `mobile` workflow builds and tests both phone apps; a contract test fails when their theme or API description drifts from the desktop app (#2965)
- iOS TestFlight workflow: maintainers can upload a signed iPhone build for internal testers from `main` ([guide](docs/mobile.md#testflight-maintainers)) (#3188)
+- Android Play internal testing workflow: the matching signed Android upload from `main`, and beta versions no longer break the Android build ([guide](docs/mobile.md#play-internal-testing-maintainers)) (#PR)
- Gallery preview fallback smoke no longer flakes when a slower runner reads the playing clip in several byte ranges (#3018)
diff --git a/docs/RELEASING.md b/docs/RELEASING.md
index 96025fa44..b778a27d9 100644
--- a/docs/RELEASING.md
+++ b/docs/RELEASING.md
@@ -52,6 +52,11 @@ Electron publication uses these GitHub Actions secrets:
`APP_STORE_CONNECT_API_KEY` in the `app-store-connect` environment for the
iOS TestFlight upload ([`mobile.md`](mobile.md#testflight-maintainers)).
TestFlight is not a release channel.
+- `ANDROID_UPLOAD_KEYSTORE`, `ANDROID_UPLOAD_KEYSTORE_PASSWORD`,
+ `ANDROID_UPLOAD_KEY_ALIAS`, `ANDROID_UPLOAD_KEY_PASSWORD` and
+ `GOOGLE_PLAY_SERVICE_ACCOUNT_JSON` in the `google-play` environment for the
+ Play internal testing upload ([`mobile.md`](mobile.md#play-internal-testing-maintainers)).
+ Play internal testing is not a release channel either.
- The repository `GITHUB_TOKEN` for draft creation and asset uploads.
- `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` for the Docker Hub mirror.
- `POSTHOG_PROJECT_TOKEN` (secret) and `POSTHOG_HOST` (repository variable),
diff --git a/docs/mobile.md b/docs/mobile.md
index 1fcbdb4d5..7d3511a3e 100644
--- a/docs/mobile.md
+++ b/docs/mobile.md
@@ -95,3 +95,30 @@ submits the app for App Store review. One-time setup in the Apple Developer team
The version is the root `package.json` version without any `-beta.N` suffix
(App Store Connect accepts only `X.Y.Z`); the build number is the workflow run
number and attempt, so every upload is new.
+
+## Play internal testing (maintainers)
+
+The `Android Play internal testing` workflow is the Android counterpart: it
+signs a release bundle with the Play upload key and uploads it to the Play
+Console **internal testing** track. It is dispatched by hand from `main` and
+never sends a release to production. One-time setup:
+
+1. Create the app in the Play Console with the package name
+ `com.voicestudio.mobile` and keep Play App Signing on (Google holds the app
+ signing key; CI only holds the upload key).
+2. Create an upload key once and keep a backup in the team password manager:
+ `keytool -genkeypair -v -keystore upload.jks -alias upload -keyalg RSA -keysize 4096 -validity 10000`.
+3. Create a Google Cloud service account with a JSON key, then invite its email
+ in the Play Console (Users and permissions) with release access to this app.
+4. Create the `google-play` environment (Settings → Environments), limit it to
+ the `main` branch, and add `ANDROID_UPLOAD_KEYSTORE` (the `.jks` as base64),
+ `ANDROID_UPLOAD_KEYSTORE_PASSWORD`, `ANDROID_UPLOAD_KEY_ALIAS`,
+ `ANDROID_UPLOAD_KEY_PASSWORD` and `GOOGLE_PLAY_SERVICE_ACCOUNT_JSON`.
+5. Google Play takes the first bundle only through the Play Console: run the
+ workflow once (its upload step fails), download the `VoiceStudio-android-play`
+ artifact and upload it to internal testing by hand. Until the app's first
+ release is rolled out, dispatch with status `draft`.
+
+The version name is the root `package.json` version; the version code is the
+workflow run number × 10 plus the attempt, so every upload is new. Local and
+`mobile` workflow builds stay debug-signed.
diff --git a/mobile/android/app/build.gradle.kts b/mobile/android/app/build.gradle.kts
index 7cf517fbe..468b1b54d 100644
--- a/mobile/android/app/build.gradle.kts
+++ b/mobile/android/app/build.gradle.kts
@@ -6,6 +6,14 @@ plugins {
}
val repository = rootDir.resolve("../..")
val appVersion = (JsonSlurper().parse(repository.resolve("package.json")) as Map<*, *>)["version"].toString()
+// Play accepts any versionName, but the code must be numeric; a beta's -beta.N maps to its X.Y.Z.
+val (major, minor, patch) = Regex("""(\d+)\.(\d+)\.(\d+)(?:-beta\.\d+)?""").matchEntire(appVersion)?.destructured
+ ?: error("Unsupported app version for Android: $appVersion")
+// Play uploads pass a new, increasing code per upload; local builds derive it from the version.
+val appVersionCode = providers.environmentVariable("VOICESTUDIO_ANDROID_VERSION_CODE").orNull?.toInt()
+ ?: (major.toInt() * 1000000 + minor.toInt() * 1000 + patch.toInt())
+// The Play upload key, supplied only by the Play workflow; other builds stay debug-signed.
+val uploadKeystore = providers.environmentVariable("VOICESTUDIO_ANDROID_KEYSTORE").orNull
android {
namespace = "com.voicestudio.mobile"
compileSdk = 36
@@ -13,10 +21,19 @@ android {
applicationId = "com.voicestudio.mobile"
minSdk = 29
targetSdk = 36
- versionCode = appVersion.split(".").take(3).map { it.toInt() }.let { it[0]*1000000+it[1]*1000+it[2] }
+ versionCode = appVersionCode
versionName = appVersion
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
+ if (uploadKeystore != null) {
+ signingConfigs.create("upload") {
+ storeFile = file(uploadKeystore)
+ storePassword = providers.environmentVariable("VOICESTUDIO_ANDROID_KEYSTORE_PASSWORD").get()
+ keyAlias = providers.environmentVariable("VOICESTUDIO_ANDROID_KEY_ALIAS").get()
+ keyPassword = providers.environmentVariable("VOICESTUDIO_ANDROID_KEY_PASSWORD").get()
+ }
+ buildTypes.getByName("release").signingConfig = signingConfigs.getByName("upload")
+ }
buildFeatures { compose = true; buildConfig = true }
compileOptions { sourceCompatibility = JavaVersion.VERSION_17; targetCompatibility = JavaVersion.VERSION_17 }
testOptions { unitTests.isIncludeAndroidResources = true }
@@ -51,6 +68,7 @@ val bundleCatalogs by tasks.registering {
}
}
tasks.named("preBuild") { dependsOn(bundleCatalogs) }
+tasks.register("printAppVersion") { doLast { println("versionName=$appVersion versionCode=$appVersionCode") } }
dependencies {
implementation(project(":features"))
implementation(libs.activity)
diff --git a/tests/test_android_play_workflow.py b/tests/test_android_play_workflow.py
new file mode 100644
index 000000000..0a6812dbf
--- /dev/null
+++ b/tests/test_android_play_workflow.py
@@ -0,0 +1,50 @@
+from pathlib import Path
+
+import yaml
+
+
+ROOT = Path(__file__).resolve().parents[1]
+WORKFLOW = ROOT / ".github" / "workflows" / "android-play-internal.yml"
+GRADLE = ROOT / "mobile" / "android" / "app" / "build.gradle.kts"
+MOBILE = ROOT / ".github" / "workflows" / "mobile.yml"
+
+
+def load(path):
+ return yaml.load(path.read_text(), Loader=yaml.BaseLoader)
+
+
+def test_workflow_is_manual_main_only_and_read_only():
+ workflow = load(WORKFLOW)
+ assert set(workflow["on"]) == {"workflow_dispatch"}
+ assert workflow["permissions"] == {"contents": "read"}
+ job = workflow["jobs"]["play-internal"]
+ assert job["if"] == "github.ref == 'refs/heads/main'"
+ assert job["environment"] == "google-play"
+ assert "env" not in job
+
+
+def test_workflow_uploads_only_a_verified_release_bundle_to_internal():
+ steps = load(WORKFLOW)["jobs"]["play-internal"]["steps"]
+ names = [step.get("name") for step in steps]
+ assert names.index("Verify bundle signature") < names.index("Upload to Play internal testing")
+ upload = steps[names.index("Upload to Play internal testing")]
+ assert upload["with"]["track"] == "internal"
+ assert upload["with"]["packageName"] == "com.voicestudio.mobile"
+ cleanup = steps[-1]
+ assert cleanup["name"] == "Remove upload keystore" and cleanup["if"] == "always()"
+ build = steps[names.index("Build signed bundle")]
+ assert "GITHUB_RUN_ATTEMPT" in build["run"] and ":app:bundleRelease" in build["run"]
+
+
+def test_gradle_signs_release_only_with_the_upload_key_and_parses_beta_versions():
+ source = GRADLE.read_text()
+ assert 'Regex("""(\\d+)\\.(\\d+)\\.(\\d+)(?:-beta\\.\\d+)?""")' in source
+ assert 'appVersion.split(".")' not in source
+ assert "if (uploadKeystore != null)" in source
+ assert 'environmentVariable("VOICESTUDIO_ANDROID_VERSION_CODE")' in source
+
+
+def test_mobile_ci_configures_a_beta_version():
+ steps = load(MOBILE)["jobs"]["android"]["steps"]
+ step = next(step for step in steps if step.get("name") == "Beta version configures")
+ assert "-beta.1" in step["run"] and ":app:printAppVersion" in step["run"]