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"
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)
15 tmp.puts spec.description.strip
17 tmp.puts "* #{spec.homepage}"
18 tmp.puts "* #{spec.email}"
19 tmp.puts "* #{git_url}"
20 tmp.print "\nChanges:\n\n"
23 system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
24 msg = File.readlines(tmp.path)
27 blank == "\n" or abort "no newline after subject!"
29 body = msg.join("").strip!
31 rf = RubyForge.new.configure
33 rf.post_news('rainbows', subject, body)
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
52 "auth_code" => api_token,
54 "tag_list" => "Stable",
56 "changelog" => changelog,
59 Net::HTTP.start(uri.host, uri.port) do |http|
60 p http.post(uri.path, req, {'Content-Type'=>'application/json'})