#!/bin/bash

# debug/release
BUILD_MODE=${BUILD_MODE:-debug}
# LOCAL/DEV/PROD
APP_TITLE=${APP_TITLE:-}
APP_URI=${APP_URI:-}
APP_COLOR=${APP_COLOR:-}
ANDROID_KEYSTORE_FILE=${ANDROID_KEYSTORE_FILE:-}
ANDROID_KEY_ALIAS=${ANDROID_KEY_ALIAS:-}
ANDROID_KEYSTORE_PASSWORD=${ANDROID_KEYSTORE_PASSWORD:-}
ANDROID_KEY_PASSWORD=${ANDROID_KEY_PASSWORD:-}


cat  << EOF > android/local.properties
flutter.sdk=/home/developer/flutter
sdk.dir=/home/developer/android
flutter.buildMode=${BUILD_MODE}
flutter.versionName=
flutter.versionCode=
EOF

cat  << EOF > android/key.properties
storePassword=${ANDROID_KEYSTORE_PASSWORD}
keyPassword=${ANDROID_KEY_PASSWORD}
keyAlias=${ANDROID_SIGNING_KEY_ALIAS}
storeFile=${ANDROID_KEYSTORE_FILE}
EOF

pwd

flutter build appbundle --dart-define="APP_TITLE=${APP_TITLE}" --dart-define="APP_URI=${APP_URI}" --dart-define="APP_COLOR=${APP_COLOR}"

