forked from CollaboraOnline/online
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modify_bundle_version.sh
executable file
·38 lines (32 loc) · 1.47 KB
/
modify_bundle_version.sh
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
#!/bin/bash -e
set +x
# Modify the Info.plist to ensure that CFBundleVersion is always incremented
# AppStoreConnect requires each upload, whether it is released or not, to be
# higher than the previous successful upload's CFBundleVersion. So this
# script sets the CFBundleVersion to the first and second components of
# CFBundleShortVersionString and the UTC timestamp of when this script was
# run is appended as the third component (or the second component if there
# isn't a second component in CFBundleShortVersionString).
info_plist="$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
if [ ! -f "$info_plist" ]; then
echo "Error: $info_plist does not exist or is not a regular file" >&2
exit 1
fi
bundle_short_version=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$info_plist"`
if [ -z "$bundle_short_version" ]; then
echo "Error: CFBundleShortVersionString key in $info_plist empty" >&2
exit 1
fi
major_version=`echo "$bundle_short_version" | cut -d. -f1`
if [ -z "$major_version" -o "$major_version" = "0" ]; then
echo "Error: CFBundleShortVersionString major version is empty or 0" >&2
exit 1
fi
bundle_version="$major_version"
minor_version=`echo "$bundle_short_version" | cut -d. -f2`
if [ ! -z "$minor_version" ]; then
bundle_version="$bundle_version.$minor_version"
fi
bundle_version="$bundle_version.`date -u '+%Y%m%d%H%M'`"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $bundle_version" "$info_plist"
echo "Succesfully Updated CFBundleVersion"