1 # -*- encoding: binary -*-
2 autoload :Gem, 'rubygems'
4 # most tasks are in the GNUmakefile which offers better parallelism
7 timefmt = '%Y-%m-%dT%H:%M:%SZ'
8 @tags ||= `git tag -l`.split(/\n/).map do |tag|
9 if %r{\Av[\d\.]+\z} =~ tag
10 header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
11 header = header.split(/\n/)
12 tagger = header.grep(/\Atagger /).first
15 :time => Time.at(tagger.split(/ /)[-2].to_i).utc.strftime(timefmt),
16 :tagger_name => %r{^tagger ([^<]+)}.match(tagger)[1].strip,
17 :tagger_email => %r{<([^>]+)>}.match(tagger)[1].strip,
18 :id => `git rev-parse refs/tags/#{tag}`.chomp!,
24 end.compact.sort { |a,b| b[:time] <=> a[:time] }
27 cgit_url = "http://git.bogomips.org/cgit/rainbows.git"
28 git_url = ENV['GIT_URL'] || 'git://git.bogomips.org/rainbows.git'
30 desc 'prints news as an Atom feed'
34 puts(Nokogiri::XML::Builder.new do
35 feed :xmlns => "http://www.w3.org/2005/Atom" do
36 id! "http://rainbows.rubyforge.org/NEWS.atom.xml"
37 title "Rainbows! news"
38 subtitle "Unicorn for sleepy apps and slow clients"
39 link! :rel => 'alternate', :type => 'text/html',
40 :href => 'http://rainbows.rubyforge.org/NEWS.html'
41 updated(new_tags.empty? ? "1970-01-01T00:00:00Z" : new_tags.first[:time])
42 new_tags.each do |tag|
48 name tag[:tagger_name]
49 email tag[:tagger_email]
51 url = "#{cgit_url}/tag/?id=#{tag[:tag]}"
52 link! :rel => "alternate", :type => "text/html", :href =>url
54 message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/s).first.strip
55 content({:type =>:text}, message_only)
56 content(:type =>:xhtml) { pre tag[:body] }
63 desc 'prints RDoc-formatted news'
66 time = tag[:time].tr!('T', ' ').gsub!(/:\d\dZ/, ' UTC')
67 puts "=== #{tag[:tag].sub(/^v/, '')} / #{time}"
71 puts tag[:body].gsub(/^/sm, " ").gsub(/[ \t]+$/sm, "")
76 desc "print release changelog for Rubyforge"
77 task :release_changes do
78 version = ENV['VERSION'] or abort "VERSION= needed"
79 version = "v#{version}"
80 vtags = tags.map { |tag| tag[:tag] =~ /\Av/ and tag[:tag] }.sort
81 prev = vtags[vtags.index(version) - 1]
83 system('git', 'diff', '--stat', prev, version) or abort $?
85 system('git', 'log', "#{prev}..#{version}") or abort $?
87 system('git', 'log', version) or abort $?
91 desc "print release notes for Rubyforge"
92 task :release_notes do
93 spec = Gem::Specification.load('rainbows.gemspec')
94 puts spec.description.strip
96 puts "* #{spec.homepage}"
97 puts "* #{spec.email}"
100 _, _, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
101 print "\nChanges:\n\n"
105 desc "read news article from STDIN and post to rubyforge"
106 task :publish_news do
108 IO.select([STDIN], nil, nil, 1) or abort "E: news must be read from stdin"
109 msg = STDIN.readlines
112 blank == "\n" or abort "no newline after subject!"
114 body = msg.join("").strip!
116 rf = RubyForge.new.configure
118 rf.post_news('rainbows', subject, body)
125 rc = Net::Netrc.locate('rainbows-raa') or abort "~/.netrc not found"
126 password = rc.password
128 s = Gem::Specification.load('rainbows.gemspec')
129 desc = [ s.description.strip ]
131 desc << "* #{s.email}"
132 desc << "* #{git_url}"
133 desc << "* #{cgit_url}"
134 desc = desc.join("\n")
135 uri = URI.parse('http://raa.ruby-lang.org/regist.rhtml')
138 :short_description => s.summary,
139 :version => s.version.to_s,
140 :status => 'experimental',
141 :owner => s.authors.first,
143 :category_major => 'Library',
144 :category_minor => 'Web',
146 :download => "http://rubyforge.org/frs/?group_id=8977",
147 :license => "Ruby's",
148 :description_style => 'Plain',
149 :description => desc,
153 res = Net::HTTP.post_form(uri, form)
164 version = ENV['VERSION'] or abort "VERSION= needed"
165 uri = URI.parse('http://freshmeat.net/projects/rainbows/releases.json')
166 rc = Net::Netrc.locate('rainbows-fm') or abort "~/.netrc not found"
167 api_token = rc.password
168 changelog = tags.find { |t| t[:tag] == "v#{version}" }[:body]
169 tmp = Tempfile.new('fm-changelog')
170 tmp.syswrite(changelog)
171 system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
172 changelog = File.read(tmp.path).strip
175 "auth_code" => api_token,
177 "tag_list" => "Stable",
178 "version" => version,
179 "changelog" => changelog,
182 Net::HTTP.start(uri.host, uri.port) do |http|
183 p http.post(uri.path, req, {'Content-Type'=>'application/json'})