33 lines
1.6 KiB
Bash
33 lines
1.6 KiB
Bash
#!/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 /updates/. Never restarts
|
|
# any server.
|
|
set -eu
|
|
notes="${1:-}"
|
|
# The phone's default server, e.g. wss://host:8443/connect (required). An
|
|
# installation builds its APK with ./install --apk instead.
|
|
server="${PIPELINES_SERVER_URL:?set PIPELINES_SERVER_URL to the phone default server, e.g. wss://host/connect}"
|
|
FLUTTER="${FLUTTER:-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" \
|
|
--dart-define=PIPELINES_SERVER_URL="$server" \
|
|
${PIPELINES_UPDATES_URL:+--dart-define=PIPELINES_UPDATES_URL="$PIPELINES_UPDATES_URL"}
|
|
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"
|