gemspec: loosen Sinatra version dependency
[local-openid.git] / Rakefile
blob27ba42fab396f42976ed23ca4024362691767a51
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 RAA"
36 task :raa_update do
37   require 'net/http'
38   require 'net/netrc'
39   rc = Net::Netrc.locate('local-openid-raa') or abort "~/.netrc not found"
40   password = rc.password
42   s = Gem::Specification.load('local-openid.gemspec')
43   desc = [ s.description.strip ]
44   desc << ""
45   desc << "* #{s.email}"
46   desc << "* #{git_url}"
47   desc << "* #{cgit_url}"
48   desc = desc.join("\n")
49   uri = URI.parse('http://raa.ruby-lang.org/regist.rhtml')
50   form = {
51     :name => s.name,
52     :short_description => s.summary,
53     :version => s.version.to_s,
54     :status => 'stable',
55     :owner => s.authors.first,
56     :email => s.email,
57     :category_major => 'Application',
58     :category_minor => 'WWW',
59     :url => s.homepage,
60     :download => 'http://rubyforge.org/frs/?group_id=5626',
61     :license => "OpenSource", # AGPLv3, specifically
62     :description_style => 'Plain',
63     :description => desc,
64     :pass => password,
65     :submit => "Update",
66   }
67   res = Net::HTTP.post_form(uri, form)
68   p res
69   puts res.body
70 end
72 desc "post to FM"
73 task :fm_update do
74   require 'tempfile'
75   require 'net/http'
76   require 'net/netrc'
77   require 'json'
78   version = ENV['VERSION'] or abort "VERSION= needed"
79   uri = URI.parse('http://freshmeat.net/projects/local-openid/releases.json')
80   rc = Net::Netrc.locate('local-openid-fm') or abort "~/.netrc not found"
81   api_token = rc.password
82   changelog = tags.find { |t| t[:tag] == "v#{version}" }[:body]
83   tmp = Tempfile.new('fm-changelog')
84   tmp.syswrite(changelog)
85   system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
86   changelog = File.read(tmp.path).strip
88   req = {
89     "auth_code" => api_token,
90     "release" => {
91       "tag_list" => "Stable",
92       "version" => version,
93       "changelog" => changelog,
94     },
95   }.to_json
96   Net::HTTP.start(uri.host, uri.port) do |http|
97     p http.post(uri.path, req, {'Content-Type'=>'application/json'})
98   end
99 end