Last active
December 18, 2015 15:49
-
-
Save mps/5807196 to your computer and use it in GitHub Desktop.
A rake task for revving plist build version numbers...
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
def revBuild(plistFile) | |
puts "Attempting to update #{plistFile} build version..." | |
oldVersion = `/usr/libexec/PlistBuddy -c "Print CFBundleVersion" #{plistFile}` | |
puts "The old version: #{oldVersion}" | |
versionParts = oldVersion.split(".") | |
previousDate = versionParts[2] | |
newDate = Time.now.strftime("%Y%m%d") | |
versionParts[2] = newDate | |
versionParts[3] = previousDate == versionParts[2] ? (versionParts[3].to_i+1).to_s : "1" | |
versionParts.each do |part| | |
part.chomp! | |
end | |
newVersion = versionParts.join(".") | |
`/usr/libexec/PlistBuddy -c "Set :CFBundleVersion #{newVersion}" #{plistFile}` | |
puts "The new version: #{newVersion}" | |
end | |
desc "Rev the build numbers in a project's plist" | |
task :rev do | |
revBuild './path/to/my.plist' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment