0
# Does CHANGELOG reflects current release?
0
print 'Checking that CHANGELOG indicates most recent version and today\'s date ... '
0
- expecting = "#{ruby_spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
0
- header = File.readlines('CHANGELOG').first
0
+ expecting = "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
0
+ header = File.readlines('CHANGELOG').first.chomp
0
fail "Expecting CHANGELOG to start with #{expecting}, but found #{header} instead" unless expecting == header
0
+ print 'Checking there are no local changes ... '
0
fail "Cannot release unless all local changes are in SVN:\n#{status}" unless status.empty?
0
+ fail "Cannot release unless all local changes are in Git:\n" + `git status` if `git status`[/^#\t/]
0
- task 'make'=>'prepare' do
0
+ task 'make'=>'release:prepare' do |task|
0
task('release:wrapup').invoke
0
- task 'rubyforge'=>'pacakge' do
0
- # Read the changes for this release.
0
- print 'Looking for changes between this release and previous one ... '
0
- pattern = /(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/
0
- changelog = File.read(__FILE__.pathmap('%d/CHANGELOG'))
0
- changes = changelog.scan(pattern).inject({}) { |hash, set| hash[set[1]] = set[2] ; hash }
0
- current = changes[spec.version.to_s]
0
- current = changes[spec.version.to_s.split('.')[0..-2].join('.')] if !current && spec.version.to_s =~ /\.0$/
0
- fail "No changeset found for version #{spec.version}" unless current
0
+ task 'rubyforge'=>'package' do
0
+ if File.exist?('CHANGELOG')
0
+ # Read the changes for this release.
0
+ print 'Looking for changes between this release and previous one ... '
0
+ pattern = /(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/
0
+ changes = File.read('CHANGELOG').scan(pattern).inject({}) { |hash, set| hash[set[1]] = set[2] ; hash }
0
+ current = changes[spec.version.to_s]
0
+ current = changes[spec.version.to_s.split('.')[0..-2].join('.')] if !current && spec.version.to_s =~ /\.0$/
0
+ fail "No changeset found for version #{spec.version}" unless current
0
print "Uploading #{spec.version} to RubyForge ... "
0
files = Dir.glob('pkg/*.{gem,tgz,zip}')
0
rubyforge = RubyForge.new
0
- File.open('.changes', 'w'){|f| f.write(current)}
0
- rubyforge.userconfig.merge!('release_changes' => '.changes', 'preformatted' => true)
0
- rubyforge.add_release spec.rubyforge_project.downcase, spec.name.downcase, spec.version, *files
0
+ File.open('.changes', 'w'){|f| f.write(current)}
0
+ rubyforge.userconfig.merge!('release_changes' => '.changes', 'preformatted' => true)
0
+ rubyforge.add_release spec.rubyforge_project.downcase, spec.name.downcase, spec.version, *files
0
+ rm '.changes' if changes
0
# Tag this release in SVN.
0
- print "Tagging release as tags/#{ruby_spec.version} ... "
0
- cur_url = `svn info`.scan(/URL: (.*)/)[0][0]
0
- new_url = cur_url.sub(/(trunk$)|(branches\/\w*)$/, "tags/#{ruby_spec.version.to_s}")
0
- sh 'svn', 'copy', cur_url, new_url, '-m', "Release #{ruby_spec.version.to_s}", :verbose=>false
0
+ info = `svn info` + `git svn info` # Using either svn or git-svn
0
+ url = info[/^URL:/] && info.scan(/^URL: (.*)/)[0][0]
0
+ new_url = url.sub(/(trunk$)|(branches\/\w*)$/, "tags/#{spec.version}")
0
+ break if url == new_url
0
+ print "Tagging release as tags/#{spec.version} ... "
0
+ sh 'svn', 'copy', url, new_url, '-m', "Release #{spec.version}", :verbose=>false do |ok, res|
0
+ puts 'Could not create tag, please do it yourself!'
0
+ puts %{ svn copy #{url} #{new_url} -m "#{spec.version}"}
0
# Update lib/buildr.rb to next vesion number, add new entry in CHANGELOG.
0
task 'next_version'=>'tag' do
0
- next_version = ruby_spec.version.to_ints.zip([0, 0, 1]).map { |a| a.inject(0) { |t,i| t + i } }.join('.')
0
- print "Updating lib/buildr.rb to next version number (#{next_version}) ... "
0
- buildr_rb = File.read(__FILE__.pathmap('%d/lib/buildr.rb')).
0
- sub(/(VERSION\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
0
- File.open(__FILE__.pathmap('%d/lib/buildr.rb'), 'w') { |file| file.write buildr_rb }
0
+ next_version = spec.version.to_ints.zip([0, 0, 1]).map { |a| a.inject(0) { |t,i| t + i } }.join('.')
0
+ ver_file = "lib/#{spec.name}.rb"
0
+ if File.exist?(ver_file)
0
+ print "Updating #{ver_file} to next version number (#{next_version}) ... "
0
+ modified = File.read(ver_file).sub(/(VERSION\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
0
+ File.open(ver_file, 'w') { |file| file.write modified }
0
- print 'Adding new entry to CHANGELOG ... '
0
- changelog = File.read(__FILE__.pathmap('%d/CHANGELOG'))
0
- File.open(__FILE__.pathmap('%d/CHANGELOG'), 'w') { |file| file.write "#{next_version} (Pending)\n\n#{changelog}" }
0
+ if File.exist?('CHANGELOG')
0
+ print 'Adding new entry to CHANGELOG ... '
0
+ modified = "#{next_version} (Pending)\n\n" + File.read('CHANGELOG')
0
+ File.open('CHANGELOG', 'w') { |file| file.write modified }
0
task 'wrapup'=>['tag', 'next_version']
Comments
No one has commented yet.