#!/usr/bin/env bash # # Build a signed Android App Bundle for the Google Play internal testing track. # # Usage: # scripts/build-release-aab.sh [versionCode] [versionName] # # Signing values are read by Gradle from the environment or local.properties: # UPLOAD_STORE_FILE absolute path to the upload keystore # UPLOAD_STORE_PASSWORD # UPLOAD_KEY_ALIAS # UPLOAD_KEY_PASSWORD # # Play requires a versionCode that is higher than every previous upload. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$ROOT" GRADLE="${GRADLE:-gradle}" AAB="composeApp/build/outputs/bundle/release/composeApp-release.aab" prop() { local key="$1" [ -f local.properties ] || return 0 grep -E "^${key}=" local.properties | tail -1 | cut -d= -f2- } if [ -z "${ANDROID_KEYSTORE_PATH:-}" ] && [ -z "$(prop UPLOAD_STORE_FILE)" ]; then echo "No upload key configured: set UPLOAD_STORE_FILE in local.properties" >&2 echo "or ANDROID_KEYSTORE_PATH in the environment." >&2 exit 1 fi VERSION_CODE="${1:-${VERSION_CODE:-$(prop VERSION_CODE)}}" VERSION_NAME="${2:-${VERSION_NAME:-$(prop VERSION_NAME)}}" VERSION_CODE="${VERSION_CODE:-1}" VERSION_NAME="${VERSION_NAME:-0.1.0}" export VERSION_CODE VERSION_NAME export ANDROID_HOME="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-$HOME/Android/Sdk}}" echo "Building AAB versionCode=$VERSION_CODE versionName=$VERSION_NAME" "$GRADLE" :composeApp:bundleRelease --console=plain if ! jarsigner -verify "$AAB" >/dev/null 2>&1; then echo "AAB is not signed; check the upload keystore settings." >&2 exit 1 fi echo echo "Signed bundle: $ROOT/$AAB" sha256sum "$AAB" echo echo "Upload it to Play Console > Testing > Internal testing > Create new release."