2014-11-02 15:27:02 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
cd "${BASH_SOURCE%/*}"
|
2014-11-18 13:12:40 +00:00
|
|
|
source ./bashlib
|
2014-11-02 15:27:02 +00:00
|
|
|
cd ..
|
|
|
|
export PATH+=:/usr/libexec
|
|
|
|
|
|
|
|
addPlistWithKey() {
|
|
|
|
local key=$1 type=$2 value=$3 plist=${4:-"$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"}
|
|
|
|
|
|
|
|
PlistBuddy -c "Delete :'$key'" "$plist" 2>/dev/null || true
|
|
|
|
PlistBuddy -c "Add :'$key' '$type' '$value'" "$plist"
|
|
|
|
}
|
|
|
|
setPlistWithKey() {
|
|
|
|
local key=$1 value=$2 plist=${3:-"$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"}
|
|
|
|
|
|
|
|
PlistBuddy -c "Set :'$key' '$value'" "$plist"
|
|
|
|
}
|
|
|
|
getPlistWithKey() {
|
|
|
|
local key=$1 plist=${2:-"$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"}
|
|
|
|
|
|
|
|
PlistBuddy -c "Print :'$key'" "$plist"
|
|
|
|
}
|
|
|
|
setSettingWithTitle() {
|
|
|
|
local i title=$1 value=$2 plist=${3:-"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Settings.bundle/Root.plist"}
|
|
|
|
|
|
|
|
for (( i=0; 1; ++i )); do
|
|
|
|
PlistBuddy -c "Print :PreferenceSpecifiers:$i" "$plist" &>/dev/null || break
|
|
|
|
inf "Checking preference specifier $i"
|
|
|
|
|
|
|
|
[[ $(PlistBuddy -c "Print :PreferenceSpecifiers:$i:Title" "$plist" 2>/dev/null) = $title ]] || continue
|
|
|
|
|
|
|
|
inf "Correct title, setting value."
|
|
|
|
PlistBuddy -c "Set :PreferenceSpecifiers:$i:DefaultValue $value" "$plist"
|
|
|
|
break
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
description=$(git describe --always --dirty --long --match '*-release')
|
|
|
|
version=${description%-g*}
|
2015-11-06 07:15:58 +00:00
|
|
|
release=${version%%-*} build=${version##*-}
|
|
|
|
printf -v version '%s.%d' "$release" "$build"
|
|
|
|
printf -v commit '%s' "${description##*-g}"
|
2014-11-02 15:27:02 +00:00
|
|
|
|
|
|
|
addPlistWithKey GITDescription string "$description"
|
2015-11-06 07:15:58 +00:00
|
|
|
setPlistWithKey CFBundleVersion "$version"
|
|
|
|
setPlistWithKey CFBundleShortVersionString "$release"
|
2014-11-02 15:27:02 +00:00
|
|
|
|
|
|
|
setSettingWithTitle "Build" "$commit"
|
|
|
|
setSettingWithTitle "Version" "$version"
|
|
|
|
setSettingWithTitle "Copyright" "$(getPlistWithKey NSHumanReadableCopyright)"
|
|
|
|
|
|
|
|
if [[ $DEPLOYMENT_LOCATION = YES ]]; then
|
|
|
|
# This build is a release. Do some release checks.
|
2015-11-05 16:43:57 +00:00
|
|
|
crashlyticsPlist="$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/Crashlytics.plist"
|
2014-11-02 15:27:02 +00:00
|
|
|
passed=1
|
|
|
|
[[ $description != *-dirty ]] || \
|
|
|
|
{ passed=0; err 'ERROR: Cannot release a dirty version, first commit any changes.'; }
|
2015-02-07 14:16:17 +00:00
|
|
|
[[ -r "$crashlyticsPlist" && $(PlistBuddy -c "Print :'API Key'" "$crashlyticsPlist" 2>/dev/null) ]] || \
|
2014-11-02 15:27:02 +00:00
|
|
|
{ passed=0; err 'ERROR: Cannot release: Crashlytics API key is missing.'; }
|
|
|
|
(( passed )) || \
|
|
|
|
{ ftl "Failed to pass release checks. Fix the above errors and re-try. Aborting."; exit 1; }
|
|
|
|
fi
|