feat(app): Check for updates downloads the server's newest APK and opens the installer

This commit is contained in:
2026-10-23 19:59:03 +01:00
parent 72e01471ab
commit 6152292aff
11 changed files with 523 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
#!/bin/sh
# Builds the Android app and offers it to phones through Check for updates.
#
# Usage (from app/ on main): sh tool/publish_apk.sh ["notes"]
# The build number is minutes since the epoch, so every build is newer than
# the last. The APK and version.json go to build/updates/ (kept across preview
# publishes) and are copied into the live preview at build/web/updates/,
# served behind the web login at https://<host>:8096/updates/. Never restarts
# any server.
set -eu
notes="${1:-}"
FLUTTER="${FLUTTER:-/Users/alan/development/flutter/bin/flutter}"
export JAVA_HOME="${JAVA_HOME:-/Applications/Android Studio.app/Contents/jbr/Contents/Home}"
export ANDROID_HOME="${ANDROID_HOME:-$HOME/Library/Android/sdk}"
code=$(( $(date +%s) / 60 ))
name="0.1.$code"
"$FLUTTER" build apk --release --build-number="$code" --build-name="$name"
mkdir -p build/updates
cp build/app/outputs/flutter-apk/app-release.apk build/updates/pipelines.apk
cat > build/updates/version.json <<JSON
{"versionCode": $code, "versionName": "$name", "apk": "pipelines.apk", "notes": "$notes"}
JSON
if [ -d build/web ]; then
rm -rf build/web/updates
cp -R build/updates build/web/updates
fi
echo "APK $code $(shasum build/updates/pipelines.apk | cut -c1-8) $(pwd)/build/updates/pipelines.apk"
+2
View File
@@ -13,5 +13,7 @@ FLUTTER="${FLUTTER:-/Users/alan/development/flutter/bin/flutter}"
rollback="build/web-before-${name}-$(date +%s)"
if [ -d build/web ]; then mv build/web "$rollback"; fi
mv build/web-next build/web
# Keep the phone builds offered by Check for updates (tool/publish_apk.sh).
if [ -d build/updates ]; then cp -R build/updates build/web/updates; fi
echo "ROLLBACK $rollback"
echo "JS $(shasum build/web/main.dart.js | cut -c1-8)"