Files
cardclaws/cardclaws-mobile/scripts/build-release-apk.sh
T
Omar SobhandClaude Opus 4.8 eddca62f23
CI / policy (push) Successful in 5s
CI / profile (push) Successful in 11s
CI / mobile (push) Successful in 16s
CI / backend (push) Failing after 1m7s
Mobile: standalone signed release APK build (config plugin + script)
- plugins/withReleaseSigning.js — Expo config plugin that injects a release
  signingConfig into android/app/build.gradle at prebuild, reading credentials
  from credentials/keystore.properties (gitignored). Survives CNG regeneration.
- scripts/build-release-apk.sh — generate keystore (once) → prebuild → build →
  install → emit a shareable cardclaws-demo.apk
- .gitignore: exclude /credentials, *.keystore, *.apk (no secrets/binaries)

Produces a standalone APK with the JS bundle embedded — runs with no Metro, no
laptop, no Wi-Fi. Built, signed, installed, and verified running on a physical
device with Metro stopped + the USB route removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-04 18:11:36 -05:00

43 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build a standalone, signed release APK (JS bundled in — runs with no Metro,
# no laptop). Reproducible: the release signing config is injected at prebuild
# by plugins/withReleaseSigning.js, which reads credentials/keystore.properties.
#
# Usage:
# JAVA_HOME=$(/usr/libexec/java_home -v 17) ./scripts/build-release-apk.sh
#
# Override the (demo) keystore password via KEYSTORE_PASSWORD if you like.
set -euo pipefail
cd "$(dirname "$0")/.."
PASS="${KEYSTORE_PASSWORD:-cardclaws-demo}"
KS="$(pwd)/credentials/cardclaws-release.keystore"
# 1) Create the release keystore once (gitignored).
if [ ! -f "$KS" ]; then
echo "Generating release keystore…"
mkdir -p credentials
keytool -genkeypair -v -keystore "$KS" -alias cardclaws \
-keyalg RSA -keysize 2048 -validity 10000 \
-storepass "$PASS" -keypass "$PASS" \
-dname "CN=CardClaws, O=RedClaw Systems LLC, C=US"
cat > credentials/keystore.properties <<EOF
storeFile=$KS
storePassword=$PASS
keyAlias=cardclaws
keyPassword=$PASS
EOF
fi
# 2) Regenerate native project (applies the signing config plugin).
npx expo prebuild --platform android --clean --no-install
# 3) Build + install the signed release APK to the connected device.
npx expo run:android --variant release
APK="android/app/build/outputs/apk/release/app-release.apk"
if [ -f "$APK" ]; then
cp "$APK" cardclaws-demo.apk
echo "Standalone APK: $(pwd)/cardclaws-demo.apk"
fi