Skip to content

Instantly share code, notes, and snippets.

@armcknight
Last active April 20, 2018 20:03
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 armcknight/8c2def2f9c0ba6714611a28ce14f1a0e to your computer and use it in GitHub Desktop.
Save armcknight/8c2def2f9c0ba6714611a28ce14f1a0e to your computer and use it in GitHub Desktop.
Bumping versions in iOS apps and their repositories from the command line
desc 'Bump version number, commit the changes, and tag that commit. Can supply argument to bump one of: major, minor, patch or build. E.g., `rake bump[major]` or `rake bump[build]`.'
task :bump,[:component] do |t, args|
require 'open3'
sh "git stash --all"
component = args[:component]
if component == 'major' then
stdout, stderr, status = Open3.capture3("vrsn major --file #{version_file}")
elsif component == 'minor' then
stdout, stderr, status = Open3.capture3("vrsn minor --file #{version_file}")
elsif component == 'patch' then
stdout, stderr, status = Open3.capture3("vrsn patch --file #{version_file}")
elsif component == 'build' then
stdout, stderr, status = Open3.capture3("vrsn --numeric --file #{version_file}")
else
fail 'Unrecognized version component.'
end
sh "git add #{version_file}"
sh "git commit --message \"#{stdout}\""
sh "git tag `vrsn --read --file #{version_file}`+`vrsn --read --numeric --file #{version_file}`"
sh "git stash pop"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment