1 # -*- encoding: binary -*-
2 autoload :Gem, 'rubygems'
4 # most tasks are in the GNUmakefile which offers better parallelism
7 @old_summaries ||= File.readlines(".CHANGELOG.old").inject({}) do |hash, line|
8 version, summary = line.split(/ - /, 2)
9 hash[version] = summary
15 timefmt = '%Y-%m-%dT%H:%M:%SZ'
16 @tags ||= `git tag -l`.split(/\n/).map do |tag|
17 next if tag == "v0.0.0"
18 if %r{\Av[\d\.]+\z} =~ tag
19 header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
20 header = header.split(/\n/)
21 tagger = header.grep(/\Atagger /).first
24 :time => Time.at(tagger.split(/ /)[-2].to_i).utc.strftime(timefmt),
25 :tagger_name => %r{^tagger ([^<]+)}.match(tagger)[1].strip,
26 :tagger_email => %r{<([^>]+)>}.match(tagger)[1].strip,
27 :id => `git rev-parse refs/tags/#{tag}`.chomp!,
30 :body => (old = old_summaries[tag]) ? "#{old}\n#{body}" : body,
33 end.compact.sort { |a,b| b[:time] <=> a[:time] }
36 cgit_url = "http://git.bogomips.org/cgit/unicorn.git"
37 git_url = ENV['GIT_URL'] || 'git://git.bogomips.org/unicorn.git'
39 desc 'prints news as an Atom feed'
43 puts(Nokogiri::XML::Builder.new do
44 feed :xmlns => "http://www.w3.org/2005/Atom" do
45 id! "http://unicorn.bogomips.org/NEWS.atom.xml"
47 subtitle "Rack HTTP server for Unix and fast clients"
48 link! :rel => 'alternate', :type => 'text/html',
49 :href => 'http://unicorn.bogomips.org/NEWS.html'
50 updated new_tags.first[:time]
51 new_tags.each do |tag|
57 name tag[:tagger_name]
58 email tag[:tagger_email]
60 url = "#{cgit_url}/tag/?id=#{tag[:tag]}"
61 link! :rel => "alternate", :type => "text/html", :href =>url
63 message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/s).first.strip
64 content({:type =>:text}, message_only)
65 content(:type =>:xhtml) { pre tag[:body] }
72 desc 'prints RDoc-formatted news'
75 time = tag[:time].tr!('T', ' ').gsub!(/:\d\dZ/, ' UTC')
76 puts "=== #{tag[:tag].sub(/^v/, '')} / #{time}"
80 puts tag[:body].gsub(/^/sm, " ").gsub(/[ \t]+$/sm, "")
85 desc "print release changelog for Rubyforge"
86 task :release_changes do
87 version = ENV['VERSION'] or abort "VERSION= needed"
88 version = "v#{version}"
89 vtags = tags.map { |tag| tag[:tag] =~ /\Av/ and tag[:tag] }.sort
90 prev = vtags[vtags.index(version) - 1]
91 system('git', 'diff', '--stat', prev, version) or abort $?
93 system('git', 'log', "#{prev}..#{version}") or abort $?
96 desc "print release notes for Rubyforge"
97 task :release_notes do
98 spec = Gem::Specification.load('unicorn.gemspec')
99 puts spec.description.strip
101 puts "* #{spec.homepage}"
102 puts "* #{spec.email}"
105 _, _, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
106 print "\nChanges:\n\n"
114 rc = Net::Netrc.locate('unicorn-raa') or abort "~/.netrc not found"
115 password = rc.password
117 s = Gem::Specification.load('unicorn.gemspec')
118 desc = [ s.description.strip ]
120 desc << "* #{s.email}"
121 desc << "* #{git_url}"
122 desc << "* #{cgit_url}"
123 desc = desc.join("\n")
124 uri = URI.parse('http://raa.ruby-lang.org/regist.rhtml')
127 :short_description => s.summary,
128 :version => s.version.to_s,
130 :owner => s.authors.first,
132 :category_major => 'Library',
133 :category_minor => 'Web',
135 :download => "http://rubyforge.org/frs/?group_id=1306",
136 :license => "Ruby's",
137 :description_style => 'Plain',
138 :description => desc,
142 res = Net::HTTP.post_form(uri, form)
153 version = ENV['VERSION'] or abort "VERSION= needed"
154 uri = URI.parse('http://freshmeat.net/projects/unicorn/releases.json')
155 rc = Net::Netrc.locate('unicorn-fm') or abort "~/.netrc not found"
156 api_token = rc.password
157 changelog = tags.find { |t| t[:tag] == "v#{version}" }[:body]
158 tmp = Tempfile.new('fm-changelog')
159 tmp.syswrite(changelog)
160 system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
161 changelog = File.read(tmp.path).strip
164 "auth_code" => api_token,
166 "tag_list" => "Stable",
167 "version" => version,
168 "changelog" => changelog,
171 Net::HTTP.start(uri.host, uri.port) do |http|
172 p http.post(uri.path, req, {'Content-Type'=>'application/json'})
176 # optional rake-compiler support in case somebody needs to cross compile
178 mk = "ext/unicorn_http/Makefile"
180 warn "run 'gmake -C ext/unicorn_http clean' and\n" \
181 "remove #{mk} before using rake-compiler"
183 unless test ?r, "ext/unicorn_http/unicorn_http.c"
184 abort "run 'gmake ragel' or 'make ragel' to generate the Ragel source"
186 spec = Gem::Specification.load('unicorn.gemspec')
187 require 'rake/extensiontask'
188 Rake::ExtensionTask.new('unicorn_http', spec)