1 # -*- encoding: binary -*-
2 # most tasks are in the GNUmakefile which offers better parallelism
4 timefmt = '%Y-%m-%dT%H:%M:%SZ'
5 @tags ||= `git tag -l`.split(/\n/).map do |tag|
6 if %r{\Av[\d\.]+\z} =~ tag
7 header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
8 header = header.split(/\n/)
9 tagger = header.grep(/\Atagger /).first
12 :time => Time.at(tagger.split(/ /)[-2].to_i).utc.strftime(timefmt),
13 :tagger_name => %r{^tagger ([^<]+)}.match(tagger)[1].strip,
14 :tagger_email => %r{<([^>]+)>}.match(tagger)[1].strip,
15 :id => `git rev-parse refs/tags/#{tag}`.chomp!,
21 end.compact.sort { |a,b| b[:time] <=> a[:time] }
24 cgit_url = "http://git.bogomips.org/cgit/sleepy_penguin.git"
25 git_url = ENV['GIT_URL'] || 'git://git.bogomips.org/sleepy_penguin.git'
26 web_url = "http://bogomips.org/sleepy_penguin"
28 desc 'prints news as an Atom feed'
32 puts(Nokogiri::XML::Builder.new do
33 feed :xmlns => "http://www.w3.org/2005/Atom" do
34 id! "#{web_url}NEWS.atom.xml"
35 title "sleepy_penguin news"
37 link! :rel => "alternate", :type => "text/html",
38 :href => "#{web_url}NEWS.html"
39 updated(new_tags.empty? ? "1970-01-01T00:00:00Z" : new_tags.first[:time])
40 new_tags.each do |tag|
46 name tag[:tagger_name]
47 email tag[:tagger_email]
49 url = "#{cgit_url}/tag/?id=#{tag[:tag]}"
50 link! :rel => "alternate", :type => "text/html", :href =>url
52 message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/s).first.strip
53 content({:type =>:text}, message_only)
54 content(:type =>:xhtml) { pre tag[:body] }
61 desc 'prints RDoc-formatted news'
64 time = tag[:time].tr!('T', ' ').gsub!(/:\d\dZ/, ' UTC')
65 puts "=== #{tag[:tag].sub(/^v/, '')} / #{time}"
69 puts tag[:body].gsub(/^/sm, " ").gsub(/[ \t]+$/sm, "")
74 desc "print release changelog for Rubyforge"
75 task :release_changes do
76 version = ENV['VERSION'] or abort "VERSION= needed"
77 version = "v#{version}"
78 vtags = tags.map { |tag| tag[:tag] =~ /\Av/ and tag[:tag] }.sort
79 prev = vtags[vtags.index(version) - 1]
81 system('git', 'diff', '--stat', prev, version) or abort $?
83 system('git', 'log', "#{prev}..#{version}") or abort $?
85 system('git', 'log', version) or abort $?
89 desc "print release notes for Rubyforge"
90 task :release_notes do
91 spec = Gem::Specification.load('sleepy_penguin.gemspec')
92 puts spec.description.strip
94 puts "* #{spec.homepage}"
95 puts "* #{spec.email}"
98 _, _, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
99 print "\nChanges:\n\n"
103 desc "read news article from STDIN and post to rubyforge"
104 task :publish_news do
106 spec = Gem::Specification.load('sleepy_penguin.gemspec')
107 tmp = Tempfile.new('rf-news')
108 _, subject, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
111 tmp.puts spec.description.strip
113 tmp.puts "* #{spec.homepage}"
114 tmp.puts "* #{spec.email}"
115 tmp.puts "* #{git_url}"
116 tmp.print "\nChanges:\n\n"
119 system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
120 msg = File.readlines(tmp.path)
123 blank == "\n" or abort "no newline after subject!"
125 body = msg.join("").strip!
127 rf = RubyForge.new.configure
129 rf.post_news('rainbows', subject, body)
136 rc = Net::Netrc.locate('sleepy_penguin-raa') or abort "~/.netrc not found"
137 password = rc.password
139 s = Gem::Specification.load('sleepy_penguin.gemspec')
140 desc = [ s.description.strip ]
142 desc << "* #{s.email}"
143 desc << "* #{git_url}"
144 desc << "* #{cgit_url}"
145 desc = desc.join("\n")
146 uri = URI.parse('http://raa.ruby-lang.org/regist.rhtml')
149 :short_description => s.summary,
150 :version => s.version.to_s,
151 :status => 'experimental',
152 :owner => s.authors.first,
154 :category_major => 'Library',
155 :category_minor => 'System',
157 :download => 'http://rubyforge.org/frs/?group_id=8977',
159 :description_style => 'Plain',
160 :description => desc,
164 res = Net::HTTP.post_form(uri, form)