-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreinstall.sh
More file actions
executable file
·48 lines (39 loc) · 1.05 KB
/
Copy pathreinstall.sh
File metadata and controls
executable file
·48 lines (39 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
# reinstall.sh - Downloads the latest successful build artifact and reinstalls the app via adb.
REPO="c0dev0id/andRemote2"
WORKFLOW="build.yml"
ARTIFACT_NAME="app-debug"
APK_FILE="app-debug.apk"
PACKAGE_ID="de.codevoid.andremote2"
WORK_DIR=$(mktemp -d)
cleanup() {
rm -rf "$WORK_DIR"
}
trap cleanup EXIT
echo "Finding latest successful build run..."
RUN_ID=$(gh run list \
--repo "$REPO" \
--workflow "$WORKFLOW" \
--status success \
--limit 1 \
--json databaseId \
--jq '.[0].databaseId')
if [ -z "$RUN_ID" ] || [ "$RUN_ID" = "null" ]; then
echo "Error: No successful workflow runs found." >&2
exit 1
fi
echo "Downloading artifact from run $RUN_ID..."
gh run download \
--repo "$REPO" \
--name "$ARTIFACT_NAME" \
--dir "$WORK_DIR" \
"$RUN_ID"
if [ ! -f "$WORK_DIR/$APK_FILE" ]; then
echo "Error: APK file not found after download." >&2
exit 1
fi
echo "Uninstalling old version..."
adb uninstall "$PACKAGE_ID" || true
echo "Installing new version..."
adb install "$WORK_DIR/$APK_FILE"
echo "Done."