Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

build(mobile): support secure local Play builds

tianma-if5edcf0eb0e57
diff --git a/.env.android.local.example b/.env.android.local.example
new file mode 100644
index 00000000..e3e2cfbf
--- /dev/null
+++ b/.env.android.local.example
@@ -0,0 +1,9 @@
+# Absolute path to the existing Google Play upload key. Keep the key outside
+# the repository and never commit the populated .env.android.local file.
+ANDROID_KEYSTORE_FILE=/Users/your-name/.config/edgeever/android/edgeever-upload.p12
+ANDROID_KEYSTORE_PASSWORD=
+ANDROID_KEY_ALIAS=
+ANDROID_KEY_PASSWORD=
+
+# Optional. The default includes all Play-supported Android architectures.
+EDGE_EVER_ANDROID_ARCHS=armeabi-v7a,arm64-v8a,x86,x86_64
diff --git a/.github/workflows/recover-android-signing.yml b/.github/workflows/recover-android-signing.yml
new file mode 100644
index 00000000..cac18c79
--- /dev/null
+++ b/.github/workflows/recover-android-signing.yml
@@ -0,0 +1,76 @@
+name: Recover Android signing material
+
+on:
+ workflow_dispatch:
+ inputs:
+ recovery_certificate_base64:
+ description: Base64-encoded one-time X.509 recovery certificate
+ required: true
+ type: string
+
+permissions:
+ contents: read
+
+jobs:
+ recover:
+ if: github.repository == 'tianma-if/edgeever'
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ steps:
+ - name: Encrypt signing material for the release Mac
+ env:
+ ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
+ ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
+ ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
+ ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
+ RECOVERY_CERTIFICATE_BASE64: ${{ inputs.recovery_certificate_base64 }}
+ run: |
+ set -euo pipefail
+ umask 077
+ recovery_dir="$RUNNER_TEMP/edgeever-signing-recovery"
+ mkdir -p "$recovery_dir"
+
+ test -n "$ANDROID_KEYSTORE_BASE64"
+ test -n "$ANDROID_KEYSTORE_PASSWORD"
+ test -n "$ANDROID_KEY_ALIAS"
+ test -n "$ANDROID_KEY_PASSWORD"
+ test -n "$RECOVERY_CERTIFICATE_BASE64"
+
+ printf '%s' "$ANDROID_KEYSTORE_BASE64" | openssl base64 -d -A > "$recovery_dir/edgeever-upload.p12"
+ printf '%s' "$RECOVERY_CERTIFICATE_BASE64" | openssl base64 -d -A > "$RUNNER_TEMP/recovery-certificate.pem"
+
+ keytool -list \
+ -keystore "$recovery_dir/edgeever-upload.p12" \
+ -storepass "$ANDROID_KEYSTORE_PASSWORD" \
+ -alias "$ANDROID_KEY_ALIAS" >/dev/null
+
+ RECOVERY_DIR="$recovery_dir" node <<'NODE'
+ const fs = require("node:fs");
+ const path = require("node:path");
+ const target = "/Users/tianma/.config/edgeever/android/edgeever-upload.p12";
+ const values = [
+ ["ANDROID_KEYSTORE_FILE", target],
+ ["ANDROID_KEYSTORE_PASSWORD", process.env.ANDROID_KEYSTORE_PASSWORD],
+ ["ANDROID_KEY_ALIAS", process.env.ANDROID_KEY_ALIAS],
+ ["ANDROID_KEY_PASSWORD", process.env.ANDROID_KEY_PASSWORD],
+ ["EDGE_EVER_ANDROID_ARCHS", "armeabi-v7a,arm64-v8a,x86,x86_64"],
+ ];
+ const contents = values.map(([key, value]) => `${key}=${JSON.stringify(value)}`).join("\n") + "\n";
+ fs.writeFileSync(path.join(process.env.RECOVERY_DIR, "signing.env"), contents, { mode: 0o600 });
+ NODE
+
+ tar -C "$recovery_dir" -czf "$RUNNER_TEMP/edgeever-android-signing.tar.gz" edgeever-upload.p12 signing.env
+ openssl cms -encrypt -binary -aes256 \
+ -in "$RUNNER_TEMP/edgeever-android-signing.tar.gz" \
+ -out "$RUNNER_TEMP/edgeever-android-signing.cms" \
+ -outform DER \
+ "$RUNNER_TEMP/recovery-certificate.pem"
+
+ - name: Upload encrypted recovery package
+ uses: actions/upload-artifact@v7
+ with:
+ name: edgeever-android-signing-recovery
+ path: ${{ runner.temp }}/edgeever-android-signing.cms
+ if-no-files-found: error
+ retention-days: 1
+ compression-level: 0
diff --git a/.gitignore b/.gitignore
index 3375b2aa..59173c40 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
.env.*
!.env.example
!.env.local.example
+!.env.android.local.example
node_modules/
dist/
diff --git a/docs/mobile-build.md b/docs/mobile-build.md
index 7b1aae1e..a442b395 100644
--- a/docs/mobile-build.md
+++ b/docs/mobile-build.md
@@ -21,6 +21,42 @@ The APK is uploaded as a GitHub Actions artifact named `edgeever-android-debug-a
## Release Builds
+### Recommended local Play build
+
+Routine Google Play bundles should be built on the release Mac instead of in
+GitHub Actions. Keep the upload keystore and signing environment outside the
+repository:
+
+```sh
+mkdir -p "$HOME/.config/edgeever/android"
+cp .env.android.local.example "$HOME/.config/edgeever/android/signing.env"
+chmod 600 "$HOME/.config/edgeever/android/signing.env"
+```
+
+Fill in the existing upload key's absolute path and credentials. Android
+keystore formats and local environment files are ignored by Git.
+
+```sh
+bun run build:android:play:local
+```
+
+This produces:
+
+```text
+apps/mobile/android/app/build/outputs/bundle/release/app-release.aab
+apps/mobile/android/app/build/outputs/mapping/release/mapping.txt
+```
+
+The command builds all Play-supported Android architectures by default,
+verifies the AAB signature, and requires a non-empty R8 mapping file. Keep an
+encrypted backup of `signing.env` and the upload keystore outside the
+repository. Do not replace or regenerate the upload key for an existing Play
+app unless the key reset has been completed in Play Console.
+
+Set `EDGE_EVER_ANDROID_ENV_FILE` to use a different secure environment file.
+
+### GitHub Actions fallback
+
Run the workflow manually to build a signed Android App Bundle. The workflow
uses the following GitHub Actions secrets:
diff --git a/package.json b/package.json
index fc5f594e..c61d12a0 100644
--- a/package.json
+++ b/package.json
@@ -18,6 +18,7 @@
"dev:mobile": "bun --cwd apps/mobile expo start",
"build:android:fast": "bash scripts/build-android-local.sh fast",
"build:android:play": "bash scripts/build-android-local.sh play",
+ "build:android:play:local": "bun --env-file=${EDGE_EVER_ANDROID_ENV_FILE:-$HOME/.config/edgeever/android/signing.env} run build:android:play",
"dev:site": "bun --cwd apps/site dev",
"build": "bun run build:web",
"build:extension": "vite build --config apps/extension/vite.config.ts",