-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathappbundle.sh
executable file
·38 lines (32 loc) · 1.15 KB
/
appbundle.sh
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
#!/bin/bash
# Check if the flavor argument is provided
if [ $# -eq 0 ]; then
echo "Usage: $0 <flavor>"
exit 1
fi
# Get the flavor argument
FLAVOR=$1
version=$(head -n 5 pubspec.yaml | tail -n 1 | cut -d ' ' -f 2)
appname=$(head -n 1 pubspec.yaml | cut -d ' ' -f 2)
echo "Building $appname version $version for $FLAVOR"
# Run the Flutter command based on the flavor
case $FLAVOR in
dev)
flutter build appbundle --release --flavor dev --dart-define-from-file env/dev.json
mv "build/app/outputs/bundle/devRelease/app-dev-release.aab" "build/app/outputs/bundle/devRelease/$appname-$version-dev.aab"
;;
prod)
# Check that REVENUECAT_GOOGLE_API_KEY is provided in env/prod.json
API_KEY=$(jq -r '.REVENUECAT_GOOGLE_API_KEY' env/prod.json)
if [ -z "$API_KEY" ]; then
echo "Error: REVENUECAT_GOOGLE_API_KEY is empty in env/prod.json"
exit 1
fi
flutter build appbundle --release --flavor prod --dart-define-from-file env/prod.json
mv "build/app/outputs/bundle/prodRelease/app-prod-release.aab" "build/app/outputs/bundle/prodRelease/$appname-$version.aab"
;;
*)
echo "Invalid flavor provided"
exit 1
;;
esac