4 require 'rubygems/package_task'
6 if ENV['YAML'] == "syck"
18 Hoe::RUBY_FLAGS << " --disable-gems" if RUBY_VERSION > "1.9"
24 hoe = Hoe.spec 'rubygems-update' do
25 self.author = ['Jim Weirich', 'Chad Fowler', 'Eric Hodel']
26 self.email = %w[rubygems-developers@rubyforge.org]
27 self.readme_file = 'README.rdoc'
32 spec_extras[:required_rubygems_version] = Gem::Requirement.default
33 spec_extras[:required_ruby_version] = Gem::Requirement.new '>= 1.8.7'
34 spec_extras[:executables] = ['update_rubygems']
37 'docs.seattlerb.org:/data/www/docs.seattlerb.org/rubygems/'
39 clean_globs.push('**/debug.log',
46 'pkgs/sources/sources*.gem',
49 dependency 'builder', '~> 2.1', :dev
50 dependency 'hoe-seattlerb', '~> 1.2', :dev
51 dependency 'rdoc', '~> 3.0', :dev
52 dependency 'ZenTest', '~> 4.5', :dev
53 dependency 'rake', '~> 0.9.3', :dev
54 dependency 'minitest', '~> 4.0', :dev
56 self.extra_rdoc_files = Dir["*.rdoc"] + %w[
61 spec_extras['rdoc_options'] = proc do |rdoc_options|
62 rdoc_options << "--title=RubyGems Update Documentation"
65 self.rsync_args += " --no-p -O"
67 spec_extras['require_paths'] = %w[hide_lib_for_update]
72 hoe.test_prelude = 'gem "minitest", "~> 4.0"'
74 Rake::Task['docs'].clear
75 Rake::Task['clobber_docs'].clear
80 RDoc::Task.new :rdoc => 'docs', :clobber_rdoc => 'clobber_docs' do |doc|
81 doc.main = hoe.readme_file
82 doc.title = "RubyGems #{v} API Documentation"
84 rdoc_files = Rake::FileList.new %w[lib History.txt LICENSE.txt MIT.txt]
85 rdoc_files.add hoe.extra_rdoc_files
87 doc.rdoc_files = rdoc_files
91 rescue LoadError, RuntimeError # rake 10.1 on rdoc from ruby 1.9.2 and earlier
93 abort 'You must install rdoc to build documentation, try `rake newb` again'
97 desc "Install gems needed to run the tests"
98 task :install_test_deps => :clean_env do
99 sh "gem install minitest -v '~> 4.0'"
102 # --------------------------------------------------------------------
105 task :prerelease => [:clobber, :check_manifest, :test]
107 task :postrelease => %w[upload guides:publish blog:publish publish_docs]
109 file "pkg/rubygems-#{v}" => "pkg/rubygems-update-#{v}" do |t|
112 dest_root = File.expand_path t.name
115 Find.find '.' do |file|
116 dest = File.expand_path file, dest_root
118 if File.directory? file then
128 source_pkg_dir = "pkg/rubygems-#{v}"
130 file "pkg/rubygems-#{v}.tgz" => source_pkg_dir do
132 sh "tar -czf rubygems-#{v}.tgz rubygems-#{v}"
136 file "pkg/rubygems-#{v}.zip" => source_pkg_dir do
138 sh "zip -q -r rubygems-#{v}.zip rubygems-#{v}"
142 file "pkg/rubygems-update-#{v}.gem"
145 pkg/rubygems-update-#{v}.gem
146 pkg/rubygems-#{v}.tgz
147 pkg/rubygems-#{v}.zip
150 desc "Upload release to gemcutter S3"
151 task :upload_to_gemcutter do
152 sh "s3cmd put -P pkg/rubygems-update-#{v}.gem pkg/rubygems-#{v}.zip pkg/rubygems-#{v}.tgz s3://production.s3.rubygems.org/rubygems/"
155 desc "Upload release to rubygems.org"
156 task :upload => %w[upload_to_gemcutter]
158 on_master = `git branch --list master`.strip == '* master'
159 on_master = true if ENV['FORCE']
161 Rake::Task['publish_docs'].clear unless on_master
163 directory '../guides.rubygems.org' do
165 'git@github.com:rubygems/guides.git',
166 '../guides.rubygems.org'
169 namespace 'guides' do
170 task 'pull' => %w[../guides.rubygems.org] do
171 chdir '../guides.rubygems.org' do
176 task 'update' => %w[../guides.rubygems.org] do
177 lib_dir = File.join Dir.pwd, 'lib'
179 chdir '../guides.rubygems.org' do
180 ruby '-I', lib_dir, '-S', 'rake', 'command_guide'
181 ruby '-I', lib_dir, '-S', 'rake', 'spec_guide'
185 task 'commit' => %w[../guides.rubygems.org] do
186 chdir '../guides.rubygems.org' do
188 sh 'git', 'diff', '--quiet'
190 sh 'git', 'commit', 'command-reference.md', 'specification-reference.md',
191 '-m', "Rebuild for RubyGems #{v}"
196 task 'push' => %w[../guides.rubygems.org] do
197 chdir '../guides.rubygems.org' do
202 desc 'Updates and publishes the guides for the just-released RubyGems'
205 task 'publish' => %w[
213 directory '../blog.rubygems.org' do
215 'git@github.com:rubygems/rubygems.github.com.git',
216 '../blog.rubygems.org'
220 date = Time.now.strftime '%Y-%m-%d'
221 post_page = "_posts/#{date}-#{v}-released.md"
224 task 'checksums' => 'package' do
226 Dir['pkg/*{tgz,zip,gem}'].map do |file|
227 digest = Digest::SHA256.new
229 open file, 'rb' do |io|
230 while chunk = io.read(65536) do
235 checksums << "* #{File.basename(file)} \n"
236 checksums << " #{digest.hexdigest}\n"
240 task 'pull' => %w[../blog.rubygems.org] do
241 chdir '../blog.rubygems.org' do
246 path = File.join '../blog.rubygems.org', post_page
248 task 'update' => [path]
250 file path => 'checksums' do
251 name = `git config --get user.name`.strip
252 email = `git config --get user.email`.strip
254 history = File.read 'History.txt'
256 history.force_encoding Encoding::UTF_8 if Object.const_defined? :Encoding
258 _, change_log, = history.split %r%^===\s*\d.*%, 3
262 lines = change_log.strip.lines
265 while line = lines.shift do
267 when /(^[A-Z].*)/ then
269 change_log << "_#{$1}_\n"
273 while /^ \S/ =~ lines.first do
274 entry << lines.shift.strip
277 change_log << "#{entry.join ' '}\n"
283 change_log = change_log.join
285 change_types = change_types.map do |change_type|
286 change_type.downcase.tr '^a-z ', ''
289 last_change_type = change_types.pop
291 if change_types.empty? then
294 change_types = change_types.join(', ') << ' and '
297 change_types << last_change_type
301 Tempfile.open 'blog_post' do |io|
302 io.write <<-ANNOUNCEMENT
307 author_email: #{email}
310 RubyGems #{v} includes #{change_types}.
312 To update to the latest RubyGems you can run:
316 If you need to upgrade or downgrade please follow the [how to upgrade/downgrade
317 RubyGems][upgrading] instructions. To install RubyGems by hand see the
318 [Download RubyGems][download] page.
326 [download]: http://rubygems.org/pages/download
327 [upgrading]: http://docs.seattlerb.org/rubygems/UPGRADING_rdoc.html
333 sh ENV['EDITOR'], io.path
335 FileUtils.cp io.path, path
339 task 'commit' => %w[../blog.rubygems.org] do
340 chdir '../blog.rubygems.org' do
341 sh 'git', 'add', post_page
342 sh 'git', 'commit', post_page,
343 '-m', "Added #{v} release announcement"
347 task 'push' => %w[../blog.rubygems.org] do
348 chdir '../blog.rubygems.org' do
353 desc 'Updates and publishes the blog for the just-released RubyGems'
354 task 'publish' => %w[
362 # Misc Tasks ---------------------------------------------------------
364 # These tasks expect to have the following directory structure:
366 # git/git.rubini.us/code # Rubinius git HEAD checkout
367 # svn/ruby/trunk # ruby subversion HEAD checkout
368 # svn/rubygems/trunk # RubyGems subversion HEAD checkout
370 # If you don't have this directory structure, set RUBY_PATH and/or
376 "--exclude '*svn*' " +
377 "--exclude '*swp' " +
378 "--exclude '*rbc' " +
379 "--exclude '*.rej' " +
380 "--exclude '*.orig' " +
381 "--exclude 'lib/rubygems/defaults/*' " +
382 "--exclude gauntlet_rubygems.rb"
384 sh "rsync #{rsync_options} bin/gem #{dir}/bin/gem"
385 sh "rsync #{rsync_options} lib/ #{dir}/lib"
386 sh "rsync #{rsync_options} test/ #{dir}/test"
390 diff_options = "-urpN --exclude '*svn*' --exclude '*swp' --exclude '*rbc'"
391 sh "diff #{diff_options} bin/gem #{dir}/bin/gem; true"
392 sh "diff #{diff_options} lib/ubygems.rb #{dir}/lib/ubygems.rb; true"
393 sh "diff #{diff_options} lib/rubygems.rb #{dir}/lib/rubygems.rb; true"
394 sh "diff #{diff_options} lib/rubygems #{dir}/lib/rubygems; true"
395 sh "diff #{diff_options} lib/rbconfig #{dir}/lib/rbconfig; true"
396 sh "diff #{diff_options} test/rubygems #{dir}/test/rubygems; true"
399 rubinius_dir = ENV['RUBINIUS_PATH'] || '../git.rubini.us/code'
400 ruby_dir = ENV['RUBY_PATH'] || '../../svn/ruby/trunk'
402 desc "Updates Ruby HEAD with the currently checked-out copy of RubyGems."
407 desc "Updates Rubinius HEAD with the currently checked-out copy of RubyGems."
408 task :update_rubinius do
409 rsync_with rubinius_dir
412 desc "Diffs Ruby HEAD with the currently checked-out copy of RubyGems."
417 desc "Diffs Rubinius HEAD with the currently checked-out copy of RubyGems."
418 task :diff_rubinius do
419 diff_with rubinius_dir
422 desc "Cleanup trailing whitespace"
424 system 'find . -not \( -name .svn -prune -o -name .git -prune \) -type f -print0 | xargs -0 sed -i "" -E "s/[[:space:]]*$//"'