rake + rspec + gemcutter

Today I’m going to talk about how I release new versions of ice_cube. I’ve set up a rake task called ‘release’, which makes sure that all of my tests pass before deploying tagging and pushing to RubyGems. I got the basis of the idea from a yehuda katz blog post.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require 'spec/rake/spectask'
require 'lib/ice_cube/version'
 
task :build => :test do
  system "gem build ice_cube.gemspec"
end
 
task :release => :build do
  # tag and push
  system "git tag v#{IceCube::VERSION}"
  system "git push origin --tags"
  # push the gem
  system "gem push ice_cube-#{IceCube::VERSION}.gem"
end
 
Spec::Rake::SpecTask.new(:test) do |t|
  t.spec_files = FileList['spec/**/*_spec.rb']
  fail_on_error = true # be explicit
end

Then you can just update the version.rb file:

1
2
3
module IceCube
  VERSION = "0.3.9"
end

and type:

$ rake release

Voila! Using this simple release method (thanks to rake and rspec), will make sure you don’t accidentally push broken versions ever (again).

  • email
  • del.icio.us
  • Facebook
  • Digg
  • Twitter
  • FriendFeed
  • Google Bookmarks