-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·141 lines (121 loc) · 3.81 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·141 lines (121 loc) · 3.81 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
source scripts/select.sh
selected_item=0
menu_items=("Testing" "Github" "Store")
title="Select a build type (arrow keys to select, enter to confirm):"
if [ -z "$1" ]; then
run_menu "$title" "$selected_item" "${menu_items[@]}"
menu_result="$?"
else
case "$1" in
"testing" | "test" | "debug")
menu_result=0
;;
"github" | "gh")
menu_result=1
;;
"store" | "release")
menu_result=2
;;
*)
echo "Invalid option: $1" >&2
exit 1
;;
esac
fi
echo
build_arg="LS_IS_TESTING=true"
build_desc="Testing"
build_modes=("apk --split-per-abi")
build_extras="--dart-define-from-file=./config/secrets.json"
suffix="test"
case "$menu_result"
in
0)
build_arg="LS_IS_TESTING=true"
build_desc="Testing"
build_modes=("apk --split-per-abi")
suffix="test"
;;
1)
build_arg="LS_IS_STORE=false"
build_desc="Github"
build_modes=("apk --split-per-abi")
suffix="github"
;;
2)
build_arg="LS_IS_STORE=true"
build_desc="Store"
build_modes=("appbundle" "apk")
suffix="store"
;;
esac
clear
echo "Doing a ["$build_desc"] build"
# Generate empty secret vars config if it's not there
sh gen_config.sh
# Prefer the project-pinned FVM SDK, then fall back to fvm/global flutter.
if [ -x "./.fvm/flutter_sdk/bin/flutter" ]; then
flutter_cmd="./.fvm/flutter_sdk/bin/flutter"
elif command -v fvm &> /dev/null; then
flutter_cmd="fvm flutter"
else
flutter_cmd="flutter"
fi
if ! $flutter_cmd pub get ; then
echo "Build failed"
exit 1
fi
for mode in "${build_modes[@]}"; do
echo "Running [flutter build $mode --release --dart-define=$build_arg $build_extras]"
if $flutter_cmd build $mode --release --dart-define=$build_arg $build_extras ; then
echo "Build succeeded: $mode"
else
echo "Build failed: $mode"
exit 1
fi
done
get_version_and_build() {
version_and_build=$(grep "version:" pubspec.yaml | awk '{print $2}')
IFS='+' read -ra version_build_array <<< "$version_and_build"
version="${version_build_array[0]}"
build="${version_build_array[1]}"
}
get_version_and_build
has_build_mode() {
local expected="$1"
local mode
for mode in "${build_modes[@]}"; do
if [ "$mode" = "$expected" ]; then
return 0
fi
done
return 1
}
if has_build_mode "appbundle"; then
src_aab="build/app/outputs/bundle/release/app-release.aab"
dest_aab="build/app/outputs/bundle/release/LoliSnatcher_${version}_${build}_appbundle_${suffix}.aab"
cp "$src_aab" "$dest_aab"
echo
echo "=> Built AAB: LoliSnatcher_${version}_${build}_appbundle_${suffix}.aab"
fi
if has_build_mode "apk --split-per-abi"; then
srcv8_apk="build/app/outputs/flutter-apk/app-arm64-v8a-release.apk"
destv8_apk="build/app/outputs/flutter-apk/LoliSnatcher_${version}_${build}_arm64-v8a_${suffix}.apk"
cp "$srcv8_apk" "$destv8_apk"
srcv7_apk="build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk"
destv7_apk="build/app/outputs/flutter-apk/LoliSnatcher_${version}_${build}_armeabi-v7a_${suffix}.apk"
cp "$srcv7_apk" "$destv7_apk"
src64_apk="build/app/outputs/flutter-apk/app-x86_64-release.apk"
dest64_apk="build/app/outputs/flutter-apk/LoliSnatcher_${version}_${build}_x86_64_${suffix}.apk"
cp "$src64_apk" "$dest64_apk"
echo
echo "=> Built APKs: LoliSnatcher_${version}_${build}_[arch]_${suffix}.apk"
fi
if has_build_mode "apk"; then
src_apk="build/app/outputs/flutter-apk/app-release.apk"
dest_apk="build/app/outputs/flutter-apk/LoliSnatcher_${version}_${build}_${suffix}.apk"
cp "$src_apk" "$dest_apk"
echo
echo "=> Built APK: LoliSnatcher_${version}_${build}_${suffix}.apk"
fi