Rakefile: kill raa_update task
[zbatery.git] / Rakefile
blobd1ca28554484c4d2a9188a588e37c8f4f628e7e3
1 # -*- encoding: binary -*-
2 autoload :Gem, 'rubygems'
4 cgit_url = "http://bogomips.org/zbatery.git"
5 git_url = 'git://bogomips.org/zbatery.git'
7 desc "read news article from STDIN and post to rubyforge"
8 task :publish_news do
9   require 'rubyforge'
10   spec = Gem::Specification.load('zbatery.gemspec')
11   tmp = Tempfile.new('rf-news')
12   _, subject, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
13   tmp.puts subject
14   tmp.puts
15   tmp.puts spec.description.strip
16   tmp.puts ""
17   tmp.puts "* #{spec.homepage}"
18   tmp.puts "* #{spec.email}"
19   tmp.puts "* #{git_url}"
20   tmp.print "\nChanges:\n\n"
21   tmp.puts body
22   tmp.flush
23   system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
24   msg = File.readlines(tmp.path)
25   subject = msg.shift
26   blank = msg.shift
27   blank == "\n" or abort "no newline after subject!"
28   subject.strip!
29   body = msg.join("").strip!
31   rf = RubyForge.new.configure
32   rf.login
33   rf.post_news('rainbows', subject, body)
34 end
36 desc "post to FM"
37 task :fm_update do
38   require 'tempfile'
39   require 'net/http'
40   require 'net/netrc'
41   require 'json'
42   version = ENV['VERSION'] or abort "VERSION= needed"
43   uri = URI.parse('http://freecode.com/projects/zbatery/releases.json')
44   rc = Net::Netrc.locate('zbatery-fm') or abort "~/.netrc not found"
45   api_token = rc.password
46   _, subject, body = `git cat-file tag v#{version}`.split(/\n\n/, 3)
47   tmp = Tempfile.new('fm-changelog')
48   system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
49   changelog = File.read(tmp.path).strip
51   req = {
52     "auth_code" => api_token,
53     "release" => {
54       "tag_list" => "Stable",
55       "version" => version,
56       "changelog" => changelog,
57     },
58   }.to_json
59   Net::HTTP.start(uri.host, uri.port) do |http|
60     p http.post(uri.path, req, {'Content-Type'=>'application/json'})
61   end
62 end