Skip to content

Instantly share code, notes, and snippets.

@armcknight
Last active April 20, 2018 20:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Bumping versions in iOS apps and their repositories from the command line
desc 'Bump version number and commit the changes with message as the output from vrsn. 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'
modified_file_count, stderr, status = Open3.capture3("git status --porcelain | egrep '^(M| M)' | wc -l")
if modified_file_count.to_i > 0 then
sh "git stash --all"
end
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 push'
if modified_file_count.to_i > 0 then
sh "git stash pop"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment