-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathupdate_version.sh
More file actions
executable file
·43 lines (34 loc) · 938 Bytes
/
Copy pathupdate_version.sh
File metadata and controls
executable file
·43 lines (34 loc) · 938 Bytes
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
#!/usr/bin/env bash
set -x -e
# Function to display usage.
usage() {
echo "Usage: $0 [-v <version>] [-b <build_number>]"
exit 1
}
unset -v VERSION
unset -v BUILD_NUMBER
# Check if no arguments are provided.
if [ $# -ne 4 ]; then # if [ -z "$VERSION" ] || [ -z "$BUILD_NUMBER" ]; then
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.
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
sed -i.bak \
-e "s/PLACEHOLDER_V/$VERSION/g" \
-e "s/PLACEHOLDER_B/$BUILD_NUMBER/g" \
"${PUBSPEC_FILE}"
rm -f "${PUBSPEC_FILE}.bak"
echo "Updated $PUBSPEC_FILE with version: $VERSION and build number: $BUILD_NUMBER"