From 07b611d07d1a1e28daebc0f8b7765bc05ef97dc5 Mon Sep 17 00:00:00 2001 From: Dorian Date: Fri, 19 Jun 2026 17:53:38 +0100 Subject: [PATCH] chore(android): add companion APK auto-publish hook + script scripts/publish-companion-apk.sh builds the debug APK and refreshes the served download neode-ui/public/packages/archipelago-companion.apk.zip; .githooks/pre-push runs it on every push to main that touches Android. Enable per clone with git config core.hooksPath .githooks Co-Authored-By: Claude Opus 4.8 (1M context) --- .githooks/pre-push | 48 ++++++++++++++++++ .../packages/archipelago-companion.apk.zip | Bin 17441676 -> 17441624 bytes scripts/publish-companion-apk.sh | 35 +++++++++++++ 3 files changed, 83 insertions(+) create mode 100755 .githooks/pre-push create mode 100755 scripts/publish-companion-apk.sh diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100755 index 00000000..973aa11a --- /dev/null +++ b/.githooks/pre-push @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# Keep the served companion APK in sync with main on every push. +# +# When a push to main includes Android changes, rebuild the APK, refresh +# neode-ui/public/packages/archipelago-companion.apk.zip, commit it, and ask +# you to push again (so the refreshed APK rides along in the same push). +# +# Enable once per clone: git config core.hooksPath .githooks +set -euo pipefail + +ROOT="$(git rev-parse --show-toplevel)" +cd "$ROOT" + +PUSH_MAIN=0; RANGE_OLD=""; RANGE_NEW="" +while read -r _local_ref local_sha remote_ref remote_sha; do + if [ "${remote_ref##*/}" = "main" ]; then + PUSH_MAIN=1; RANGE_OLD="$remote_sha"; RANGE_NEW="$local_sha" + fi +done +[ "$PUSH_MAIN" = "1" ] || exit 0 + +# Loop-break: if the tip is already the auto APK commit, let the push proceed. +case "$(git log -1 --pretty=%s)" in + *"companion APK"*) exit 0 ;; +esac + +# Only rebuild when this push actually touches the Android app. +ZEROS="0000000000000000000000000000000000000000" +if [ -z "$RANGE_OLD" ] || [ "$RANGE_OLD" = "$ZEROS" ]; then + ANDROID_CHANGED=1 +elif git diff --quiet "$RANGE_OLD" "$RANGE_NEW" -- Android/ 2>/dev/null; then + ANDROID_CHANGED=0 +else + ANDROID_CHANGED=1 +fi +[ "$ANDROID_CHANGED" = "1" ] || exit 0 + +bash scripts/publish-companion-apk.sh || exit 0 + +DEST="neode-ui/public/packages/archipelago-companion.apk.zip" +if git diff --cached --quiet -- "$DEST"; then + exit 0 # APK unchanged — nothing to do +fi + +git commit -q -m "chore(android): update companion APK download [skip ci]" +echo "" >&2 +echo "▶ Companion APK rebuilt and committed. Run your push again to include it." >&2 +exit 1 diff --git a/neode-ui/public/packages/archipelago-companion.apk.zip b/neode-ui/public/packages/archipelago-companion.apk.zip index 248894dd5392aa30d9b4f8ee10fc6a5adbc978aa..e8e0e97d854e93590deba905d6f26768784cdfd3 100644 GIT binary patch delta 934 zcmZwGX_VCi7{~GZpXJ^=H-nf|G-%2?O(lsM6soTbnQSGcX0)iND@{a}iLXkFHMFQ` z%GedM6;Vw}3r5poij)j(mTX!7<6Y-?p7S}sbDnq4i{Hc*X`2su)+q@Ell^`(I{l%wSsX(ZWltQ;rDOJm8ACel<+kQ3!3IayATQzciL zNuD&97Sd8qlU8!Nw3aiZjhrcGNn2?r`Es_LBj-wc=^*FH`Er4DlupuF!ly2jE^?6+ z$i;Grbd^h`P`b%wa=Ba~SISk=U3$pX(o?RHUea5xl|Ir}ilkVslYY`)2FO6UUIxiv z86r2xjWSe*Nm6c-;c~N#kP;awx5%wBN^XmL!rHF6)lpG-pM!4xqjF4T!}5qcDv!x9d0d9e z2+5HrWTcD|WweZuCuOWWB~QyZ$(3hhyiAaZGD#-Ovob}d$~1XSo|hM7y3CN7GD}{R zm*i!6MP8NJ@|wIZZ%CfJDRbm4d0XbnJb6dnmHDzj7Rn-dPZrA(St`q9xvY?tvPxFV z8d)prWWBsEAIJvTD4S%nd?;IFt89~x&2 + echo " (set JAVA_HOME and ANDROID_HOME to build the companion APK)" >&2 + exit 0 +fi + +echo "publish-companion-apk: building debug APK…" >&2 +( cd Android && JAVA_HOME="$JAVA" ANDROID_HOME="$SDK" ./gradlew -q :app:assembleDebug ) + +APK="Android/app/build/outputs/apk/debug/app-debug.apk" +DEST="neode-ui/public/packages/archipelago-companion.apk.zip" +mkdir -p "$(dirname "$DEST")" + +TMP="$(mktemp -d)" +cp "$APK" "$TMP/app-debug.apk" +# -X drops platform-specific extra fields for a stabler archive. +( cd "$TMP" && zip -q -X archipelago-companion.apk.zip app-debug.apk ) +cp "$TMP/archipelago-companion.apk.zip" "$DEST" +rm -rf "$TMP" + +git add "$DEST" +echo "publish-companion-apk: staged $DEST" >&2