Created
September 17, 2014 17:09
-
-
Save nkammah/4cf5e8996e1f782e7a9f to your computer and use it in GitHub Desktop.
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
#Lots of credit to http://www.merowing.info/2013/03/overlaying-application-version-on-top-of-your-icon/ | |
# USAGE: | |
# Run setup.sh first to make sure ImageMagick works | |
# This script takes one argument: a path to the folder containing the icons to burn. | |
version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${INFOPLIST_FILE}"` | |
branch=`git rev-parse --abbrev-ref HEAD` | |
caption="${branch}\n${version}" | |
identify="/usr/local/bin/identify" | |
convert="/usr/local/bin/convert" | |
resource_path="${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" | |
icon_root=$1 | |
if [[ -z "${icon_root}" || ! -e "${icon_root}" ]]; then | |
echo "You must pass the root folder containing the icons you'd like to burn." | |
exit; | |
fi | |
if [[ ! -e ${identify} || ! -e ${convert} ]]; then | |
echo "ImageMagick is not installed correctly. Aborting." | |
exit; | |
fi | |
function burn() { | |
base_path=$1 | |
base_icon=`basename ${base_path}` | |
echo "Burning ${base_icon} with build information" | |
target_path="${resource_path}/${base_icon}" | |
width=`${identify} -format %w ${base_path}` | |
height=`echo ${width}/3 | bc` | |
if [ `echo "(${height} < 40)" | bc` == 1 ]; then | |
height=40 | |
fi | |
${convert} -background '#0008' -fill white -gravity center -size ${width}x${height} \ | |
caption:"${caption}"\ | |
"${base_path}" +swap -gravity south -composite "${target_path}" | |
} | |
echo "Applying version caption \"${caption}\" to icons in ${icon_root}" | |
# Go through the icon files we've already moved and burn them with build information | |
for icon in "Icon.png" "Icon@2x.png" "Icon-72@2x.png" "Icon-72.png" | |
do | |
burn ${icon_root}/${icon} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment