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