Repository navigation
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·44 lines (38 loc) · 1.41 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·44 lines (38 loc) · 1.41 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
#!/usr/bin/env bash
# pulse deploy: refresh the upstream diff, commit, push to github.
# usage: ./deploy.sh "commit message" (message defaults to "deploy")
# SKIP_BUILD=1 ./deploy.sh "..." to skip the build check
set -e
cd "$(dirname "$0")"
MSG="${1:-deploy}"
OUT=pulse-vs-gadgetbridge.diff
# upstream tip we track - our syncs squash upstream in, so merge-base points at the
# ancient 2017 fork point rather than the sync point and must not be used here
BASE=$(git rev-parse upstream/master 2>/dev/null || echo 79ad5a6)
if [ -z "$SKIP_BUILD" ]; then
echo "building…"
JAVA_HOME="${JAVA_HOME:-$HOME/dev/android-toolchain/jdk17}" \
./gradlew :app:assembleMainlineDebug --no-daemon -q
fi
# stage everything except the diff (it's regenerated below)
git add -A -- . ":(exclude)$OUT"
committed=0
if ! git diff --cached --quiet; then
git commit -q -m "$MSG"
committed=1
fi
# regenerate the full diff vs upstream (excluding the diff file itself)
{
echo "### pulse vs upstream gadgetbridge (base $BASE)"
echo "### generated $(date -u +%Y-%m-%dT%H:%MZ)"
echo
git diff "$BASE"..HEAD -- . ":(exclude)$OUT"
} > "$OUT"
git add "$OUT"
if [ "$committed" = 1 ]; then
git commit -q --amend --no-edit # fold the refreshed diff into this deploy
elif ! git diff --cached --quiet; then
git commit -q -m "refresh diff"
fi
git push origin main
echo "deployed: $(git rev-parse --short HEAD)"