Files
OrbitTv/tools/make-build-folder.sh
pauljdandClaude Opus 5.5 5cc331ecb7
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 2m51s
release-gate / verify (push) Successful in 14m47s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 2m52s
make-build-folder: read the version without a broken pipe
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 00:31:32 +00:00

36 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# After tools/verify.sh passes: puts the household build in ~/Documents/OrbitTV/outputs/<name>/ with a BUILD.txt that the
# signing script (tools/sign-household.sh, copied to outputs/sign.sh) reads. Nothing is signed or installed here.
#
# bash tools/make-build-folder.sh 1.0-rc1 "What changed, in one line"
set -euo pipefail
NAME=${1:?a build name, such as 1.0-rc1}
CHANGES=${2:?one line on what changed}
ROOT=$(cd "$(dirname "$0")/.." && pwd)
OUTPUTS=${ORBIT_OUTPUTS:-$HOME/Documents/OrbitTV/outputs}
APK=$ROOT/android/app/build/outputs/apk/household/release/app-household-release-unsigned.apk
[ -f "$APK" ] || { echo "No household release build: run tools/verify.sh first."; exit 1; }
[ -z "$(git -C "$ROOT" status --porcelain -- android)" ] || { echo "android/ has uncommitted changes: commit first, so the build matches a commit."; exit 1; }
BT=$(ls -d /opt/android-sdk/build-tools/* | sort -V | tail -1)
DIR=$OUTPUTS/$NAME
[ ! -e "$DIR" ] || { echo "$DIR already exists."; exit 1; }
mkdir -p "$DIR"
UNSIGNED=orbit-$NAME-aligned-unsigned.apk
"$BT/zipalign" -f -p 4 "$APK" "$DIR/$UNSIGNED"
BADGING=$("$BT/aapt2" dump badging "$DIR/$UNSIGNED" 2>/dev/null | grep -m1 "^package:" || true)
VERSION=$(sed -E "s/.*versionName='([^']*)'.*/\1/" <<<"$BADGING"); CODE=$(sed -E "s/.*versionCode='([^']*)'.*/\1/" <<<"$BADGING")
cat > "$DIR/BUILD.txt" <<EOF
name=$NAME
version=$VERSION
code=$CODE
commit=$(git -C "$ROOT" log -1 --format='%h %s')
made=$(date -u +%Y-%m-%dT%H:%M:%SZ)
changes=$CHANGES
unsigned=$UNSIGNED
signed=orbit-$NAME-household-signed.apk
sha256=$(sha256sum "$DIR/$UNSIGNED" | cut -d' ' -f1)
EOF
cp "$ROOT/tools/sign-household.sh" "$OUTPUTS/sign.sh"
echo "Ready to sign: $DIR"
echo " bash $OUTPUTS/sign.sh /dev/shm/note.asc"