Bumping versions in iOS apps and their repositories from the command line
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
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