Created
May 17, 2012 02:28
-
-
Save DylanLacey/2715767 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
task "cut_gem" do | |
version:bump:patch | |
end | |
rule /^version:bump:.*/ do |t| | |
sh "git status | grep 'nothing to commit'" # ensure we are not dirty | |
index = ['major', 'minor','patch'].index(t.name.split(':').last) | |
file = 'lib/GEM_NAME/version.rb' | |
version_file = File.read(file) | |
old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a | |
version_parts[index] = version_parts[index].to_i + 1 | |
version_parts[2] = 0 if index < 2 | |
version_parts[1] = 0 if index < 1 | |
new_version = version_parts * '.' | |
File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) } | |
sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment