1 # -*- encoding: binary -*-
2 autoload :Gem, 'rubygems'
5 timefmt = '%Y-%m-%dT%H:%M:%SZ'
6 @tags ||= `git tag -l`.split(/\n/).map do |tag|
7 if %r{\Av[\d\.]+\z} =~ tag
8 header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
9 header = header.split(/\n/)
10 tagger = header.grep(/\Atagger /).first
13 :time => Time.at(tagger.split(/ /)[-2].to_i).utc.strftime(timefmt),
14 :tagger_name => %r{^tagger ([^<]+)}.match(tagger)[1].strip,
15 :tagger_email => %r{<([^>]+)>}.match(tagger)[1].strip,
16 :id => `git rev-parse refs/tags/#{tag}`.chomp!,
22 end.compact.sort { |a,b| b[:time] <=> a[:time] }
25 cgit_url = "http://git.bogomips.org/cgit/local-openid.git"
26 git_url = ENV['GIT_URL'] || 'git://git.bogomips.org/local-openid.git'
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! "http://bogomips.org/local-openid/NEWS.atom.xml"
35 title "local-openid news"
36 subtitle %q{Single User, Ephemeral OpenID Provider}
37 link! :rel => 'alternate', :type => 'text/html',
38 :href => 'http://bogomips.org/local-openid/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('local-openid.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 IO.select([STDIN], nil, nil, 1) or abort "E: news must be read from stdin"
107 msg = STDIN.readlines
110 blank == "\n" or abort "no newline after subject!"
112 body = msg.join("").strip!
114 rf = RubyForge.new.configure
116 rf.post_news('qrp', subject, body)
123 rc = Net::Netrc.locate('local-openid-raa') or abort "~/.netrc not found"
124 password = rc.password
126 s = Gem::Specification.load('local-openid.gemspec')
127 desc = [ s.description.strip ]
129 desc << "* #{s.email}"
130 desc << "* #{git_url}"
131 desc << "* #{cgit_url}"
132 desc = desc.join("\n")
133 uri = URI.parse('http://raa.ruby-lang.org/regist.rhtml')
136 :short_description => s.summary,
137 :version => s.version.to_s,
139 :owner => s.authors.first,
141 :category_major => 'Application',
142 :category_minor => 'WWW',
144 :download => 'http://rubyforge.org/frs/?group_id=5626',
145 :license => "OpenSource", # AGPLv3, specifically
146 :description_style => 'Plain',
147 :description => desc,
151 res = Net::HTTP.post_form(uri, form)
162 version = ENV['VERSION'] or abort "VERSION= needed"
163 uri = URI.parse('http://freshmeat.net/projects/local-openid/releases.json')
164 rc = Net::Netrc.locate('local-openid-fm') or abort "~/.netrc not found"
165 api_token = rc.password
166 changelog = tags.find { |t| t[:tag] == "v#{version}" }[:body]
167 tmp = Tempfile.new('fm-changelog')
168 tmp.syswrite(changelog)
169 system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
170 changelog = File.read(tmp.path).strip
173 "auth_code" => api_token,
175 "tag_list" => "Stable",
176 "version" => version,
177 "changelog" => changelog,
180 Net::HTTP.start(uri.host, uri.port) do |http|
181 p http.post(uri.path, req, {'Content-Type'=>'application/json'})