Created
January 4, 2021 05:11
-
-
Save nhancv/2c4c3e6644e97547306f6aba4a88c017 to your computer and use it in GitHub Desktop.
Update info.plist version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash -e | |
_INFOPLIST_DIR="ios/Runner/Info.plist" | |
_PACKAGE_VERSION=$(cat pubspec.yaml | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[: ']//g'') | |
# Set BUILD_NUMBER to the value 1 only if it is unset. | |
: ${BUILD_NUMBER=$(expr $(git log -1 --pretty=format:%ct) / 3600)} | |
# Update plist with new values | |
BUNDLE_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${_INFOPLIST_DIR}") | |
if [ "$BUNDLE_VERSION" != "$BUILD_NUMBER" ] | |
then | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD_NUMBER" "${_INFOPLIST_DIR}" | |
fi | |
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${_PACKAGE_VERSION#*v}" "${_INFOPLIST_DIR}" | |
echo "****************************************" | |
echo "PACKAGE_VERSION: " $_PACKAGE_VERSION | |
echo "BUILD_NUMBER: " $BUILD_NUMBER | |
echo "****************************************" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment