-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild-apks.sh
More file actions
executable file
·105 lines (83 loc) · 3.47 KB
/
Copy pathbuild-apks.sh
File metadata and controls
executable file
·105 lines (83 loc) · 3.47 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env bash
set -euo pipefail
export PATH="/usr/local/bin:$PATH"
export NODE_BINARY="/usr/local/bin/node"
MODE="${1:-release}"
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
if [[ "$MODE" != "debug" && "$MODE" != "release" ]]; then
echo "Usage: bash build-apks.sh [debug|release]"
exit 1
fi
if [[ "$MODE" == "release" ]]; then
TASK="assembleRelease bundleRelease"
APK_DIR="release"
else
TASK="assembleDebug"
APK_DIR="debug"
echo "WARNING: Debug APK requires Metro server at runtime and is not for standalone emulator/device testing."
fi
echo "Building $MODE APKs for Overline apps..."
validate_google_services() {
local file_path="$1"
local package_name="$2"
node - "$file_path" "$package_name" <<'NODE'
const fs = require('fs');
const filePath = process.argv[2];
const packageName = process.argv[3];
let payload;
try {
payload = JSON.parse(fs.readFileSync(filePath, 'utf8'));
} catch (error) {
console.error(`ERROR: ${filePath} is not valid JSON`);
process.exit(1);
}
const clients = Array.isArray(payload.client) ? payload.client : [];
const appClient = clients.find((entry) => {
return entry?.client_info?.android_client_info?.package_name === packageName;
});
if (!appClient) {
console.error(`ERROR: ${filePath} does not contain package_name ${packageName}`);
process.exit(1);
}
const oauthClients = Array.isArray(appClient.oauth_client) ? appClient.oauth_client : [];
const hasAndroidOAuth = oauthClients.some((entry) => entry?.client_type === 1);
const hasWebOAuth = oauthClients.some((entry) => entry?.client_type === 3);
if (!hasAndroidOAuth) {
console.error(`ERROR: ${filePath} is missing Android OAuth client (client_type 1) for ${packageName}.`);
console.error('Google Sign-In will fail with developer_error until Firebase Android OAuth is configured with SHA fingerprints.');
process.exit(1);
}
if (!hasWebOAuth) {
console.error(`ERROR: ${filePath} is missing Web OAuth client (client_type 3) for ${packageName}.`);
process.exit(1);
}
console.log(`Verified Google OAuth config in ${filePath} for ${packageName}`);
NODE
}
if [[ ! -f "$ROOT_DIR/apps/mobile-admin/android/app/google-services.json" ]]; then
echo "ERROR: Missing file apps/mobile-admin/android/app/google-services.json"
echo "Admin APK cannot provide Google login or FCM Push Notifications without Firebase Android config."
exit 1
fi
if [[ ! -f "$ROOT_DIR/apps/mobile-user/android/app/google-services.json" ]]; then
echo "ERROR: Missing file apps/mobile-user/android/app/google-services.json"
echo "User APK cannot provide Google login or FCM Push Notifications without Firebase Android config."
exit 1
fi
validate_google_services "$ROOT_DIR/apps/mobile-admin/android/app/google-services.json" "com.overlineadmin"
validate_google_services "$ROOT_DIR/apps/mobile-user/android/app/google-services.json" "com.overlineuser"
echo "\nBuilding Admin App (mobile-admin)..."
cd "$ROOT_DIR/apps/mobile-admin/android"
./gradlew clean $TASK
echo "\nBuilding User App (mobile-user)..."
cd "$ROOT_DIR/apps/mobile-user/android"
./gradlew clean $TASK
cd "$ROOT_DIR"
echo "\nBuild completed successfully."
if [[ "$MODE" == "release" ]]; then
echo "User App AAB: apps/mobile-user/android/app/build/outputs/bundle/$APK_DIR/app-$APK_DIR.aab"
echo "Admin App AAB: apps/mobile-admin/android/app/build/outputs/bundle/$APK_DIR/app-$APK_DIR.aab"
else
echo "User App APK: apps/mobile-user/android/app/build/outputs/apk/$APK_DIR/app-$APK_DIR.apk"
echo "Admin App APK: apps/mobile-admin/android/app/build/outputs/apk/$APK_DIR/app-$APK_DIR.apk"
fi