1 # -*- encoding: binary -*-
2 autoload :Gem, 'rubygems'
3 autoload :Tempfile, 'tempfile'
5 # most tasks are in the GNUmakefile which offers better parallelism
8 timefmt = '%Y-%m-%dT%H:%M:%SZ'
9 @tags ||= `git tag -l`.split(/\n/).map do |tag|
10 if %r{\Av[\d\.]+\z} =~ tag
11 header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
12 header = header.split(/\n/)
13 tagger = header.grep(/\Atagger /).first
16 :time => Time.at(tagger.split(/ /)[-2].to_i).utc.strftime(timefmt),
17 :tagger_name => %r{^tagger ([^<]+)}.match(tagger)[1].strip,
18 :tagger_email => %r{<([^>]+)>}.match(tagger)[1].strip,
19 :id => `git rev-parse refs/tags/#{tag}`.chomp!,
25 end.compact.sort { |a,b| b[:time] <=> a[:time] }
28 cgit_url = "http://git.bogomips.org/cgit/rainbows.git"
29 git_url = ENV['GIT_URL'] || 'git://git.bogomips.org/rainbows.git'
31 desc 'prints news as an Atom feed'
35 puts(Nokogiri::XML::Builder.new do
36 feed :xmlns => "http://www.w3.org/2005/Atom" do
37 id! "http://rainbows.rubyforge.org/NEWS.atom.xml"
38 title "Rainbows! news"
39 subtitle "Unicorn for sleepy apps and slow clients"
40 link! :rel => 'alternate', :type => 'text/html',
41 :href => 'http://rainbows.rubyforge.org/NEWS.html'
42 updated(new_tags.empty? ? "1970-01-01T00:00:00Z" : new_tags.first[:time])
43 new_tags.each do |tag|
49 name tag[:tagger_name]
50 email tag[:tagger_email]
52 url = "#{cgit_url}/tag/?id=#{tag[:tag]}"
53 link! :rel => "alternate", :type => "text/html", :href =>url
55 message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/s).first.strip
56 content({:type =>:text}, message_only)
57 content(:type =>:xhtml) { pre tag[:body] }
64 desc 'prints RDoc-formatted news'
67 time = tag[:time].tr!('T', ' ').gsub!(/:\d\dZ/, ' UTC')
68 puts "=== #{tag[:tag].sub(/^v/, '')} / #{time}"
72 puts tag[:body].gsub(/^/sm, " ").gsub(/[ \t]+$/sm, "")
77 desc "print release changelog for Rubyforge"
78 task :release_changes do
79 version = ENV['VERSION'] or abort "VERSION= needed"
80 version = "v#{version}"
81 vtags = tags.map { |tag| tag[:tag] =~ /\Av/ and tag[:tag] }.sort
82 prev = vtags[vtags.index(version) - 1]
84 system('git', 'diff', '--stat', prev, version) or abort $?
86 system('git', 'log', "#{prev}..#{version}") or abort $?
88 system('git', 'log', version) or abort $?
92 desc "print release notes for Rubyforge"
93 task :release_notes do
94 spec = Gem::Specification.load('rainbows.gemspec')
95 puts spec.description.strip
97 puts "* #{spec.homepage}"
98 puts "* #{spec.email}"
101 _, _, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
102 print "\nChanges:\n\n"
106 desc "read news article from STDIN and post to rubyforge"
107 task :publish_news do
109 spec = Gem::Specification.load('rainbows.gemspec')
110 tmp = Tempfile.new('rf-news')
111 _, subject, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
114 tmp.puts spec.description.strip
116 tmp.puts "* #{spec.homepage}"
117 tmp.puts "* #{spec.email}"
118 tmp.puts "* #{git_url}"
119 tmp.print "\nChanges:\n\n"
122 system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
123 msg = File.readlines(tmp.path)
126 blank == "\n" or abort "no newline after subject!"
128 body = msg.join("").strip!
130 rf = RubyForge.new.configure
132 rf.post_news('rainbows', subject, body)
139 rc = Net::Netrc.locate('rainbows-raa') or abort "~/.netrc not found"
140 password = rc.password
142 s = Gem::Specification.load('rainbows.gemspec')
143 desc = [ s.description.strip ]
145 desc << "* #{s.email}"
146 desc << "* #{git_url}"
147 desc << "* #{cgit_url}"
148 desc = desc.join("\n")
149 uri = URI.parse('http://raa.ruby-lang.org/regist.rhtml')
152 :short_description => s.summary,
153 :version => s.version.to_s,
154 :status => 'experimental',
155 :owner => s.authors.first,
157 :category_major => 'Library',
158 :category_minor => 'Web',
160 :download => "http://rubyforge.org/frs/?group_id=8977",
161 :license => "Ruby's",
162 :description_style => 'Plain',
163 :description => desc,
167 res = Net::HTTP.post_form(uri, form)
177 version = ENV['VERSION'] or abort "VERSION= needed"
178 uri = URI.parse('http://freshmeat.net/projects/rainbows/releases.json')
179 rc = Net::Netrc.locate('rainbows-fm') or abort "~/.netrc not found"
180 api_token = rc.password
181 changelog = tags.find { |t| t[:tag] == "v#{version}" }[:body]
182 tmp = Tempfile.new('fm-changelog')
183 tmp.syswrite(changelog)
184 system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
185 changelog = File.read(tmp.path).strip
188 "auth_code" => api_token,
190 "tag_list" => "Stable",
191 "version" => version,
192 "changelog" => changelog,
195 Net::HTTP.start(uri.host, uri.port) do |http|
196 p http.post(uri.path, req, {'Content-Type'=>'application/json'})