Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
ci(android): add Google Play publishing pipeline (#7955)
Peter Chinmand4c9aeb6d2cc
diff --git a/.github/workflows/publish-android-play.yml b/.github/workflows/publish-android-play.ymlnew file mode 100644index 0000000000..9a2b71dad6--- /dev/null+++ b/.github/workflows/publish-android-play.yml@@ -0,0 +1,160 @@+name: Publish Android to Google Play++on:+ workflow_dispatch:+ inputs:+ operation:+ description: Upload a bundle to internal testing, or promote a tested version to production+ type: choice+ default: upload-internal+ options:+ - upload-internal+ - promote-production+ release_tag:+ description: Internal upload only — published GitHub release containing a verified AAB+ required: false+ type: string+ version_code:+ description: Production promotion only — exact version code already active in internal testing (full rollout)+ required: false+ type: string+ status:+ description: Internal upload only — draft for Console review, or completed for internal testers+ type: choice+ default: draft+ options:+ - draft+ - completed+ changes_not_sent_for_review:+ description: Leave changes for manual submission in Play Console (only if Play requires it)+ type: boolean+ default: false++# All edits for this package must be serialized, even for different releases.+concurrency:+ group: google-play-com-macro-workspace-mobile+ cancel-in-progress: false++permissions:+ contents: read++jobs:+ publish:+ name: Upload to internal testing+ if: github.ref == 'refs/heads/main' && inputs.operation == 'upload-internal'+ runs-on: ubuntu-24.04+ timeout-minutes: 30+ permissions:+ contents: read+ id-token: write+ env:+ RELEASE_TAG: ${{ inputs.release_tag }}+ steps:+ - name: Checkout publishing workflow+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd+ with:+ persist-credentials: false+ - name: Check Play configuration+ env:+ WIF_PROVIDER: ${{ vars.GOOGLE_PLAY_WORKLOAD_IDENTITY_PROVIDER }}+ PLAY_ACCOUNT: ${{ vars.GOOGLE_PLAY_SERVICE_ACCOUNT }}+ run: |+ set -euo pipefail+ if [[ -z "$WIF_PROVIDER" || -z "$PLAY_ACCOUNT" ]]; then+ echo "Configure the Google Play repository variables; see docs/ANDROID_DEVELOPMENT.md" >&2+ exit 1+ fi+ - name: Download verified release bundle+ id: artifact+ env:+ GH_TOKEN: ${{ github.token }}+ run: |+ set -euo pipefail+ [[ "$RELEASE_TAG" =~ ^v20[0-9]{2}\.[0-9]{1,2}\.[0-9]{1,2}(\.[0-9]{1,2})?$ ]]+ gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --json isDraft,isPrerelease \+ | jq -e '.isDraft == false and .isPrerelease == false'+ filename="macro-$RELEASE_TAG-android-arm64.aab"+ mapping="macro-$RELEASE_TAG-android-arm64-mapping.txt"+ mkdir -p "$RUNNER_TEMP/play-release"+ gh release download "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" \+ --dir "$RUNNER_TEMP/play-release" \+ --pattern "$filename" --pattern "$filename.sha256" \+ --pattern "$mapping" --pattern "$mapping.sha256"+ \cd "$RUNNER_TEMP/play-release"+ # Compare only the expected files; don't interpret paths from a checksum file.+ for artifact in "$filename" "$mapping"; do+ expected=$(awk 'NR == 1 { print $1 }' "$artifact.sha256")+ [[ "$expected" =~ ^[a-f0-9]{64}$ ]]+ actual=$(sha256sum "$artifact" | cut -d ' ' -f 1)+ [[ "$actual" == "$expected" ]]+ done+ echo "bundle=$RUNNER_TEMP/play-release/$filename" >> "$GITHUB_OUTPUT"+ echo "mapping=$RUNNER_TEMP/play-release/$mapping" >> "$GITHUB_OUTPUT"+ - name: Authenticate to Google Play+ id: auth+ uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3+ with:+ workload_identity_provider: ${{ vars.GOOGLE_PLAY_WORKLOAD_IDENTITY_PROVIDER }}+ service_account: ${{ vars.GOOGLE_PLAY_SERVICE_ACCOUNT }}+ - name: Upload to internal testing+ uses: r0adkll/upload-google-play@e738b9dd8f2476ea806d921b64aacd24f34515a5 # v1+ with:+ serviceAccountJson: ${{ steps.auth.outputs.credentials_file_path }}+ packageName: com.macro.workspace.mobile+ releaseFiles: ${{ steps.artifact.outputs.bundle }}+ mappingFile: ${{ steps.artifact.outputs.mapping }}+ releaseName: ${{ inputs.release_tag }}+ tracks: internal+ status: ${{ inputs.status }}+ changesNotSentForReview: ${{ inputs.changes_not_sent_for_review }}+ - name: Record upload+ env:+ RELEASE_STATUS: ${{ inputs.status }}+ run: |+ printf 'Uploaded `%s` to Google Play internal testing with status `%s`.\n' \+ "$RELEASE_TAG" "$RELEASE_STATUS" >> "$GITHUB_STEP_SUMMARY"++ promote:+ name: Promote tested version to production+ if: github.ref == 'refs/heads/main' && inputs.operation == 'promote-production'+ runs-on: ubuntu-24.04+ timeout-minutes: 10+ permissions:+ contents: read+ id-token: write+ steps:+ - name: Checkout publishing workflow+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd+ with:+ persist-credentials: false+ - name: Check promotion inputs+ env:+ VERSION_CODE: ${{ inputs.version_code }}+ WIF_PROVIDER: ${{ vars.GOOGLE_PLAY_WORKLOAD_IDENTITY_PROVIDER }}+ PLAY_ACCOUNT: ${{ vars.GOOGLE_PLAY_SERVICE_ACCOUNT }}+ run: |+ set -euo pipefail+ if [[ ! "$VERSION_CODE" =~ ^[1-9][0-9]{0,9}$ ]] || (( VERSION_CODE > 2100000000 )); then+ echo "Enter the exact Android version code to promote (1–2100000000)" >&2+ exit 1+ fi+ if [[ -z "$WIF_PROVIDER" || -z "$PLAY_ACCOUNT" ]]; then+ echo "Configure the Google Play repository variables; see docs/ANDROID_DEVELOPMENT.md" >&2+ exit 1+ fi+ - name: Authenticate to Google Play+ id: auth+ uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3+ with:+ workload_identity_provider: ${{ vars.GOOGLE_PLAY_WORKLOAD_IDENTITY_PROVIDER }}+ service_account: ${{ vars.GOOGLE_PLAY_SERVICE_ACCOUNT }}+ token_format: access_token+ access_token_scopes: https://www.googleapis.com/auth/androidpublisher+ create_credentials_file: false+ export_environment_variables: false+ - name: Promote existing version to production+ env:+ GOOGLE_PLAY_ACCESS_TOKEN: ${{ steps.auth.outputs.access_token }}+ VERSION_CODE: ${{ inputs.version_code }}+ CHANGES_NOT_SENT_FOR_REVIEW: ${{ inputs.changes_not_sent_for_review }}+ run: node apps/web/scripts/android-play-promote.mjsdiff --git a/.github/workflows/release-production.yml b/.github/workflows/release-production.ymlindex f5d2071c1c..b3bd4ab95d 100644--- a/.github/workflows/release-production.yml+++ b/.github/workflows/release-production.yml@@ -9,7 +9,7 @@ on:required: truetype: stringpublish_android:- description: Attach the verified APK to the existing release+ description: Attach verified Android App Bundle artifacts to the existing releasedefault: falsetype: boolean@@ -21,8 +21,36 @@ env:MODE: "production"jobs:+ android-changes:+ name: Check for native Android changes+ runs-on: ubuntu-24.04+ permissions:+ contents: read+ timeout-minutes: 10+ outputs:+ build: ${{ steps.changes.outputs.build || steps.recovery.outputs.build }}+ steps:+ - name: Allow explicit recovery build+ id: recovery+ if: github.event_name == 'workflow_dispatch'+ run: echo 'build=true' >> "$GITHUB_OUTPUT"+ - name: Checkout release history+ if: github.event_name == 'release'+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd+ with:+ fetch-depth: 0+ persist-credentials: false+ - name: Compare Tauri with last published Android bundle+ id: changes+ if: github.event_name == 'release'+ env:+ GH_TOKEN: ${{ github.token }}+ run: node apps/web/scripts/android-release-needed.mjs+build-android:- name: Build signed Android APK+ name: Build signed Android App Bundle+ needs: [android-changes]+ if: needs.android-changes.outputs.build == 'true'runs-on: ubuntu-24.04permissions:contents: read@@ -72,7 +100,7 @@ jobs:bun scripts/android-release.ts signing "$RUNNER_TEMP/android-signing" \tauri/src-tauri/gen/android/keystore.propertiesbun scripts/android-firebase.ts build --doppler "$RUNNER_TEMP/android-google-services.json"- - name: Build production APK+ - name: Build production App Bundleworking-directory: apps/webenv:VITE_SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_PRODUCTION }}@@ -88,14 +116,14 @@ jobs:export RUSTC_WRAPPER=""cargo tauri --version# Tauri has shipped both switch-only and value-taking APK/AAB flags.- # Nix and local installations can differ; select APK-only with either CLI.+ # Nix and local installations can differ; build only the AAB with either CLI.android_help=$(cargo tauri android build --help)- apk_args=(--apk)+ artifact_args=(--aab)if [[ "$android_help" == *'--apk <APK>'* ]]; then- apk_args=(--apk true --aab false)+ artifact_args=(--apk false --aab true)fijust android-build --firebase-config "$RUNNER_TEMP/android-google-services.json" \- "${apk_args[@]}" --ci --config "$RUNNER_TEMP/android-release.json" \+ "${artifact_args[@]}" --ci --config "$RUNNER_TEMP/android-release.json" \2>&1 | tee "$RUNNER_TEMP/android-build.log"- name: Preserve Android build logif: always()@@ -105,23 +133,39 @@ jobs:path: ${{ runner.temp }}/android-build.logif-no-files-found: warnretention-days: 7- - name: Verify and collect APK+ - name: Verify and collect App Bundleworking-directory: apps/webenv:- APK_FILENAME: ${{ steps.metadata.outputs.filename }}+ RELEASE_FILENAME: ${{ steps.metadata.outputs.filename }}run: |set -euo pipefail- mapfile -t apks < <(find tauri/src-tauri/gen/android/app/build/outputs/apk -type f -name '*-release.apk')- if [ "${#apks[@]}" -ne 1 ]; then- echo "Expected exactly one signed ARM64 release APK, found ${#apks[@]}" >&2+ curl --fail --location --retry 3 \+ https://github.com/google/bundletool/releases/download/1.18.3/bundletool-all-1.18.3.jar \+ --output "$RUNNER_TEMP/bundletool.jar"+ echo "a099cfa1543f55593bc2ed16a70a7c67fe54b1747bb7301f37fdfd6d91028e29 $RUNNER_TEMP/bundletool.jar" | sha256sum --check+ mapfile -t bundles < <(find tauri/src-tauri/gen/android/app/build/outputs/bundle -type f -name '*-release.aab')+ if [ "${#bundles[@]}" -ne 1 ]; then+ echo "Expected exactly one signed release AAB, found ${#bundles[@]}" >&2exit 1fi- bun scripts/android-release.ts verify "$RELEASE_TAG" "${apks[0]}" \- "$ANDROID_HOME/build-tools/36.0.0" "$RUNNER_TEMP/android-signing/certificate-sha256"+ bun scripts/android-bundle.ts "$RELEASE_TAG" "${bundles[0]}" \+ "$RUNNER_TEMP/bundletool.jar" "$RUNNER_TEMP/android-signing/certificate-sha256"+ # Recovery builds can check out older tags whose metadata names an APK.+ bundle_filename="${RELEASE_FILENAME%.*}.aab"mkdir -p "$GITHUB_WORKSPACE/android-artifacts"- cp "${apks[0]}" "$GITHUB_WORKSPACE/android-artifacts/$APK_FILENAME"+ cp "${bundles[0]}" "$GITHUB_WORKSPACE/android-artifacts/$bundle_filename"+ # R8 mapping belongs to this exact binary; preserve it for Play crash reports.+ bundle_variant=$(basename "$(dirname "${bundles[0]}")")+ mapping="tauri/src-tauri/gen/android/app/build/outputs/mapping/$bundle_variant/mapping.txt"+ if [[ ! -s "$mapping" ]]; then+ echo "Missing R8 mapping for bundle variant $bundle_variant" >&2+ exit 1+ fi+ mapping_filename="${bundle_filename%.aab}-mapping.txt"+ cp "$mapping" "$GITHUB_WORKSPACE/android-artifacts/$mapping_filename"\cd "$GITHUB_WORKSPACE/android-artifacts"- sha256sum "$APK_FILENAME" > "$APK_FILENAME.sha256"+ sha256sum "$bundle_filename" > "$bundle_filename.sha256"+ sha256sum "$mapping_filename" > "$mapping_filename.sha256"- name: Upload verified Android artifactuses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02with:@@ -150,18 +194,31 @@ jobs:runs-on: ubuntu-24.04permissions:contents: write+ actions: writesteps:- name: Download verified Android artifactuses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0with:name: android-releasepath: android-artifacts- - name: Attach APK and checksum to release+ - name: Attach Android artifacts and checksums to releaseuses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65with:tag_name: ${{ inputs.release_tag || github.event.release.tag_name }}files: android-artifacts/*fail_on_unmatched_files: true+ - name: Release to Google Play internal testers+ if: github.event_name == 'release'+ env:+ GH_TOKEN: ${{ github.token }}+ RELEASE_TAG: ${{ github.event.release.tag_name }}+ run: |+ set -euo pipefail+ # Dispatch from main to retain the existing restricted Google OIDC identity.+ gh workflow run publish-android-play.yml --repo "$GITHUB_REPOSITORY" --ref main \+ -f operation=upload-internal -f release_tag="$RELEASE_TAG" -f status=completed+ printf 'Queued Google Play internal testing upload for `%s`. Check the Publish Android to Google Play workflow for its result.\n' \+ "$RELEASE_TAG" >> "$GITHUB_STEP_SUMMARY"deploy-cloud-storage:if: github.event_name == 'release'diff --git a/.gitignore b/.gitignoreindex 92ff2435d9..7fbc7d0d78 100644--- a/.gitignore+++ b/.gitignore@@ -57,3 +57,6 @@ infra/local/generated/# Marketing site prerender bundle (dist/ is covered by **/dist)./apps/marketing/dist-prerender/++# Short-lived credentials generated by google-github-actions/auth.+gha-creds-*.jsondiff --git a/apps/marketing/README.md b/apps/marketing/README.mdindex f98c1f8e79..8e024f2eb7 100644--- a/apps/marketing/README.md+++ b/apps/marketing/README.md@@ -140,6 +140,14 @@ repository's `just check` and verify user-visible behavior in a browser.## SEO and deployment+`/delete-account` is a public, prerendered account-deletion help page linked from+the footer. It offers an email request path without requiring sign-in or an app+installation, plus instructions for the in-app deletion flow. Keep its data and+retention descriptions aligned with the deletion services and the Privacy Policy.+The seven-day cleanup window is a target after verification, not a guarantee;+shared-content and legal/backup retention exceptions are described separately.+Verify the email link, direct navigation, and readability on desktop and mobile.+See [the migration audit and cutover checklist](seo/MIGRATION.md). The committed`seo/migration-baseline.json` records the indexable URLs and schema types onmacro.com. Keep the baseline when adding pages; do not remove a URL from it todiff --git a/apps/marketing/scripts/prerender.ts b/apps/marketing/scripts/prerender.tsindex cb58113f1c..1ee46173aa 100644--- a/apps/marketing/scripts/prerender.ts+++ b/apps/marketing/scripts/prerender.ts@@ -58,6 +58,7 @@ const STATIC_ROUTES = ['/jobs','/terms','/privacy',+ '/delete-account','/dpa','/posts','/tasks',@@ -86,6 +87,7 @@ const ROUTE_MODULES: Array<[RegExp, string]> = [[/^\/jobs$/, 'src/app/routes/RouteJobs.tsx'],[/^\/terms$/, 'src/app/routes/RouteTerms.tsx'],[/^\/privacy$/, 'src/app/routes/RoutePrivacy.tsx'],+ [/^\/delete-account$/, 'src/app/routes/RouteDeleteAccount.tsx'],[/^\/dpa$/, 'src/app/routes/RouteDpa.tsx'],[/^\/tasks$/, 'src/app/routes/RouteTasks.tsx'],[/^\/email$/, 'src/app/routes/RouteEmail.tsx'],@@ -139,6 +141,7 @@ const ROUTE_LABELS: Record<string, string> = {'/jobs': 'Careers','/terms': 'Terms','/privacy': 'Privacy',+ '/delete-account': 'Delete your account','/dpa': 'Data Processing Agreement','/posts': 'Blog','/tasks': 'Tasks',@@ -180,6 +183,7 @@ function sitemapHints(route: string): { priority: string; changefreq: string } {if (route === '/terms' ||route === '/privacy' ||+ route === '/delete-account' ||route === '/dpa' ||route === '/partners/terms')diff --git a/apps/marketing/src/app/components/sections/SectionMoreFeatures.tsx b/apps/marketing/src/app/components/sections/SectionMoreFeatures.tsxindex a651a401c3..7f5df9e6b0 100644--- a/apps/marketing/src/app/components/sections/SectionMoreFeatures.tsx+++ b/apps/marketing/src/app/components/sections/SectionMoreFeatures.tsx@@ -30,6 +30,7 @@ const secondaryLinks: {{ title: 'Partners', href: '/partners' },{ title: 'Terms', href: '/terms' },{ title: 'Privacy', href: '/privacy' },+ { title: 'Delete account', href: '/delete-account' },{ title: 'DPA', href: '/dpa' },];diff --git a/apps/marketing/src/app/main/App.tsx b/apps/marketing/src/app/main/App.tsxindex 86a8306f59..ebef603426 100644--- a/apps/marketing/src/app/main/App.tsx+++ b/apps/marketing/src/app/main/App.tsx@@ -60,6 +60,10 @@ const RoutePrivacy = lazy(() =>const RouteDpa = lazy(() =>import('../routes/RouteDpa').then((module) => ({ default: module.RouteDpa })));+const RouteDeleteAccount = lazy(async () => {+ const module = await import('../routes/RouteDeleteAccount');+ return { default: module.RouteDeleteAccount };+});const RouteTest = lazy(() =>import('../routes/RouteTest').then((module) => ({default: module.RouteTest,@@ -280,6 +284,7 @@ export const App: Component<{<Route path="/jobs" component={RouteJobs} /><Route path="/terms" component={RouteTerms} /><Route path="/privacy" component={RoutePrivacy} />+ <Route path="/delete-account" component={RouteDeleteAccount} /><Route path="/dpa" component={RouteDpa} /><Route path="/posts" component={PostsIndex} /><Route path="/posts/:slug" component={PostPage} />diff --git a/apps/marketing/src/app/routes/RouteDeleteAccount.tsx b/apps/marketing/src/app/routes/RouteDeleteAccount.tsxnew file mode 100644index 0000000000..809163bb33--- /dev/null+++ b/apps/marketing/src/app/routes/RouteDeleteAccount.tsx@@ -0,0 +1,64 @@+import type { Component } from 'solid-js';+import { SectionMoreFeatures } from '../components/sections/SectionMoreFeatures';+import { UtilPlainText } from '../components/utils/UtilPlainText';+import { setPageSeo } from '../utils/utilSeo';+import './RouteLegal.css';++const content = `Macro++# Delete your Macro account++You can request deletion of your Macro account and associated personal data by email, including if you no longer have the app installed. Macro is operated by Coparse, Inc. dba Macro.++## Request deletion by email++1. Email [[email protected]](mailto:[email protected]?subject=Delete%20my%20Macro%20account) from the email address associated with your Macro account.+2. Use the subject “Delete my Macro account” and say that you want your account and associated personal data deleted.+3. We may ask you to verify your identity before fulfilling the request. Do not send your password or sign-in codes.++If you cannot access your account email, contact the same address and explain the situation so we can help verify your identity. You do not need to reinstall the app to make a request.++## Delete your account in the app++1. Open Macro and sign in.+2. Open Settings, then Account.+3. Under Danger zone, select Delete account and follow the confirmation steps.++Account deletion is permanent. Save anything you need before confirming. Uninstalling the app does not delete your account.++## How long deletion takes++We aim to complete account deletion and associated cleanup within seven days after verifying your request. Some cleanup runs in the background. The retained data described below may remain longer.++## Data covered by deletion++The request covers your Macro account, profile information such as your name and email address, and associated personal data stored by Macro. Account cleanup includes owned documents, AI chats, projects, agent sessions, scheduled actions, and onboarding information.++Deleting your Macro account does not delete accounts you hold with connected providers, such as Google. Copies of content held independently by other people or services are outside Macro's account-deletion process. If you use Macro through an organization, that organization may be responsible for handling requests for data it controls.++## Data retention and exceptions++Messages and comments you shared in conversations or items owned by others may remain visible to participants after your account is deleted, preserving their conversation history. Account deletion does not automatically remove this shared content; it may remain until the message, comment, or containing conversation or item is deleted. If your request concerns personal information in shared content, identify that content when you contact [[email protected]](mailto:[email protected]).++As described in our [Privacy Policy](/privacy), some personal information may be retained where needed to comply with legal requirements, resolve disputes, establish legal defenses, conduct audits, or enforce our agreements. Retention periods depend on the type of information and the reason it must be kept. When there is no ongoing legitimate business need or legal reason to retain it, we delete or anonymize it.++Personal information in backup archives that cannot immediately be deleted is securely stored and isolated from further processing until deletion is possible. Contact [[email protected]](mailto:[email protected]) for information about retention that applies to your account or for help with a deletion request.+`;++export const RouteDeleteAccount: Component = () => {+ setPageSeo({+ title: 'Delete your account · Macro',+ description:+ 'Request deletion of your Macro account and associated personal data by email or in the app. Learn what deletion covers and how retained data is handled.',+ path: '/delete-account',+ });++ return (+ <>+ <UtilPlainText content={content} lists />+ <div class="legal-doc-footer">+ <SectionMoreFeatures currentPath="/delete-account" footerOnly />+ </div>+ </>+ );+};diff --git a/apps/marketing/src/app/routes/RouteLegal.css b/apps/marketing/src/app/routes/RouteLegal.cssindex 3f0e2b4675..281686e17a 100644--- a/apps/marketing/src/app/routes/RouteLegal.css+++ b/apps/marketing/src/app/routes/RouteLegal.css@@ -8,6 +8,7 @@as /partners/terms and the blog. */.legal-doc {+ box-sizing: border-box;margin: 0 auto;max-width: 56rem;/* BaseHeader is `position: fixed`, so the document has to start below it —diff --git a/apps/web/scripts/android-bundle.test.ts b/apps/web/scripts/android-bundle.test.tsnew file mode 100644index 0000000000..5fe5ac3e00--- /dev/null+++ b/apps/web/scripts/android-bundle.test.ts@@ -0,0 +1,96 @@+import { execFileSync } from 'node:child_process';+import { afterEach, describe, expect, it, vi } from 'vitest';+import { verifyAndroidBundle } from './android-bundle';+import { androidPackage, androidReleaseMetadata } from './android-release';++vi.mock('node:child_process', () => ({ execFileSync: vi.fn() }));+afterEach(() => vi.mocked(execFileSync).mockReset());++const certificate = 'ab'.repeat(32);+const metadata = androidReleaseMetadata('v2026.10.9', {+ version: '2.5.0',+ bundle: { android: { versionCode: 7 } },+});++function mockBundle(overrides: Record<string, string> = {}, signerStatus = 0) {+ vi.mocked(execFileSync).mockImplementation((command, args) => {+ const parameters = args as string[];+ const key =+ command === 'java'+ ? (parameters.find((arg) => arg.startsWith('--xpath=')) ??+ parameters[2])+ : String(command);+ const outputs: Record<string, string> = {+ jarsigner: 'jar verified.\n',+ keytool: `SHA256: ${certificate}\n`,+ validate: '',+ '--xpath=/manifest/@package': androidPackage,+ '--xpath=/manifest/@android:versionCode': '7',+ '--xpath=/manifest/@android:versionName': '2.5.0',+ dump: '<manifest><application android:debuggable="false" /></manifest>',+ unzip: 'base/lib/arm64-v8a/libapp.so\n',+ ...overrides,+ };+ if (command === 'jarsigner' && signerStatus) {+ throw Object.assign(new Error('jarsigner failed'), {+ status: signerStatus,+ stdout: outputs.jarsigner,+ });+ }+ if (!(key in outputs)) throw new Error(`Unexpected command: ${key}`);+ return outputs[key];+ });+}++function verify() {+ verifyAndroidBundle('app.aab', 'bundletool.jar', certificate, metadata);+}++describe('Android App Bundle verification', () => {+ it('accepts the expected signed ARM64 release', () => {+ mockBundle();+ expect(verify).not.toThrow();+ });++ it('accepts the pinned self-signed upload certificate', () => {+ mockBundle({ jarsigner: 'jar verified, with signer errors.\n' }, 4);+ expect(verify).not.toThrow();+ });++ it.each([1, 16, 20, 32])('rejects jarsigner error status %s', (status) => {+ mockBundle({}, status);+ expect(verify).toThrow(/signature verification/);+ });++ it.each<[string, string, RegExp]>([+ ['jarsigner', 'jar is unsigned.\n', /not signed/],+ ['keytool', `SHA256: ${'cd'.repeat(32)}`, /certificate/],+ ['keytool', `SHA256: ${certificate}\nSHA256: ${certificate}`, /certificate/],+ ['--xpath=/manifest/@package', 'com.wrong.app', /package/],+ ['--xpath=/manifest/@android:versionCode', '6', /versionCode/],+ ['--xpath=/manifest/@android:versionName', '1.0.0', /versionName/],+ ['dump', '<application android:debuggable="true" />', /debuggable/],+ ['unzip', 'base/assets/index.html\n', /ARM64/],+ ['unzip', 'base/lib/x86_64/libapp.so\n', /ARM64/],+ [+ 'unzip',+ 'base/lib/arm64-v8a/libapp.so\nbase/lib/x86_64/libapp.so\n',+ /ARM64/,+ ],+ ])('rejects incorrect %s output', (key, output, message) => {+ mockBundle({ [key]: output });+ expect(verify).toThrow(message);+ });++ it('stops if bundletool rejects the bundle structure', () => {+ mockBundle();+ const implementation = vi.mocked(execFileSync).getMockImplementation()!;+ vi.mocked(execFileSync).mockImplementation((...args) => {+ if (args[0] === 'java' && args[1]?.includes('validate')) {+ throw new Error('Invalid bundle structure');+ }+ return implementation(...args);+ });+ expect(verify).toThrow('Invalid bundle structure');+ });+});diff --git a/apps/web/scripts/android-bundle.ts b/apps/web/scripts/android-bundle.tsnew file mode 100644index 0000000000..8084baab59--- /dev/null+++ b/apps/web/scripts/android-bundle.ts@@ -0,0 +1,114 @@+import { execFileSync } from 'node:child_process';+import { readFile } from 'node:fs/promises';+import { androidPackage, androidReleaseMetadata } from './android-release';++const javaLocale = ['-J-Duser.language=en', '-J-Duser.country=US'];++export function verifyAndroidBundle(+ bundle: string,+ bundletool: string,+ expectedCertificate: string,+ metadata: ReturnType<typeof androidReleaseMetadata>+) {+ let verification: string;+ try {+ verification = execFileSync(+ 'jarsigner',+ [...javaLocale, '-verify', '-strict', bundle],+ { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }+ );+ } catch (error) {+ // Android upload certificates are self-signed. jarsigner's bit 4 includes+ // untrusted chains; accept ONLY that status and pin the certificate below.+ // In particular, bit 16 (unsigned entries) must always fail.+ if (+ typeof error !== 'object' ||+ error === null ||+ !('status' in error) ||+ error.status !== 4 ||+ !('stdout' in error) ||+ typeof error.stdout !== 'string'+ ) {+ throw new Error('AAB signature verification failed');+ }+ verification = error.stdout;+ }+ if (!/^jar verified[.,\s]/m.test(verification)) {+ throw new Error('AAB is not signed');+ }+ const certificates = execFileSync(+ 'keytool',+ [...javaLocale, '-printcert', '-jarfile', bundle],+ { encoding: 'utf8' }+ );+ const fingerprints = [+ ...certificates.matchAll(/SHA256:\s*([a-fA-F0-9:]+)/g),+ ].map((match) => match[1].replaceAll(':', '').toLowerCase());+ if (+ fingerprints.length !== 1 ||+ fingerprints[0] !== expectedCertificate.trim().toLowerCase()+ ) {+ throw new Error('AAB does not have the expected upload certificate');+ }++ const runBundletool = (...args: string[]) =>+ execFileSync('java', ['-jar', bundletool, ...args, `--bundle=${bundle}`], {+ encoding: 'utf8',+ }).trim();+ runBundletool('validate');+ for (const [attribute, expected] of [+ ['package', androidPackage],+ ['android:versionCode', String(metadata.versionCode)],+ ['android:versionName', metadata.version],+ ]) {+ const actual = runBundletool(+ 'dump',+ 'manifest',+ '--module=base',+ `--xpath=/manifest/@${attribute}`+ );+ if (actual !== expected) {+ throw new Error(`AAB ${attribute} is incorrect`);+ }+ }+ const manifest = runBundletool('dump', 'manifest', '--module=base');+ if (/android:debuggable="true"/.test(manifest)) {+ throw new Error('AAB is debuggable');+ }+ const entries = execFileSync('unzip', ['-Z1', bundle], { encoding: 'utf8' });+ const abis = new Set(+ [...entries.matchAll(/^[^/]+\/lib\/([^/]+)\/[^\n]+\.so$/gm)].map(+ (match) => match[1]+ )+ );+ if (abis.size !== 1 || !abis.has('arm64-v8a')) {+ throw new Error('AAB must contain only ARM64 native libraries');+ }+}++if (import.meta.main) {+ const [tag, bundle, bundletool, certificateFile, ...extra] =+ process.argv.slice(2);+ try {+ if (!tag || !bundle || !bundletool || !certificateFile || extra.length) {+ throw new Error(+ 'Usage: android-bundle.ts TAG AAB BUNDLETOOL_JAR CERTIFICATE_FILE'+ );+ }+ const config = JSON.parse(+ await readFile(+ new URL('../tauri/src-tauri/tauri.android.conf.json', import.meta.url),+ 'utf8'+ )+ );+ verifyAndroidBundle(+ bundle,+ bundletool,+ await readFile(certificateFile, 'utf8'),+ androidReleaseMetadata(tag, config)+ );+ } catch (error) {+ console.error(error instanceof Error ? error.message : 'Invalid AAB');+ process.exitCode = 1;+ }+}diff --git a/apps/web/scripts/android-play-promote.mjs b/apps/web/scripts/android-play-promote.mjsnew file mode 100644index 0000000000..1568867811--- /dev/null+++ b/apps/web/scripts/android-play-promote.mjs@@ -0,0 +1,178 @@+import { appendFile } from 'node:fs/promises';+import { resolve } from 'node:path';+import { pathToFileURL } from 'node:url';++const api =+ 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.macro.workspace.mobile/edits';++export function validateVersionCode(value) {+ if (+ typeof value !== 'string' ||+ value.trim() !== value ||+ !/^[1-9][0-9]{0,9}$/.test(value) ||+ Number(value) > 2_100_000_000+ ) {+ throw new Error('Specify an Android version code between 1 and 2100000000');+ }+ return value;+}++function releasesFor(track, expectedTrack) {+ if (+ track?.track !== expectedTrack ||+ (track.releases !== undefined && !Array.isArray(track.releases))+ ) {+ throw new Error(`Invalid ${expectedTrack} track response`);+ }+ const releases = track.releases ?? [];+ for (const release of releases) {+ if (+ !release ||+ !Array.isArray(release.versionCodes) ||+ release.versionCodes.length === 0+ ) {+ throw new Error(`Missing version codes in ${expectedTrack} track`);+ }+ release.versionCodes.forEach(validateVersionCode);+ }+ return releases;+}++export function productionPromotion(internal, production, versionCode) {+ validateVersionCode(versionCode);+ const sources = releasesFor(internal, 'internal').filter(+ (release) =>+ release.status === 'completed' &&+ release.versionCodes.includes(versionCode)+ );+ if (sources.length !== 1 || sources[0].versionCodes.length !== 1) {+ throw new Error(+ 'The exact version must be a completed, single-version release in internal testing'+ );+ }+ const current = releasesFor(production, 'production');+ if (current.some((release) => release.status !== 'completed')) {+ throw new Error(+ 'Production has a draft, staged, or halted release; resolve it in Play Console first'+ );+ }+ const currentCodes = current.flatMap((release) => release.versionCodes);+ if (currentCodes.some((code) => Number(code) > Number(versionCode))) {+ throw new Error('A newer version is already in production');+ }+ if (currentCodes.includes(versionCode)) return null;++ const source = sources[0];+ return {+ track: 'production',+ releases: [+ {+ versionCodes: [versionCode],+ status: 'completed',+ ...(source.name !== undefined ? { name: source.name } : {}),+ ...(source.releaseNotes !== undefined+ ? { releaseNotes: source.releaseNotes }+ : {}),+ ...(source.inAppUpdatePriority !== undefined+ ? { inAppUpdatePriority: source.inAppUpdatePriority }+ : {}),+ },+ ],+ };+}++export async function promoteToProduction({+ token,+ versionCode,+ changesNotSentForReview = false,+ request = fetch,+}) {+ validateVersionCode(versionCode);+ if (!token) throw new Error('Missing Google Play access token');+ if (typeof changesNotSentForReview !== 'boolean')+ throw new Error('Invalid review submission option');++ async function call(method, path, body = undefined) {+ const response = await request(`${api}${path}`, {+ method,+ headers: {+ Authorization: `Bearer ${token}`,+ 'Content-Type': 'application/json',+ },+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),+ signal: AbortSignal.timeout(60_000),+ });+ if (!response.ok) {+ // Do not dump credentials, request headers, or raw API responses into CI logs.+ throw new Error(+ `Google Play ${method} ${path} failed (HTTP ${response.status})`+ );+ }+ return response.status === 204 ? undefined : response.json();+ }++ const edit = await call('POST', '', {});+ if (typeof edit?.id !== 'string' || !edit.id)+ throw new Error('Google Play did not return an edit ID');+ const editPath = `/${encodeURIComponent(edit.id)}`;+ let committed = false;+ try {+ const internal = await call('GET', `${editPath}/tracks/internal`);+ const production = await call('GET', `${editPath}/tracks/production`);+ const update = productionPromotion(internal, production, versionCode);+ if (update === null) return 'already-production';++ await call('PUT', `${editPath}/tracks/production`, update);+ await call('POST', `${editPath}:validate`);+ // A failed/ambiguous commit is not automatically retried; inspect Console first.+ const result = await call(+ 'POST',+ `${editPath}:commit?changesNotSentForReview=${changesNotSentForReview}`+ );+ if (result?.id !== edit.id)+ throw new Error(+ 'Google Play did not confirm the committed edit; inspect Play Console'+ );+ committed = true;+ return 'submitted';+ } finally {+ if (!committed) {+ try {+ await call('DELETE', editPath);+ } catch {+ console.warn(+ 'Unable to discard the Play edit; inspect Play Console before retrying'+ );+ }+ }+ }+}++if (+ process.argv[1] &&+ import.meta.url === pathToFileURL(resolve(process.argv[1])).href+) {+ try {+ const reviewOption = process.env.CHANGES_NOT_SENT_FOR_REVIEW ?? 'false';+ if (!['true', 'false'].includes(reviewOption))+ throw new Error('Invalid review submission option');+ const versionCode = validateVersionCode(process.env.VERSION_CODE);+ const result = await promoteToProduction({+ token: process.env.GOOGLE_PLAY_ACCESS_TOKEN,+ versionCode,+ changesNotSentForReview: reviewOption === 'true',+ });+ const summary =+ result === 'already-production'+ ? `Version code ${versionCode} is already in production; no changes made.`+ : `Submitted version code ${versionCode} from internal testing for a full production rollout. Check Play Console for review and publishing status.`;+ console.log(summary);+ if (process.env.GITHUB_STEP_SUMMARY)+ await appendFile(process.env.GITHUB_STEP_SUMMARY, `${summary}\n`);+ } catch (error) {+ console.error(+ error instanceof Error ? error.message : 'Production promotion failed'+ );+ process.exitCode = 1;+ }+}diff --git a/apps/web/scripts/android-play-promote.test.ts b/apps/web/scripts/android-play-promote.test.tsnew file mode 100644index 0000000000..02618811ff--- /dev/null+++ b/apps/web/scripts/android-play-promote.test.ts@@ -0,0 +1,238 @@+import { describe, expect, it, vi } from 'vitest';+import {+ productionPromotion,+ promoteToProduction,+ validateVersionCode,+} from './android-play-promote.mjs';++const testedRelease = {+ name: 'v2026.10.13',+ status: 'completed',+ versionCodes: ['7'],+ releaseNotes: [{ language: 'en-US', text: 'Tested release notes' }],+ inAppUpdatePriority: 2,+};+const internal = { track: 'internal', releases: [testedRelease] };+const production = {+ track: 'production',+ releases: [{ status: 'completed', versionCodes: ['6'] }],+};++describe('production promotion selection', () => {+ it('promotes only the selected version and preserves its release metadata', () => {+ expect(productionPromotion(internal, production, '7')).toEqual({+ track: 'production',+ releases: [testedRelease],+ });+ });++ it('supports the first production release', () => {+ expect(productionPromotion(internal, { track: 'production' }, '7')).toEqual(+ {+ track: 'production',+ releases: [testedRelease],+ }+ );+ });++ it.each(['', '0', '-1', '01', '7.0', '7\n', '2100000001', 'v2026.10.13'])(+ 'rejects invalid version code %j',+ (version) => {+ expect(() => validateVersionCode(version)).toThrow(/version code/);+ }+ );++ it.each(['draft', 'inProgress', 'halted'])(+ 'refuses an internal release with status %s',+ (status) => {+ const source = { ...internal, releases: [{ ...testedRelease, status }] };+ expect(() => productionPromotion(source, production, '7')).toThrow(+ /internal testing/+ );+ }+ );++ it('rejects versions that are no longer active in internal testing', () => {+ expect(() => productionPromotion(internal, production, '8')).toThrow(+ /internal testing/+ );+ });++ it('does not silently promote a subset of a multi-version release', () => {+ const source = {+ ...internal,+ releases: [{ ...testedRelease, versionCodes: ['7', '8'] }],+ };+ expect(() => productionPromotion(source, production, '7')).toThrow(+ /single-version/+ );+ });++ it.each(['draft', 'inProgress', 'halted'])(+ 'preserves an existing %s production release',+ (status) => {+ const target = {+ ...production,+ releases: [{ status, versionCodes: ['6'] }],+ };+ expect(() => productionPromotion(internal, target, '7')).toThrow(+ /resolve it in Play Console/+ );+ }+ );++ it('rejects production downgrades', () => {+ const target = {+ ...production,+ releases: [{ status: 'completed', versionCodes: ['8'] }],+ };+ expect(() => productionPromotion(internal, target, '7')).toThrow(+ /newer version/+ );+ });++ it('treats a repeated completed promotion as a no-op', () => {+ expect(+ productionPromotion(+ internal,+ { ...production, releases: [testedRelease] },+ '7'+ )+ ).toBeNull();+ });++ it('fails closed on unexpected track responses', () => {+ expect(() => productionPromotion({}, production, '7')).toThrow(+ /track response/+ );+ expect(() =>+ productionPromotion(+ internal,+ { track: 'production', releases: [{}] },+ '7'+ )+ ).toThrow(/Missing version codes/);+ });+});++function mockPlay(options: { failure?: string; target?: unknown } = {}) {+ const calls: { method: string; path: string; body: unknown }[] = [];+ const request = vi.fn(+ async (input: string | URL | Request, init?: RequestInit) => {+ const url = new URL(String(input));+ const path = url.pathname.split('/edits')[1] + url.search;+ const method = init?.method ?? 'GET';+ calls.push({+ method,+ path,+ body: init?.body ? JSON.parse(String(init.body)) : undefined,+ });+ expect(new Headers(init?.headers).get('Authorization')).toBe(+ 'Bearer test-token'+ );+ if (path === options.failure)+ return Response.json({ error: 'test failure' }, { status: 403 });+ if (method === 'DELETE') return new Response(null, { status: 204 });+ if (path === '/edit-1/tracks/internal') return Response.json(internal);+ if (path === '/edit-1/tracks/production')+ return Response.json(options.target ?? production);+ return Response.json({ id: 'edit-1' });+ }+ );+ return { calls, request };+}++describe('Google Play promotion transaction', () => {+ it('updates only production, validates, and commits without uploading a binary', async () => {+ const { request, calls } = mockPlay();+ await expect(+ promoteToProduction({ token: 'test-token', versionCode: '7', request })+ ).resolves.toBe('submitted');+ expect(calls.map(({ method, path }) => `${method} ${path}`)).toEqual([+ 'POST ',+ 'GET /edit-1/tracks/internal',+ 'GET /edit-1/tracks/production',+ 'PUT /edit-1/tracks/production',+ 'POST /edit-1:validate',+ 'POST /edit-1:commit?changesNotSentForReview=false',+ ]);+ expect(calls[3].body).toEqual({+ track: 'production',+ releases: [testedRelease],+ });+ });++ it('supports leaving review submission to Play Console', async () => {+ const { request, calls } = mockPlay();+ await promoteToProduction({+ token: 'test-token',+ versionCode: '7',+ changesNotSentForReview: true,+ request,+ });+ expect(calls.at(-1)?.path).toBe(+ '/edit-1:commit?changesNotSentForReview=true'+ );+ });++ it('discards the edit without writes when the version is already in production', async () => {+ const { request, calls } = mockPlay({+ target: { ...production, releases: [testedRelease] },+ });+ await expect(+ promoteToProduction({ token: 'test-token', versionCode: '7', request })+ ).resolves.toBe('already-production');+ expect(calls.map(({ method }) => method)).toEqual([+ 'POST',+ 'GET',+ 'GET',+ 'DELETE',+ ]);+ });++ it('discards the edit without writes when the requested version was not tested', async () => {+ const { request, calls } = mockPlay();+ await expect(+ promoteToProduction({ token: 'test-token', versionCode: '8', request })+ ).rejects.toThrow(/internal testing/);+ expect(calls.map(({ method }) => method)).toEqual([+ 'POST',+ 'GET',+ 'GET',+ 'DELETE',+ ]);+ });++ it.each([+ '/edit-1/tracks/internal',+ '/edit-1:validate',+ '/edit-1:commit?changesNotSentForReview=false',+ ])(+ 'discards failed edit at %s without retrying the commit',+ async (failure) => {+ const { request, calls } = mockPlay({ failure });+ await expect(+ promoteToProduction({ token: 'test-token', versionCode: '7', request })+ ).rejects.toThrow(/HTTP 403/);+ expect(calls.at(-1)).toEqual({+ method: 'DELETE',+ path: '/edit-1',+ body: undefined,+ });+ expect(calls.filter(({ path }) => path.includes(':commit'))).toHaveLength(+ failure.includes(':commit') ? 1 : 0+ );+ }+ );++ it('rejects invalid input before creating an edit', async () => {+ const { request } = mockPlay();+ await expect(+ promoteToProduction({ token: 'test-token', versionCode: '0', request })+ ).rejects.toThrow(/version code/);+ await expect(+ promoteToProduction({ token: '', versionCode: '7', request })+ ).rejects.toThrow(/access token/);+ expect(request).not.toHaveBeenCalled();+ });+});diff --git a/apps/web/scripts/android-release-needed.mjs b/apps/web/scripts/android-release-needed.mjsnew file mode 100644index 0000000000..c30c6766c9--- /dev/null+++ b/apps/web/scripts/android-release-needed.mjs@@ -0,0 +1,116 @@+import { execFileSync } from 'node:child_process';+import { appendFile } from 'node:fs/promises';+import { resolve } from 'node:path';+import { pathToFileURL } from 'node:url';++const tauriPath = 'apps/web/tauri';+const releaseTag = /^v20\d{2}\.\d{1,2}\.\d{1,2}(?:\.\d{1,2})?$/;++export function androidReleaseDecision({ releases, cwd = process.cwd() }) {+ const git = (...args) =>+ execFileSync('git', args, {+ cwd,+ encoding: 'utf8',+ maxBuffer: 64 * 1024 * 1024,+ }).trim();+ const head = git('rev-parse', '--verify', 'HEAD^{commit}');+ const tree = git('rev-parse', '--verify', `${head}:${tauriPath}`);+ const candidates = new Map();+ for (const release of releases) {+ const tag = release.tag_name;+ if (release.draft || release.prerelease || !releaseTag.test(tag)) continue;+ const stem = `macro-${tag}-android-arm64`;+ const assets = new Set(+ release.assets+ .filter((asset) => asset.state === 'uploaded' && asset.size > 0)+ .map((asset) => asset.name)+ );+ if (+ !['.aab', '.aab.sha256', '-mapping.txt', '-mapping.txt.sha256'].every(+ (suffix) => assets.has(`${stem}${suffix}`)+ )+ )+ continue;+ // Missing tags/history must fail, rather than silently reuse a version code.+ const commit = git('rev-parse', '--verify', `refs/tags/${tag}^{commit}`);+ candidates.set(commit, tag);+ }++ // API release ordering can differ from commit order. Only consider ancestors+ // of this release, and prefer the closest one in topological history order.+ const baseline = git('rev-list', '--topo-order', head)+ .split('\n')+ .find((commit) => candidates.has(commit));+ if (!baseline) {+ return {+ build: true,+ summary:+ 'Build the first AAB: no ancestor release has complete Android artifacts.',+ };+ }+ const tag = candidates.get(baseline);+ if (tree === git('rev-parse', '--verify', `${baseline}:${tauriPath}`)) {+ return {+ build: false,+ summary: `Skip Android: ${tauriPath}/ is unchanged since ${tag}. App updates use the bundle updater.`,+ };+ }++ const versionCode = (commit) => {+ const config = JSON.parse(+ git('show', `${commit}:${tauriPath}/src-tauri/tauri.android.conf.json`)+ );+ const code = config.bundle?.android?.versionCode;+ if (!Number.isInteger(code) || code < 1 || code > 2_100_000_000)+ throw new Error(`Invalid Android versionCode at ${commit}`);+ return code;+ };+ if (versionCode(head) <= versionCode(baseline)) {+ throw new Error(+ `Tauri changed since ${tag}, but Android versionCode did not increase. Run just android-bump in apps/web and commit before tagging.`+ );+ }+ return {+ build: true,+ summary: `Build Android: ${tauriPath}/ changed since ${tag}.`,+ };+}++if (+ process.argv[1] &&+ import.meta.url === pathToFileURL(resolve(process.argv[1])).href+) {+ try {+ const repository = process.env.GITHUB_REPOSITORY;+ if (!repository || !/^[\w.-]+\/[\w.-]+$/.test(repository))+ throw new Error('GITHUB_REPOSITORY must identify the release repository');+ const pages = JSON.parse(+ execFileSync(+ 'gh',+ [+ 'api',+ '--paginate',+ '--slurp',+ `repos/${repository}/releases?per_page=100`,+ ],+ { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 }+ )+ );+ const decision = androidReleaseDecision({ releases: pages.flat() });+ console.log(decision.summary);+ if (process.env.GITHUB_OUTPUT)+ await appendFile(process.env.GITHUB_OUTPUT, `build=${decision.build}\n`);+ if (process.env.GITHUB_STEP_SUMMARY)+ await appendFile(+ process.env.GITHUB_STEP_SUMMARY,+ `${decision.summary}\n`+ );+ } catch (error) {+ console.error(+ error instanceof Error+ ? error.message+ : 'Android release detection failed'+ );+ process.exitCode = 1;+ }+}diff --git a/apps/web/scripts/android-release-needed.test.ts b/apps/web/scripts/android-release-needed.test.tsnew file mode 100644index 0000000000..f10b5f6890--- /dev/null+++ b/apps/web/scripts/android-release-needed.test.ts@@ -0,0 +1,210 @@+import { execFileSync } from 'node:child_process';+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { dirname, join } from 'node:path';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { androidReleaseDecision } from './android-release-needed.mjs';++const nativeConfig = 'apps/web/tauri/src-tauri/tauri.android.conf.json';+let cwd: string;++function git(...args: string[]) {+ return execFileSync(+ 'git',+ ['-c', 'core.hooksPath=/dev/null', '-c', 'commit.gpgsign=false', ...args],+ { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }+ ).trim();+}++function write(path: string, contents: string) {+ const file = join(cwd, path);+ mkdirSync(dirname(file), { recursive: true });+ writeFileSync(file, contents);+}++function version(code: number) {+ write(+ nativeConfig,+ JSON.stringify({ bundle: { android: { versionCode: code } } })+ );+}++function commit() {+ git('add', '.');+ git('commit', '--allow-empty', '-m', 'test release');+}++function release(tag = 'v2026.10.1') {+ git('tag', tag);+ return {+ tag_name: tag,+ draft: false,+ prerelease: false,+ assets: ['.aab', '.aab.sha256', '-mapping.txt', '-mapping.txt.sha256'].map(+ (suffix) => ({+ name: `macro-${tag}-android-arm64${suffix}`,+ size: 100,+ state: 'uploaded',+ })+ ),+ };+}++beforeEach(() => {+ cwd = mkdtempSync(join(tmpdir(), 'android-release-needed-'));+ git('init', '--initial-branch=main');+ git('config', 'user.name', 'Release test');+ git('config', 'user.email', '[email protected]');+ version(1);+ write('apps/web/tauri/src-tauri/src/lib.rs', '// native');+ commit();+});++afterEach(() => rmSync(cwd, { recursive: true, force: true }));++describe('native release detection', () => {+ it('builds the first AAB when no complete ancestor bundle exists', () => {+ expect(androidReleaseDecision({ cwd, releases: [] }).build).toBe(true);+ });++ it('skips frontend, backend, workflow, and root dependency changes', () => {+ const baseline = release();+ for (const path of [+ 'apps/web/src/index.tsx',+ 'services/example/src/lib.rs',+ '.github/workflows/release-production.yml',+ 'Cargo.lock',+ 'apps/web/scripts/android.sh',+ ]) {+ write(path, 'changed');+ }+ commit();+ expect(androidReleaseDecision({ cwd, releases: [baseline] }).build).toBe(+ false+ );+ });++ it.each([+ 'apps/web/tauri/src-tauri/src/lib.rs',+ 'apps/web/tauri/src-tauri/gen/android/app/build.gradle.kts',+ 'apps/web/tauri/src-tauri/gen/apple/project.yml',+ ])('builds for changes under %s with a new version code', (path) => {+ const baseline = release();+ write(path, 'changed');+ version(2);+ commit();+ expect(androidReleaseDecision({ cwd, releases: [baseline] }).build).toBe(+ true+ );+ });++ it.each([1, 0])('rejects native changes with version code %s', (code) => {+ const baseline = release();+ write('apps/web/tauri/src-tauri/src/lib.rs', '// changed');+ version(code);+ commit();+ expect(() => androidReleaseDecision({ cwd, releases: [baseline] })).toThrow(+ /versionCode/+ );+ });++ it('detects deleted native files', () => {+ const baseline = release();+ rmSync(join(cwd, 'apps/web/tauri/src-tauri/src/lib.rs'));+ version(2);+ commit();+ expect(androidReleaseDecision({ cwd, releases: [baseline] }).build).toBe(+ true+ );+ });++ it('skips net-zero native changes', () => {+ const baseline = release();+ write('apps/web/tauri/src-tauri/src/lib.rs', '// temporary');+ commit();+ write('apps/web/tauri/src-tauri/src/lib.rs', '// native');+ commit();+ expect(androidReleaseDecision({ cwd, releases: [baseline] }).build).toBe(+ false+ );+ });++ it('uses the closest ancestor regardless of API release ordering', () => {+ const old = release();+ version(2);+ commit();+ const latest = release('v2026.10.2');+ write('apps/web/src/index.tsx', '// frontend');+ commit();+ expect(androidReleaseDecision({ cwd, releases: [old, latest] })).toEqual({+ build: false,+ summary: expect.stringContaining('v2026.10.2'),+ });+ });++ it.each(['missing', 'empty', 'uploading', 'draft', 'prerelease'])(+ 'does not lose changes after a release with %s artifacts',+ (state) => {+ const baseline = release();+ version(2);+ commit();+ const failed = release('v2026.10.2');+ if (state === 'missing') failed.assets.pop();+ if (state === 'empty') failed.assets[0].size = 0;+ if (state === 'uploading') failed.assets[0].state = 'starter';+ if (state === 'draft') failed.draft = true;+ if (state === 'prerelease') failed.prerelease = true;+ write('apps/web/src/index.tsx', '// frontend');+ commit();+ expect(+ androidReleaseDecision({ cwd, releases: [failed, baseline] })+ ).toEqual({+ build: true,+ summary: expect.stringContaining('v2026.10.1'),+ });+ }+ );++ it('ignores bundles on an unrelated branch and future releases', () => {+ const baseline = release();+ git('checkout', '-b', 'other');+ version(3);+ commit();+ const unrelated = release('v2026.10.3');+ git('checkout', 'main');+ version(2);+ commit();+ const current = git('rev-parse', 'HEAD');+ version(3);+ commit();+ const future = release('v2026.10.4');+ git('checkout', '--detach', current);+ expect(+ androidReleaseDecision({ cwd, releases: [future, unrelated, baseline] })+ ).toEqual({ build: true, summary: expect.stringContaining('v2026.10.1') });+ });++ it('skips a rerun after this release already published complete artifacts', () => {+ const current = release();+ expect(androidReleaseDecision({ cwd, releases: [current] }).build).toBe(+ false+ );+ });++ it('supports annotated release tags', () => {+ const baseline = release();+ git('tag', '-d', baseline.tag_name);+ git('tag', '-a', baseline.tag_name, '-m', 'release');+ expect(androidReleaseDecision({ cwd, releases: [baseline] }).build).toBe(+ false+ );+ });++ it('fails when a published bundle tag is absent from checkout history', () => {+ const baseline = release();+ git('tag', '-d', baseline.tag_name);+ expect(() =>+ androidReleaseDecision({ cwd, releases: [baseline] })+ ).toThrow();+ });+});diff --git a/apps/web/scripts/android-release.test.ts b/apps/web/scripts/android-release.test.tsindex 89aa7881b3..cc6787f4fb 100644--- a/apps/web/scripts/android-release.test.ts+++ b/apps/web/scripts/android-release.test.ts@@ -50,7 +50,7 @@ describe('Android release versions', () => {expect(androidReleaseMetadata(tag, releaseConfig)).toEqual({version: '2.5.0',versionCode: 7,- filename: `macro-${tag}-android-arm64.apk`,+ filename: `macro-${tag}-android-arm64.aab`,});});diff --git a/apps/web/scripts/android-release.ts b/apps/web/scripts/android-release.tsindex 0f73628bef..01d09d09af 100644--- a/apps/web/scripts/android-release.ts+++ b/apps/web/scripts/android-release.ts@@ -43,7 +43,7 @@ export function androidReleaseMetadata(tag: string, config: unknown) {return {version: release.version,versionCode: release.bundle.android.versionCode,- filename: `macro-${tag}-android-arm64.apk`,+ filename: `macro-${tag}-android-arm64.aab`,};}diff --git a/apps/web/tauri/src-tauri/tauri.android.conf.json b/apps/web/tauri/src-tauri/tauri.android.conf.jsonindex e1c004e5e6..0d5c9b2d6b 100644--- a/apps/web/tauri/src-tauri/tauri.android.conf.json+++ b/apps/web/tauri/src-tauri/tauri.android.conf.json@@ -5,7 +5,7 @@"version": "2.5.0","bundle": {"android": {- "versionCode": 1+ "versionCode": 2}},"plugins": {diff --git a/docs/ANDROID_DEVELOPMENT.md b/docs/ANDROID_DEVELOPMENT.mdindex cc188a553b..5f87bb4365 100644--- a/docs/ANDROID_DEVELOPMENT.md+++ b/docs/ANDROID_DEVELOPMENT.md@@ -37,7 +37,7 @@ From `apps/web`, using an available frontend port:```shPORT=3004 just android-devjust android-build --debug --apk true --aab false-just android-build --apk true --aab true+just android-build --apk false --aab true```Development uses the deployed **dev** backend, builds required WebAssembly assets,@@ -110,7 +110,7 @@ normal debug certificate. No signing secrets belong in Gradle source or logs.For local qualification of the embedded frontend, disable OTA updates:```sh-just android-build --apk true --aab true -- --no-default-features+just android-build --apk true --aab false -- --no-default-features```This still uses production services/Firebase, release optimization, and R8.@@ -128,17 +128,30 @@ The upload certificate identifies locally signed artifacts. When Google createsthe Play App Signing key, Play-delivered APKs use that separate certificate; addits fingerprint to production associations before testing Play-installed links.-### Production release APKs+### Production release artifacts-`.github/workflows/release-production.yml` builds an ARM64 signed APK alongside-each production deployment, from the release commit. It uses production services,-the pinned production Firebase config, and the normal OTA-enabled release build.+`.github/workflows/release-production.yml` builds an ARM64 signed AAB from the+release commit only when `apps/web/tauri/` differs from the closest ancestor+release with a complete AAB, R8 mapping, and checksums. The first release without+such a baseline builds an AAB. Frontend-only releases skip native builds and Play+uploads; their app updates use the bundle updater. The comparison covers the+entire Tauri directory, including Android, iOS, Rust, and native config files.+Changes outside that directory do not trigger a native release. If an external+dependency or build-script change needs a new binary, bump the native version code+in the Tauri directory as part of that change.++Failed/incomplete artifact uploads do not advance the baseline. A rerun whose+release already has complete artifacts skips rebuilding; retry a failed Play+upload through the publishing workflow after checking Console.++The native build uses production services, the pinned production Firebase config,+and the normal OTA-enabled release build.The GitHub Actions `ANDROID_RELEASE_DOPPLER_TOKEN` secret must have read access to`android-release/prd`, including both the signing JSON and pinned Firebase secret.CI passes this dedicated read-only service token as `DOPPLER_TOKEN` only duringconfiguration retrieval. Signing files live in the runner's temporary directory-and are removed even when the build fails. Only APK/checksum files are attached-to the release; the separate `android-build-log` Actions artifact is retained for+and are removed even when the build fails. Only AAB, R8 mapping, and checksum+files are attached to the release; the separate `android-build-log` Actions artifact is retained forseven days, including on failed builds.Android's native release identity lives in@@ -149,8 +162,8 @@ counter. Local Tauri builds and CI use the same values. Release tags may beidentify source and artifact filenames, and do not determine either Androidversion field.-The first release using this counter is build **1**. Before each subsequent-native release (including a new binary with the same marketing version), run+Build **1** was the manual Play bootstrap bundle. The next native release uses+build **2**. Before each subsequent native release (including a new binary with the same marketing version), runfrom `apps/web`:```sh@@ -159,6 +172,8 @@ just android-bumpCommit the changed config before tagging the release. This increments only`versionCode`; edit `version` separately when changing the marketing version.+CI rejects native changes whose code is not greater than the last published AAB+baseline. No version bump is needed for frontend-only bundle updates.Builds never increment the counter implicitly, so retries of the same releaseretain its identity. Never distribute different releases with the same code orreuse a code already uploaded to Google Play. Keep the signing key for upgrades.@@ -180,15 +195,17 @@ so retire them rather than relying on it to exclude those test installs.When moving to Google Play, keep this same counter for AAB builds across alltracks (internal testing, closed testing, and production). Promote the sameuploaded artifact between tracks; allocate a new code for a new binary. The-existing `just android-build --aab` path uses the same Tauri config. The workflow-below still publishes APKs; Play upload, signing enrollment, and track promotion-are a separate setup. Use [Play App Signing](https://developer.android.com/studio/publish/app-signing) and preserve its app-signing key once+existing `just android-build --apk false --aab true` path uses the same Tauri config.+CI builds only the AAB; the Google Play workflow below uploads it to internal testing. Use+[Play App Signing](https://developer.android.com/studio/publish/app-signing) and+preserve its app-signing key oncePlay distribution starts; the upload key and installed-app signing key areseparate roles.-Before upload, CI verifies the signing certificate, package/version, ARM64 ABI,-non-debuggable manifest, and 16 KiB ZIP alignment. Publishing waits for the web,-cloud-storage, sync-service, and AI editing worker deployments. Android failures+Before publishing artifacts, CI verifies the signing certificate, package/version,+ARM64 ABI, and non-debuggable manifest, and checks the AAB structure+with a checksum-pinned bundletool. Publishing+waits for the web, cloud-storage, sync-service, and AI editing worker deployments. Android failuresfail their job without blocking web/backend rollout. CI verification does notreplace the device qualification described above.@@ -196,8 +213,10 @@ To recover an Android artifact without redeploying production, manually run`release-production.yml` with `release_tag` set to an existing publishedproduction release. The source is checked out from that tag; web/backend jobsare skipped. `publish_android` defaults to false so the first run can validate-the build and leave the APK in the `android-release` Actions artifact. Set it to-true to attach the verified APK and checksum to the selected release:+the build and leave the files in the `android-release` Actions artifact. Set it to+true to attach the verified artifacts and checksums to the selected release.+This explicit recovery path bypasses change detection and does not automatically+upload to Play:```shgh workflow run release-production.yml --ref main -f release_tag=v2026.9.30.0 -f publish_android=true@@ -208,12 +227,214 @@ cache mount. Do not invoke the shared `teardown-nix` cache-volume action there:its `fuser -km /nix` can kill the runner when `/nix` is on the root filesystem,preventing GitHub from receiving the build logs. Let the hosted VM be discarded.-The public GitHub release receives `macro-<tag>-android-arm64.apk` and-`macro-<tag>-android-arm64.apk.sha256`. Share the APK's release download link;-recipients do not need GitHub access. They open the downloaded APK and allow-installation from that browser/file manager when Android prompts. Subsequent-APKs install as updates when the certificate matches and the version increases.-Play Store migration must preserve app-signing compatibility with these APKs.+The public GitHub release receives `macro-<tag>-android-arm64.aab`,+`macro-<tag>-android-arm64-mapping.txt`, and a `.sha256` checksum for each.+Release CI does not build or attach APKs. Testers install through Google Play's+internal testing track after the bundle is uploaded; an AAB cannot be installed+directly on a device.++### Google Play publishing++`.github/workflows/publish-android-play.yml` runs from `main`. After a native+release has passed verification, completed backend/web rollout, and attached its+artifacts to GitHub, the production release workflow dispatches it automatically+with `operation=upload-internal` and `status=completed`. Testers receive the new+version subject to Google Play checks. Frontend-only releases do not dispatch it.+The separate workflow result reports whether the Play upload succeeded; queuing+it does not mean Play has accepted the release. Manual upload remains available+for recovery and Console-review drafts.+It downloads the verified AAB and R8 mapping from a published GitHub release,+checks their checksums, authenticates with short-lived Google credentials, and+uploads to the **internal testing** track for `com.macro.workspace.mobile`.+Its separate `promote-production` operation submits an existing tested version+for a full production rollout without rebuilding or uploading the binary again.+All Play edits use one concurrency group, including uploads and promotions.+Production promotion remains manual, after device qualification of the+Play-installed internal build. The dispatcher runs the publishing workflow on+`main` so the existing Google OIDC restrictions remain valid; its GitHub token+has `actions: write` for the workflow dispatch.++#### First bundle (one time)++The Play app must already exist, and its first AAB must be uploaded manually+before the publishing API can find the package. See the+[upload action's setup guide](https://github.com/r0adkll/upload-google-play#faq).++1. Merge the AAB build changes, then publish a release containing them. Recovery+ builds check out the selected release tag, so a tag predating+ `scripts/android-bundle.ts` cannot use the new verification step. For an older+ release, build the AAB locally from the intended source and verify it+ using the release signing procedure above.+2. Download `macro-<tag>-android-arm64.aab` and its checksum from the release (or+ from the `android-release` Actions artifact for a build-only run). Verify the+ checksum before upload.+3. In Play Console, open Macro → **Testing → Internal testing**, create a release,+ and enroll in [Play App Signing](https://developer.android.com/studio/publish/app-signing).+ Decide the installed-app signing key before enrollment: a Google-generated+ signing key differs from the existing sideloaded APK certificate. Updating+ those installs in place requires preserving their signing identity. The+ existing Doppler key remains the upload key; do not replace it for CI.+4. Upload the AAB, add release notes and testers, and complete the Console's+ required app setup. Save a draft or roll out to internal testers as permitted+ by the app's current state. The API cannot complete account agreements or+ app-content declarations for you.+5. Add the **Play app-signing** SHA-256 certificate to Firebase and the production+ App Links associations below. Test an installation from the Play opt-in link,+ including sign-in, notifications, links, and upgrades.++The first manual upload consumes its version code. For the next binary, run+`just android-bump` in `apps/web` and commit before tagging. Do not upload the+bootstrap bundle again through CI.++#### Keyless publishing credentials (one time)++Use [Workload Identity Federation through a service account](https://github.com/google-github-actions/auth#workload-identity-federation-through-a-service-account).+The workflow uses GitHub's OIDC identity, so no Google JSON private key is needed+in GitHub or Doppler. The existing Doppler token still supplies Android build+signing and Firebase configuration.++In Google Cloud project `macro-435922`, enable `androidpublisher.googleapis.com`,+`iamcredentials.googleapis.com`, and `sts.googleapis.com`. Create a dedicated+service account named `google-play-publisher`. It does not need a broad+Google Cloud project role. In **Play Console → Users and permissions**, invite+its email and grant app access only to `com.macro.workspace.mobile`, with+**View app information (read-only)**, **Release apps to testing tracks**, and+**Release to production, exclude devices, and use Play App Signing**. The last+permission is required for production promotion. No account-wide or billing+permissions are needed. See+[Google's API access instructions](https://developers.google.com/android-publisher/getting_started).++Create a GitHub Actions workload identity pool/provider. Map:++```text+google.subject=assertion.sub+attribute.repository_id=assertion.repository_id+```++Use issuer `https://token.actions.githubusercontent.com`. Restrict the provider's+attribute condition to the numeric repository and owner IDs (available from+`gh api repos/macro-inc/macro --jq '{repository: .id, owner: .owner.id}'`), the+publishing workflow on `main`, and its branch identity:++```text+assertion.repository_id == '1092407718' &&+assertion.repository_owner_id == '65687018' &&+assertion.workflow_ref == 'macro-inc/macro/.github/workflows/publish-android-play.yml@refs/heads/main' &&+assertion.sub == 'repo:macro-inc/macro:ref:refs/heads/main'+```++On the publishing service account, grant `roles/iam.workloadIdentityUser` to:++```text+principalSet://iam.googleapis.com/projects/1024168288732/locations/global/workloadIdentityPools/github-play/attribute.repository_id/1092407718+```++In GitHub → Settings → Secrets and variables → Actions → Variables, add these+**repository variables**, which contain identifiers, not secrets. The workflow+checks its branch, and the Google provider independently enforces both the branch+and workflow identity:++| Variable | Value |+| --- | --- |+| `GOOGLE_PLAY_WORKLOAD_IDENTITY_PROVIDER` | `projects/1024168288732/locations/global/workloadIdentityPools/github-play/providers/macro` |+| `GOOGLE_PLAY_SERVICE_ACCOUNT` | `[email protected]` |++For a project administrator completing the initial identity setup, these are the+commands for this repository (the publishing service account and required APIs+have already been created/enabled). Pool creation requires+`roles/iam.workloadIdentityPoolAdmin`; binding the service account also requires+permission to update that account's IAM policy. These commands create the pool+and provider once; inspect existing resources before rerunning them.++```sh+gcloud iam workload-identity-pools create github-play \+ --project=macro-435922 --location=global \+ --display-name='GitHub Play publishing'++gcloud iam workload-identity-pools providers create-oidc macro \+ --project=macro-435922 --location=global \+ --workload-identity-pool=github-play \+ --issuer-uri=https://token.actions.githubusercontent.com \+ --attribute-mapping='google.subject=assertion.sub,attribute.repository_id=assertion.repository_id' \+ --attribute-condition="assertion.repository_id == '1092407718' && assertion.repository_owner_id == '65687018' && assertion.workflow_ref == 'macro-inc/macro/.github/workflows/publish-android-play.yml@refs/heads/main' && assertion.sub == 'repo:macro-inc/macro:ref:refs/heads/main'"++gcloud iam service-accounts add-iam-policy-binding \+ --project=macro-435922 --role=roles/iam.workloadIdentityUser \+ --member='principalSet://iam.googleapis.com/projects/1024168288732/locations/global/workloadIdentityPools/github-play/attribute.repository_id/1092407718'+```++After those succeed, configure the repository variables:++```sh+gh variable set GOOGLE_PLAY_WORKLOAD_IDENTITY_PROVIDER --repo macro-inc/macro \+ --body projects/1024168288732/locations/global/workloadIdentityPools/github-play/providers/macro+gh variable set GOOGLE_PLAY_SERVICE_ACCOUNT --repo macro-inc/macro \+ --body [email protected]+```++#### Routine upload and recovery++After the first manual upload and credentials setup, native production releases+automatically upload to internal testing with `status=completed`. For a manual+upload or retry, select **Publish Android to Google Play** in Actions, run from+`main`, select `operation=upload-internal`, and supply a published release tag+that contains Android artifacts.+`status=draft` (the default) saves a release for Console review. Select+`status=completed` to release to internal testers, subject to Play's checks:++```sh+gh workflow run publish-android-play.yml --ref main \+ -f operation=upload-internal -f release_tag=v2026.10.9 -f status=completed+```++If Play specifically requires manual review submission, set+`changes_not_sent_for_review=true`, then submit in Console. This input does not+bypass review or make a draft available to testers.++If a run fails, inspect Console before retrying: a completed upload may already+have consumed the version code. Complete or promote an existing draft there+instead of re-uploading it to change status. A new binary needs a new code. Avoid+editing the same app in Console while a CI upload is in progress; committing+another edit invalidates the upload's pending edit. Missing AAB or mapping assets+must be recovered with the build workflow before publishing.++#### Promote a tested version to production++After qualifying the Play-installed internal build, manually run the same+**Publish Android to Google Play** workflow from `main` with+`operation=promote-production` and its exact Android `version_code`. Use the code+shown in Play Console; this is not the release tag or marketing version. Leave+`release_tag` empty; `status` applies only to internal uploads.++```sh+gh workflow run publish-android-play.yml --ref main \+ -f operation=promote-production -f version_code=7+```++The promotion script requires that exact version to be a completed, single-version+release currently active in `internal`. It copies its release name, notes, and+update priority into a `completed` production release, validates the edit, and+commits it. This requests a **full rollout**; Google review, production eligibility,+and managed publishing still apply. It does not change the internal track or+upload another AAB. See the [Google Play track API](https://developers.google.com/android-publisher/api-ref/rest/v3/edits.tracks).++The workflow refuses to replace a draft, staged, or halted production release,+and refuses to promote a version older than production. Resolve those states in+Play Console first. Repeating an already-completed promotion is a no-op, provided+that version is still active in internal testing. A newer internal release can+replace the earlier one, so qualify and promote a candidate before uploading the+next candidate. Staged rollouts and their progress are managed in Console.++`changes_not_sent_for_review=true` also applies to promotion if Play requires+manual review submission. Check Console after any ambiguous API failure before+retrying. Failed or no-op attempts discard their pending edit when possible;+commits are never automatically retried. The workflow summary reports submission,+not confirmation that the release is already available to users.++Promotion remains a separate manual action; building a GitHub release or uploading+to internal testing never triggers production promotion. It uses the existing+workflow identity, so no Google identity-provider changes are required.## Firebase@@ -268,7 +489,7 @@ the build before Cargo starts. Existing local config files are not a fallback:they cannot silently change which Firebase configuration a commit builds with.The config is fetched on each invocation, so the default path requires networkaccess. The lock file pins Firebase configuration, not every input needed for-byte-identical APKs; the toolchain, dependencies, frontend configuration, and+byte-identical Android artifacts; the toolchain, dependencies, frontend configuration, andrelease signing must also be supplied consistently.For CI, install the Doppler CLI and provide a read-only Doppler service token for