Permalink
Browse files

add version:bump:patch / :minor / :major tasks

  • Loading branch information...
1 parent 1c1ee80 commit 5fbd5328881cf1cfa3e97c4afefef082fa4a8631 Michael Grosser committed Mar 14, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 Rakefile
View
@@ -3,3 +3,20 @@ require "bundler/gem_tasks"
task :default do
sh "bundle exec rspec spec"
end
+
+# extracted from https://github.com/grosser/project_template
+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/pivotal_git_scripts/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 # remove patch for minor
+ version_parts[1] = 0 if index < 1 # remove minor for major
+ 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

0 comments on commit 5fbd532

Please sign in to comment.