Skip to content

Instantly share code, notes, and snippets.

@amrox
Created January 20, 2012 06:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amrox/1645706 to your computer and use it in GitHub Desktop.
Save amrox/1645706 to your computer and use it in GitHub Desktop.
#!/bin/bash
git=$(which git)
function parse_git_branch {
ref=$(${git} symbolic-ref HEAD 2> /dev/null) || return
echo ${ref#refs/heads/} | sed 's/\//_/'
}
prefix_file="InfoPlist_Prefix.h"
marketing_version=$(cat MARKETING_VERSION)
git_version=$(git rev-parse HEAD)
git_short_version=$(git rev-parse --short HEAD)
git_branch=$(parse_git_branch)
build_number=${BUILD_NUMBER:-0} # if $BUILD_NUMBER is set, use it. Set to 0 otherwise.
if [ -z ${VERSION} ]; then
VERSION=${git_short_version}
fi
rm -f $prefix_file
echo "#define MARKETING_VERSION ${marketing_version}" >> $prefix_file
echo "#define BUILD_NUMBER ${build_number}" >> $prefix_file
echo "#define GIT_VERSION ${git_version}" >> $prefix_file
echo "#define GIT_BRANCH ${git_branch}" >> $prefix_file
echo "#define VERSION ${VERSION}" >> $prefix_file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildNumber</key>
<string>BUILD_NUMBER</string>
<key>CFBundleShortVersionString</key>
<string>MARKETING_VERSION</string>
<key>CFBundleVersion</key>
<string>VERSION</string>
<key>GitBranch</key>
<string>GIT_BRANCH</string>
<key>GitVersion</key>
<string>GIT_VERSION</string>
....
</dict>
</plist>
#define MARKETING_VERSION 2.5.9
#define BUILD_NUMBER 0
#define GIT_VERSION ca1f23d466ad83252ab23b63431a8c66b265d508
#define GIT_BRANCH develop
#define VERSION ca1f23d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment