2026-06-19 17:46:41 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
#
|
|
|
|
|
# Build the Android companion app and publish it as the served download
|
2026-06-23 09:40:34 +01:00
|
|
|
# (neode-ui/public/packages/archipelago-companion.apk — a plain APK a phone can
|
|
|
|
|
# install straight from the link), then commit + push.
|
2026-06-19 17:46:41 +01:00
|
|
|
#
|
|
|
|
|
# Use this INSTEAD of `git push` when shipping the companion app, so the
|
|
|
|
|
# downloadable APK on the node always matches what's on main.
|
|
|
|
|
#
|
|
|
|
|
# ./Android/ship-companion.sh
|
|
|
|
|
#
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
|
|
|
cd "$ROOT"
|
|
|
|
|
|
|
|
|
|
export JAVA_HOME="${JAVA_HOME:-/opt/homebrew/opt/openjdk@17}"
|
|
|
|
|
export ANDROID_HOME="${ANDROID_HOME:-$HOME/Library/Android/sdk}"
|
|
|
|
|
|
|
|
|
|
APK="Android/app/build/outputs/apk/debug/app-debug.apk"
|
2026-06-23 09:40:34 +01:00
|
|
|
DEST="neode-ui/public/packages/archipelago-companion.apk"
|
|
|
|
|
OLD_ZIP="neode-ui/public/packages/archipelago-companion.apk.zip"
|
2026-06-19 17:46:41 +01:00
|
|
|
|
|
|
|
|
echo "==> Building debug APK"
|
|
|
|
|
( cd Android && ./gradlew :app:assembleDebug --console=plain -q )
|
|
|
|
|
[ -f "$APK" ] || { echo "ERROR: APK not found at $APK" >&2; exit 1; }
|
|
|
|
|
|
|
|
|
|
echo "==> Publishing -> $DEST"
|
|
|
|
|
mkdir -p "$(dirname "$DEST")"
|
2026-06-23 09:40:34 +01:00
|
|
|
cp "$APK" "$DEST"
|
|
|
|
|
# Drop the legacy zipped artifact so the served download is the raw APK only.
|
|
|
|
|
if [ -f "$OLD_ZIP" ]; then
|
|
|
|
|
git rm -q --ignore-unmatch "$OLD_ZIP" 2>/dev/null || rm -f "$OLD_ZIP"
|
|
|
|
|
fi
|
2026-06-19 17:46:41 +01:00
|
|
|
|
|
|
|
|
git add "$DEST"
|
|
|
|
|
if git diff --cached --quiet; then
|
|
|
|
|
echo "==> Nothing to commit (working tree + APK unchanged)"
|
|
|
|
|
else
|
|
|
|
|
git commit -q -m "chore(android): update companion apk download"
|
|
|
|
|
echo "==> Committed"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "==> Pushing $(git branch --show-current)"
|
|
|
|
|
# SHIP_COMPANION lets the pre-push guard know the APK was just refreshed.
|
|
|
|
|
SHIP_COMPANION=1 git push origin "$(git branch --show-current)"
|
|
|
|
|
echo "==> Done — companion APK published and pushed."
|