Rakefile: kill raa_update task
[local-openid.git] / Rakefile
blobe96349a47416a07d92e6121a67271a1c22ad64b7
1 # -*- encoding: binary -*-
2 require 'wrongdoc'
3 cgit_url = Wrongdoc.config[:cgit_url]
4 git_url = Wrongdoc.config[:git_url]
6 desc "post news article to rubyforge"
7 task :publish_news do
8   require 'rubyforge'
9   spec = Gem::Specification.load('local-openid.gemspec')
10   tmp = Tempfile.new('rf-news')
11   _, subject, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
12   tmp.puts subject
13   tmp.puts
14   tmp.puts spec.description.strip
15   tmp.puts ""
16   tmp.puts "* #{spec.homepage}"
17   tmp.puts "* #{spec.email}"
18   tmp.puts "* #{git_url}"
19   tmp.print "\nChanges:\n\n"
20   tmp.puts body
21   tmp.flush
22   system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
23   msg = File.readlines(tmp.path)
24   subject = msg.shift
25   blank = msg.shift
26   blank == "\n" or abort "no newline after subject!"
27   subject.strip!
28   body = msg.join("").strip!
30   rf = RubyForge.new.configure
31   rf.login
32   rf.post_news('qrp', subject, body)
33 end
35 desc "post to FM"
36 task :fm_update do
37   require 'tempfile'
38   require 'net/http'
39   require 'net/netrc'
40   require 'json'
41   version = ENV['VERSION'] or abort "VERSION= needed"
42   uri = URI.parse('https://freecode.com/projects/local-openid/releases.json')
43   rc = Net::Netrc.locate('local-openid-fm') or abort "~/.netrc not found"
44   api_token = rc.password
45   _, subject, body = `git cat-file tag v#{version}`.split(/\n\n/, 3)
46   tmp = Tempfile.new('fm-changelog')
47   tmp.puts subject
48   tmp.puts
49   tmp.puts body
50   tmp.flush
51   system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
52   changelog = File.read(tmp.path).strip
54   req = {
55     "auth_code" => api_token,
56     "release" => {
57       "tag_list" => "Stable",
58       "version" => version,
59       "changelog" => changelog,
60     },
61   }.to_json
63   if ! changelog.strip.empty? && version =~ %r{\A[\d\.]+\d+\z}
64     Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
65       p http.post(uri.path, req, {'Content-Type'=>'application/json'})
66     end
67   else
68     warn "not updating freshmeat for v#{version}"
69   end
70 end