From: Jim Weirich Date: 2005-08-30T00:36:41+09:00 Subject: Re: beaten to the punch, and a request > pat eyler writes: > >> I'm wrapping up a tutorial on Rake for IBM (but probably won't be >> published >> for 2-3 months), and I wanted to make a request to the community. Does >> anyone have an interesting, useful rake task or rule they'd be >> interested in >> sharing? I'd like to include a short cookbook at the end of the >> article with >> some example code and explanations. You'll get credit in the text if I >> end up >> using your code (or build something based on it). You can respond to me >> off >> list if you like, but it might make for an interesting discussion here. I think the release task in the RubyGems Rakefile is moderately interesting. When we are ready to do a new release of the RubyGems software, all we type is: rake release REL=0.8.13 It will * check for proper release numbers, * make sure there is no outstanding checkins, * run the unit and functional tests (and abort the release if there are any failures), * update the release number embeded in the code (and check _that_ in), * create the package tar and zip files (and the upgrade gem) * tag the CVS version with the release number. Now that we have MetaProject (formally XForge), we could have it automatically upload the files to RubyForge as well. You can view the entire Rakefile here: http://rubyforge.org/cgi-bin/viewcvs.cgi/rubygems/Rakefile?rev=1.54&cvsroot=rubygems&content-type=text/vnd.viewcvs-markup or here is the relevent portion of the file: # -------------------------------------------------------------------- # Creating a release desc "Make a new release" task :release => [ :prerelease, :clobber, :alltests, :update_version, :package, :tag] do announce announce "**************************************************************" announce "* Release #{PKG_VERSION} Complete." announce "* Packages ready to upload." announce "**************************************************************" announce end # Validate that everything is ready to go for a release. task :prerelease do announce announce "**************************************************************" announce "* Making RubyGem Release #{PKG_VERSION}" announce "* (current version #{CURRENT_VERSION})" announce "**************************************************************" announce # Is a release number supplied? unless ENV['REL'] fail "Usage: rake release REL=x.y.z [REUSE=tag_suffix]" end # Is the release different than the current release. # (or is REUSE set?) if PKG_VERSION == CURRENT_VERSION && ! ENV['REUSE'] fail "Current version is #{PKG_VERSION}, must specify REUSE=tag_suffix to reuse version" end # Are all source files checked in? if ENV['RELTEST'] announce "Release Task Testing, skipping checked-in file test" else announce "Checking for unchecked-in files..." data = `cvs -q update` unless data =~ /^$/ fail "CVS update is not clean ... do you have unchecked-in files?" end announce "No outstanding checkins found ... OK" end end task :update_version => [:prerelease] do if PKG_VERSION == CURRENT_VERSION announce "No version change ... skipping version update" else announce "Updating RubyGem version to #{PKG_VERSION}" open("lib/rubygems/rubygems_version.rb", "w") do |f| f.puts "# DO NOT EDIT" f.puts "# This file is auto-generated by build scripts." f.puts "# See: rake update_version" f.puts "module Gem" f.puts " RubyGemsVersion = '#{PKG_VERSION}'" f.puts "end" end if ENV['RELTEST'] announce "Release Task Testing, skipping commiting of new version" else sh %{cvs commit -m "Updated to version #{PKG_VERSION}" lib/rubygems/rubygems_version.rb} end end end task :tag => [:prerelease] do reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}" reltag << ENV['REUSE'].gsub(/\./, '_') if ENV['REUSE'] announce "Tagging CVS with [#{reltag}]" if ENV['RELTEST'] announce "Release Task Testing, skipping CVS tagging" else sh %{cvs tag #{reltag}} end end -- -- Jim Weirich jim@weirichhouse.org http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)