Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions atak/plugin/scripts/install_device.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ set -euo pipefail

cd "$(dirname "$0")/.."

APK="$(find app/build/outputs/apk/civ/release -maxdepth 1 -name '*.apk' -print 2>/dev/null | sort | tail -n 1)"
# Pick the newest APK by modification time so a freshly-rebuilt artifact is
# preferred over a stale-but-lexicographically-later leftover (e.g. v1.2.10
# would lex-sort before v1.2.2 with the previous `sort | tail` form). `ls -t`
# is portable across macOS (BSD) and Jetson (GNU).
pick_latest_apk() {
ls -1t app/build/outputs/apk/civ/release/*.apk 2>/dev/null | head -n 1
}

APK="$(pick_latest_apk)"

if [[ -z "$APK" || ! -f "$APK" ]]; then
./scripts/build_release.sh
APK="$(find app/build/outputs/apk/civ/release -maxdepth 1 -name '*.apk' -print | sort | tail -n 1)"
APK="$(pick_latest_apk)"
fi

adb install -r "$APK"
Loading