Skip to main content

max / goingson

3.0 KB · 96 lines History Blame Raw
1 #!/usr/bin/env bash
2 set -euo pipefail
3
4 # GoingsOn Android Release Script
5 # Builds a signed release AAB for Google Play distribution
6 #
7 # Prerequisites:
8 # - Android SDK + NDK installed (sdkmanager)
9 # - Rust Android targets (aarch64-linux-android, etc.)
10 # - Signing keystore at ~/.tauri/goingson-android.jks
11 # - key.properties in src-tauri/gen/android/
12 # - ANDROID_HOME, NDK_HOME, JAVA_HOME set
13 #
14 # Usage:
15 # ./dist/release-android.sh # build signed release AAB
16 # ./dist/release-android.sh --apk # build APK instead of AAB
17 # ./dist/release-android.sh --debug # build debug APK
18
19 cd "$(dirname "$0")/.."
20
21 # --- Configuration ---
22 ANDROID_HOME="${ANDROID_HOME:-/opt/homebrew/share/android-commandlinetools}"
23 NDK_HOME="${NDK_HOME:-$ANDROID_HOME/ndk/27.0.12077973}"
24 JAVA_HOME="${JAVA_HOME:-/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home}"
25 NDK_BIN="$NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin"
26 export ANDROID_HOME NDK_HOME JAVA_HOME
27
28 # NDK cross-compilation toolchain (needed for vendored OpenSSL)
29 export PATH="$NDK_BIN:$PATH"
30 export CC_aarch64_linux_android="$NDK_BIN/aarch64-linux-android24-clang"
31 export AR_aarch64_linux_android="$NDK_BIN/llvm-ar"
32 export RANLIB_aarch64_linux_android="$NDK_BIN/llvm-ranlib"
33
34 # --- Parse args ---
35 FORMAT="aab"
36 DEBUG=false
37 for arg in "$@"; do
38 case "$arg" in
39 --apk) FORMAT="apk" ;;
40 --debug) DEBUG=true ;;
41 -h|--help)
42 echo "Usage: $0 [--apk | --debug]"
43 echo " --apk Build APK instead of AAB"
44 echo " --debug Build debug APK"
45 exit 0
46 ;;
47 esac
48 done
49
50 # --- Read version from tauri.conf.json ---
51 VERSION=$(python3 -c "import json; print(json.load(open('src-tauri/tauri.conf.json'))['version'])")
52 echo "Version: $VERSION"
53
54 # --- Verify prerequisites ---
55 if [ ! -d "$NDK_HOME" ]; then
56 echo "Error: NDK not found at $NDK_HOME"
57 echo "Install with: sdkmanager 'ndk;27.0.12077973'"
58 exit 1
59 fi
60
61 if [ ! -f "$JAVA_HOME/bin/java" ]; then
62 echo "Error: Java not found at $JAVA_HOME"
63 echo "Install with: brew install openjdk"
64 exit 1
65 fi
66
67 # --- Build ---
68 if [ "$DEBUG" = true ]; then
69 echo ""
70 echo "=== Building Android debug APK ==="
71 cargo tauri android build --debug --target aarch64
72 echo ""
73 echo "Debug APK built. Look for output in:"
74 echo " src-tauri/gen/android/app/build/outputs/apk/universal/debug/"
75 else
76 echo ""
77 if [ "$FORMAT" = "apk" ]; then
78 echo "=== Building Android release APK ==="
79 cargo tauri android build --target aarch64 -- --apk
80 else
81 echo "=== Building Android release AAB ==="
82 cargo tauri android build --target aarch64 -- --aab
83 fi
84
85 echo ""
86 echo "Release $FORMAT built. Look for output in:"
87 if [ "$FORMAT" = "apk" ]; then
88 echo " src-tauri/gen/android/app/build/outputs/apk/universal/release/"
89 else
90 echo " src-tauri/gen/android/app/build/outputs/bundle/universalRelease/"
91 fi
92 fi
93
94 echo ""
95 echo "Done. GoingsOn Android v$VERSION ($FORMAT)"
96