Skip to content

Instantly share code, notes, and snippets.

@thetron
Created November 24, 2011 00:38
Show Gist options
  • Save thetron/1390351 to your computer and use it in GitHub Desktop.
Save thetron/1390351 to your computer and use it in GitHub Desktop.
Automatic, Apple-style build numbers
#!/usr/bin/env ruby
bundle_version_short = %x{/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE"}
bundle_version = %x{/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE"}
build_number = bundle_version_short.split(".").first
build_number += (bundle_version_short.split(".")[1].to_i + 65).chr
build_number += (bundle_version.scan(/\d+[A-Z](\d+)/).flatten.first.to_i + 1).to_s
%x{/usr/libexec/PlistBuddy -c "Set :CFBundleVersion #{build_number}" "$INFOPLIST_FILE"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment