-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-android.sh
executable file
·68 lines (56 loc) · 3.03 KB
/
build-android.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
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
# Ensure on each release you have updated android/app/build.gradle (and possibly android/app/src/main/AndroidManifest.xml ??):
# versionCode 1
# versionName "1.0"
# versionCode is an integer which Google Playstore recognises and does not allow to upload another APK having the same value. Just think of this as build number.
# versionName is the version number of your application and visible in Google Play Store. Can use server format.
# See https://saumya.github.io/ray/articles/72/
ENV=$1
if [ "$ENV" == "" ]; then
echo ""
echo Select Build Type:
echo Enter [d]evelop \(default\), [t]est, [p]roduction, or ^C to abort
read ENV
fi
if [ "$ENV" == "p" ]; then
export ENVFILE=.env.prod
echo PRODUCTION Build
set -o allexport; source $ENVFILE; set +o allexport # expose all env file variables
echo Switching to Firebase Production environment for Android
cp -rf firebase_config/prod/google-services.json android/app
rm -rf ./android/app/build/outputs/bundle/Release/*.aab
npm run build
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
cd android
export REACT_NATIVE_MAX_WORKERS=2
./gradlew clean
./gradlew bundleRelease -x bundleReleaseJsAndAssets # .aab file for Google Play store
cd ..
cp ./android/app/build/outputs/bundle/release/app-release.aab ./android/app/build/outputs/bundle/release/app-release"${APP_VERSION}".aab
ls -l ./android/app/build/outputs/bundle/Release/*.aab
ls -l ./android/app/build/outputs/bundle/Release/app-release"${APP_VERSION}".aab >> build.log
cp -rf firebase_config/test/google-services.json android/app # reset back to test config for firebase
else
export ENVFILE=.env.test
echo TEST Build
set -o allexport; source $ENVFILE; set +o allexport # expose all env file variables
echo Switching to Firebase Test environment for Android
cp -rf firebase_config/test/google-services.json android/app
rm -rf ./android/app/build/outputs/apk/release/*.apk
npm run build
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
cd android
export REACT_NATIVE_MAX_WORKERS=2
./gradlew clean
./gradlew assembleRelease -x bundleReleaseJsAndAssets # .apk file for bluestacks & testfairy
cd ..
cp ./android/app/build/outputs/apk/release/app-release.apk ./android/app/build/outputs/apk/release/app-release"${APP_VERSION}".apk
ls -l ./android/app/build/outputs/apk/release/*.apk
ls -l ./android/app/build/outputs/apk/release/app-release"${APP_VERSION}".apk >> build.log
# Upload to testfairy
COMMENTS=$(cat build-comments.txt)
if [ "$ENV" == "t" ]; then
./testfairy-upload.sh ./android/app/build/outputs/apk/release/app-release.apk beta_android "${COMMENTS}"
elif [ "$ENV" == "d" ] || [ "$ENV" == "" ]; then
./testfairy-upload.sh ./android/app/build/outputs/apk/release/app-release.apk devtest "${COMMENTS}"
fi
fi