Files
SwimBuddy/scripts/build-wearos.sh
T

62 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
# Load .env file
if [ -f "$PROJECT_ROOT/.env.local" ]; then
set -a
source "$PROJECT_ROOT/.env.local"
set +a
elif [ -f "$PROJECT_ROOT/.env" ]; then
set -a
source "$PROJECT_ROOT/.env"
set +a
fi
PROFILE="${1:-debug}"
WEAR_DIR="$PROJECT_ROOT/targets/wearos"
FIREBASE_APP_ID="${FIREBASE_WEAR_APP_ID:-}"
cd "$WEAR_DIR"
echo "Building WearOS ($PROFILE)..."
if [ "$PROFILE" = "release" ]; then
./gradlew assembleRelease
APK_PATH="app/build/outputs/apk/release/app-release.apk"
else
./gradlew assembleDebug
APK_PATH="app/build/outputs/apk/debug/app-debug.apk"
fi
if [ ! -f "$APK_PATH" ]; then
echo "Error: APK not found at $APK_PATH"
exit 1
fi
APK_SIZE=$(du -h "$APK_PATH" | cut -f1)
echo "Build complete: $APK_PATH ($APK_SIZE)"
if [ -n "$FIREBASE_APP_ID" ]; then
if ! command -v firebase &> /dev/null; then
echo "Error: firebase CLI not found. Install with: npm install -g firebase-tools"
exit 1
fi
RELEASE_NOTES="${2:-}"
CMD=(firebase appdistribution:distribute "$APK_PATH" --app "$FIREBASE_APP_ID" --groups testers)
if [ -n "$RELEASE_NOTES" ]; then
CMD+=(--release-notes "$RELEASE_NOTES")
fi
echo "Uploading to Firebase App Distribution..."
"${CMD[@]}"
echo "Upload complete"
else
echo "Set FIREBASE_WEAR_APP_ID to upload to Firebase App Distribution"
echo " export FIREBASE_WEAR_APP_ID=1:123456789:android:abc123"
fi