stack_wallet/scripts/app_config/shared/update_version.sh

47 lines
1.1 KiB
Bash
Raw Normal View History

#!/bin/bash
2024-05-22 20:48:31 +00:00
set -x -e
# Function to display usage.
usage() {
echo "Usage: $0 [-v <version>] [-b <build_number>]"
exit 1
}
2024-05-22 20:48:31 +00:00
unset -v VERSION
unset -v BUILD_NUMBER
2024-05-21 22:05:45 +00:00
# Check if no arguments are provided.
2024-05-21 22:13:23 +00:00
if [ $# -ne 4 ]; then # if [ -z "$VERSION" ] || [ -z "$BUILD_NUMBER" ]; then
2024-05-21 22:05:45 +00:00
usage
fi
# Parse command-line arguments.
while getopts "v:b:" opt; do
case "$opt" in
v) VERSION="$OPTARG" ;;
b) BUILD_NUMBER="$OPTARG" ;;
*) usage ;;
esac
done
# Define the pubspec.yaml file path.
2024-05-22 20:48:31 +00:00
PUBSPEC_FILE="${APP_PROJECT_ROOT_DIR}/pubspec.yaml"
# Ensure the pubspec.yaml file exists.
if [ ! -f "$PUBSPEC_FILE" ]; then
echo "Error: $PUBSPEC_FILE not found!"
exit 1
fi
2024-05-22 20:48:31 +00:00
if [[ "$(uname)" == 'Darwin' ]]; then
# macos specific sed
sed -i '' "s/PLACEHOLDER_V/$VERSION/g" "${PUBSPEC_FILE}"
sed -i '' "s/PLACEHOLDER_B/$BUILD_NUMBER/g" "${PUBSPEC_FILE}"
else
2024-05-22 20:54:28 +00:00
sed -i "s/PLACEHOLDER_V/$VERSION/g" "${PUBSPEC_FILE}"
sed -i "s/PLACEHOLDER_B/$BUILD_NUMBER/g" "${PUBSPEC_FILE}"
fi
echo "Updated $PUBSPEC_FILE with version: $VERSION and build number: $BUILD_NUMBER"