VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.
Python aiaudiobookcudadubbingelevenlabs-alternativehuggingfacelocal-firstmlxomnivoice-studiospeech-to-texttext-to-speechtranscriptiontranslatettsvoice-aivoice-cloningvoice-generationvoicestudioworkflow
fix(mobile): share Android release version codes across workflows
debpalash1ca7a280b202
diff --git a/.github/workflows/android-play-internal.yml b/.github/workflows/android-play-internal.ymlindex 443a8a4f8..ca533ad74 100644--- a/.github/workflows/android-play-internal.yml+++ b/.github/workflows/android-play-internal.yml@@ -28,6 +28,9 @@ jobs:timeout-minutes: 40# Holds the Play secrets; restrict it to `main` in repository settings.environment: google-play+ concurrency:+ group: signed-android-builds+ cancel-in-progress: falsedefaults:run:working-directory: mobile/android@@ -72,8 +75,9 @@ jobs: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 ))+ # Shared clock and serialized builds keep codes increasing across both release workflows.+ export VOICESTUDIO_ANDROID_VERSION_CODE="$(python3 "$GITHUB_WORKSPACE/scripts/android_version_code.py")"+ test -n "$VOICESTUDIO_ANDROID_VERSION_CODE"./gradlew --no-daemon :app:bundleRelease- name: Verify bundle signaturediff --git a/.github/workflows/mobile-release.yml b/.github/workflows/mobile-release.ymlindex 8eea22c63..917d91612 100644--- a/.github/workflows/mobile-release.yml+++ b/.github/workflows/mobile-release.yml@@ -2,7 +2,8 @@# them, with an unsigned IPA for sideloading, into a DRAFT GitHub prerelease for# the owner to review and publish. Store uploads stay in android-play-internal.yml# and ios-testflight.yml. The app version is the root package.json version; each-# run's number is the build number. Secrets live in the protected+# signed Android build shares a clock-based code with Play; iOS uses the run number.+# Secrets live in the protected# `mobile-release` environment; see docs/mobile.md → Releasing.name: mobile-release@@ -34,6 +35,9 @@ jobs:runs-on: ubuntu-24.04timeout-minutes: 60environment: mobile-release+ concurrency:+ group: signed-android-builds+ cancel-in-progress: falsedefaults:run:working-directory: mobile/android@@ -76,8 +80,9 @@ jobs:VOICESTUDIO_ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_UPLOAD_KEY_ALIAS }}VOICESTUDIO_ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_UPLOAD_KEY_PASSWORD }}run: |- # Unique and increasing per run, including reruns.- export VOICESTUDIO_ANDROID_VERSION_CODE=$(( GITHUB_RUN_NUMBER * 10 + GITHUB_RUN_ATTEMPT ))+ # Shared clock and serialized builds keep codes increasing across both release workflows.+ export VOICESTUDIO_ANDROID_VERSION_CODE="$(python3 "$GITHUB_WORKSPACE/scripts/android_version_code.py")"+ test -n "$VOICESTUDIO_ANDROID_VERSION_CODE"./gradlew --no-daemon :app:assembleRelease :app:bundleRelease- name: Collect outputsdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8fff3c5a8..3483a0cd2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -94,6 +94,7 @@ metadata and the backend fallback mirror it.### CI+- Android release and Play builds share an increasing version code to prevent reused or decreasing build numbers (#2969)- Phone build resources keep notice hashes and localized text intact on Windows (#2969)- New `mobile-release` workflow builds signed Android and iOS apps and drafts a GitHub prerelease with the APK, AAB and IPAs (#2969)- The `mobile` workflow builds the pinned on-device runtimes for both apps (#2969)diff --git a/docs/mobile.md b/docs/mobile.mdindex 42e91926f..38a786d1a 100644--- a/docs/mobile.md+++ b/docs/mobile.md@@ -158,9 +158,11 @@ never sends a release to production. One-time setup:artifact and upload it to internal testing by hand. Until the app's firstrelease 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.+The version name is the root `package.json` version. Both signed Android+workflows get their version code from `scripts/android_version_code.py`: UTC+seconds since 2020-01-01. They share a concurrency group, so signed builds run+one at a time and subsequent builds, including reruns, receive increasing codes+across Play and GitHub releases. Local and `mobile` workflow builds stay debug-signed.## Releasing@@ -176,8 +178,8 @@ to production automatically.the App Store IPA, an unsigned IPA for sideloading, and `SHA256SUMS.txt`. Reviewit, then publish. The App Store IPA only installs through TestFlight; iPhoneusers outside TestFlight sideload the unsigned IPA with their own Apple ID.-- **Version:** the root `package.json` version; each run's number makes the build- number, so a rebuild of the same version stays unique.+- **Version:** the root `package.json` version. Android shares its increasing+ build code with Play; iOS uses the workflow run number and attempt.- **Secrets** (repository environment `mobile-release`, with required reviewers,not limited to `main` so tags can use it): the same values as the storeworkflows, `ANDROID_UPLOAD_KEYSTORE`, `ANDROID_UPLOAD_KEYSTORE_PASSWORD`,@@ -185,6 +187,10 @@ to production automatically.`APP_STORE_CONNECT_KEY_ID`, `APP_STORE_CONNECT_ISSUER_ID`,`APP_STORE_CONNECT_API_KEY` and `APPLE_TEAM_ID`.+Android updates also require the installed app's signing certificate. Google+Play App Signing may use a different certificate from the APK upload key;+version codes do not make builds with different signing keys interchangeable.+## Dubbing errorsdiff --git a/scripts/android_version_code.py b/scripts/android_version_code.pynew file mode 100644index 000000000..3728852f3--- /dev/null+++ b/scripts/android_version_code.py@@ -0,0 +1,20 @@+"""Shared version codes for serialized signed Android builds, independent of workflow counters."""++from __future__ import annotations++import time+++EPOCH = 1_577_836_800 # 2020-01-01 UTC; keeps current codes within Google Play's range.+MAX_VERSION_CODE = 2_100_000_000+++def version_code(timestamp: int | None = None) -> int:+ code = int(time.time() if timestamp is None else timestamp) - EPOCH+ if not 1 <= code <= MAX_VERSION_CODE:+ raise ValueError("Build timestamp is outside the Android version-code range")+ return code+++if __name__ == "__main__":+ print(version_code())diff --git a/tests/test_android_play_workflow.py b/tests/test_android_play_workflow.pyindex 978ac9b8d..4bae1c96e 100644--- a/tests/test_android_play_workflow.py+++ b/tests/test_android_play_workflow.py@@ -1,5 +1,6 @@from pathlib import Path+import pytestimport yaml@@ -33,7 +34,48 @@ def test_workflow_uploads_only_a_verified_release_bundle_to_internal():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"]+ assert "scripts/android_version_code.py" in build["run"] and ":app:bundleRelease" in build["run"]+++def test_signed_android_workflows_share_build_number_source_and_serialization():+ play = load(WORKFLOW)["jobs"]["play-internal"]+ release = load(ROOT / ".github/workflows/mobile-release.yml")["jobs"]["android"]+ assert play["concurrency"] == release["concurrency"]+ assert play["concurrency"]["cancel-in-progress"] == "false"+ for job in (play, release):+ build = next(step for step in job["steps"] if "VOICESTUDIO_ANDROID_VERSION_CODE" in step.get("run", ""))+ assert 'python3 "$GITHUB_WORKSPACE/scripts/android_version_code.py"' in build["run"]+ assert "GITHUB_RUN_NUMBER" not in build["run"]+ assert "GITHUB_RUN_ATTEMPT" not in build["run"]+++def test_build_numbers_advance_across_workflows_and_reruns(monkeypatch):+ import runpy++ code = runpy.run_path(str(ROOT / "scripts/android_version_code.py"))["version_code"]+ monkeypatch.setenv("GITHUB_RUN_NUMBER", "9000")+ monkeypatch.setenv("GITHUB_RUN_ATTEMPT", "9")+ monkeypatch.setattr("time.time", lambda: 1_792_771_200)+ first = code()+ monkeypatch.setenv("GITHUB_RUN_NUMBER", "1")+ monkeypatch.setenv("GITHUB_RUN_ATTEMPT", "1")+ monkeypatch.setattr("time.time", lambda: 1_792_771_201)+ assert code() == first + 1+ monkeypatch.setenv("GITHUB_RUN_ATTEMPT", "10")+ monkeypatch.setattr("time.time", lambda: 1_792_771_202)+ assert code() == first + 2++[email protected](("offset", "accepted"), [(0, False), (1, True), (2_100_000_000, True), (2_100_000_001, False)])+def test_build_number_bounds(offset, accepted):+ import runpy++ module = runpy.run_path(str(ROOT / "scripts/android_version_code.py"))+ if accepted:+ assert module["version_code"](module["EPOCH"] + offset) == offset+ else:+ with pytest.raises(ValueError):+ module["version_code"](module["EPOCH"] + offset)def test_gradle_signs_release_only_with_the_upload_key_and_parses_beta_versions():