#!/usr/bin/env bash
if [ $# -ne 1 ]; then
echo "------------------------------------------------------"
echo "This script requires 1 argument. Sample usage:"
echo "sh update_release_versions.sh.sh release/1.0.0"
echo -e "------------------------------------------------------\n"
exit 1
fi
timestamp=$(date +%s)
releaseBranch=$1
if [[ ${releaseBranch} = "release/"* ]]; then
echo "It's a release branch: $releaseBranch"
else
echo "It's not a release branch: $releaseBranch"
exit
fi
# replace "release/" from branch name with ""
versionName=${releaseBranch[@]/release\//}
versionName=\"${versionName}\"
echo "updating versionCode to: ${timestamp}"
echo "updating versionName to: ${versionName}"
# replace inplace version code and version name
sed -i '' "s|versionCode.*|versionCode $timestamp|" app/build.gradle
sed -i '' "s|versionName.*|versionName $versionName|" app/build.gradle