2024-05-22 00:21:27 +00:00
#!/usr/bin/env bash
2024-05-23 17:53:11 +00:00
set -e
2024-05-22 00:21:27 +00:00
2024-05-22 16:32:29 +00:00
source ./env.sh
2024-05-22 00:21:27 +00:00
APP_PLATFORMS = ( "android" "ios" "macos" "linux" "windows" )
2024-06-05 17:35:51 +00:00
APP_NAMED_IDS = ( "stack_wallet" "stack_duo" "campfire" )
2024-05-22 00:21:27 +00:00
# Function to display usage.
usage( ) {
echo " Usage: $0 -v <version> -b <build_number> -p <platform> -a <app> "
exit 1
}
2024-05-23 17:53:11 +00:00
confirmDisclaimer( ) {
while true; do
# shellcheck disable=SC2162
read -p "Please confirm you understand that when using certain values for <version> and <build_number> there is a chance that the resulting app WILL DELETE CRITICAL WALLET DATA. Are you sure you want to continue? (yes/no): " response
case $response in
[ Yy] [ Ee] [ Ss] ) echo "Continuing..." ; break; ;
[ Nn] [ Oo] ) exit 0; ;
* ) echo "Invalid response" ; ;
esac
done
}
2024-05-22 21:28:16 +00:00
# required args
2024-05-22 00:21:27 +00:00
unset -v APP_VERSION_STRING
unset -v APP_BUILD_NUMBER
unset -v APP_BUILD_PLATFORM
unset -v APP_NAMED_ID
2024-05-22 21:28:16 +00:00
# optional args (with defaults)
BUILD_CRYPTO_PLUGINS = 0
2024-05-22 00:21:27 +00:00
# Parse command-line arguments.
2024-05-22 21:28:16 +00:00
while getopts "v:b:p:a:i" opt; do
case " ${ opt } " in
2024-05-22 00:21:27 +00:00
v) APP_VERSION_STRING = " $OPTARG " ; ;
b) APP_BUILD_NUMBER = " $OPTARG " ; ;
p) APP_BUILD_PLATFORM = " $OPTARG " ; ;
a) APP_NAMED_ID = " $OPTARG " ; ;
2024-05-22 21:28:16 +00:00
i) BUILD_CRYPTO_PLUGINS = 1 ; ;
2024-05-22 00:21:27 +00:00
*) usage ; ;
esac
done
2024-05-22 21:28:16 +00:00
if [ -z " $APP_VERSION_STRING " ] ; then
echo "Missing -v option"
usage
fi
if [ -z " $APP_BUILD_NUMBER " ] ; then
echo "Missing -b option"
usage
fi
if [ -z " $APP_BUILD_PLATFORM " ] ; then
echo "Missing -p option"
usage
fi
if [ -z " $APP_NAMED_ID " ] ; then
echo "Missing -a option"
usage
fi
2024-05-23 17:53:11 +00:00
confirmDisclaimer
set -x
2024-05-24 00:50:05 +00:00
source " ${ APP_PROJECT_ROOT_DIR } /scripts/app_config/templates/configure_template_files.sh "
2024-05-22 23:56:51 +00:00
# checks for the correct platform dir and pushes it for later
2024-05-22 00:21:27 +00:00
if printf '%s\0' " ${ APP_PLATFORMS [@] } " | grep -Fxqz -- " ${ APP_BUILD_PLATFORM } " ; then
pushd " ${ APP_PROJECT_ROOT_DIR } /scripts/ ${ APP_BUILD_PLATFORM } "
else
echo " Invalid platform: ${ APP_BUILD_PLATFORM } "
usage
fi
2024-05-24 20:16:41 +00:00
PLAY_STORE_ICON_FILE = " ${ APP_PROJECT_ROOT_DIR } /android/app/src/main/app_icon-playstore.png "
if [ -f " ${ PLAY_STORE_ICON_FILE } " ] ; then
rm " ${ PLAY_STORE_ICON_FILE } "
fi
cp -rp " ${ APP_PROJECT_ROOT_DIR } /asset_sources/other/playstore_icon/ ${ APP_NAMED_ID } /app_icon-playstore.png " " ${ PLAY_STORE_ICON_FILE } "
2024-05-22 23:56:51 +00:00
# apply config project wide change changes
2024-05-22 00:21:27 +00:00
if printf '%s\0' " ${ APP_NAMED_IDS [@] } " | grep -Fxqz -- " ${ APP_NAMED_ID } " ; then
2024-05-24 00:50:05 +00:00
if cmp -s " ${ ACTUAL_PUBSPEC } " " ${ T_PUBSPEC } " ; then
rm " ${ ACTUAL_PUBSPEC } "
cp " ${ T_PUBSPEC } " " ${ ACTUAL_PUBSPEC } "
2024-05-23 23:40:00 +00:00
fi
2024-05-22 20:49:34 +00:00
" ${ APP_PROJECT_ROOT_DIR } /scripts/app_config/shared/update_version.sh " -v " ${ APP_VERSION_STRING } " -b " ${ APP_BUILD_NUMBER } "
2024-05-28 15:56:40 +00:00
" ${ APP_PROJECT_ROOT_DIR } /scripts/app_config/shared/link_assets.sh " " ${ APP_NAMED_ID } " " ${ APP_BUILD_PLATFORM } "
2024-05-22 23:56:51 +00:00
# shellcheck disable=SC1090
2024-06-05 15:13:47 +00:00
source " ${ APP_PROJECT_ROOT_DIR } /scripts/app_config/configure_ ${ APP_NAMED_ID } .sh " " ${ APP_BUILD_PLATFORM } "
2024-05-23 00:22:43 +00:00
" ${ APP_PROJECT_ROOT_DIR } /scripts/app_config/platforms/ ${ APP_BUILD_PLATFORM } /platform_config.sh "
2024-05-23 23:56:02 +00:00
if [ [ " $APP_BUILD_PLATFORM " != "linux" ] ] ; then
# run icon and image generators after project config has completed for non linux
" ${ APP_PROJECT_ROOT_DIR } /scripts/app_config/shared/asset_generators.sh " " ${ APP_BUILD_PLATFORM } "
fi
2024-05-22 00:21:27 +00:00
else
echo " Invalid app id: ${ APP_NAMED_ID } "
exit 1
fi
2024-05-22 21:28:16 +00:00
if [ " $BUILD_CRYPTO_PLUGINS " -eq 0 ] ; then
if [ [ " $APP_NAMED_ID " = "stack_wallet" ] ] ; then
./build_all.sh
elif [ [ " $APP_NAMED_ID " = "stack_duo" ] ] ; then
./build_all_duo.sh
2024-06-05 15:13:47 +00:00
elif [ [ " $APP_NAMED_ID " = "campfire" ] ] ; then
./build_all_campfire.sh
2024-05-22 21:28:16 +00:00
else
echo " Invalid app id: ${ APP_NAMED_ID } "
exit 1
fi
2024-05-22 00:21:27 +00:00
fi
popd