1 # -*- encoding: binary -*-
2 autoload :Gem, 'rubygems'
3 autoload :Tempfile, 'tempfile'
6 cgit_url = Wrongdoc.config[:cgit_url]
7 git_url = Wrongdoc.config[:git_url]
9 desc "read news article from STDIN and post to rubyforge"
12 spec = Gem::Specification.load('rainbows.gemspec')
13 tmp = Tempfile.new('rf-news')
14 _, subject, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
17 tmp.puts spec.description.strip
19 tmp.puts "* #{spec.homepage}"
20 tmp.puts "* #{spec.email}"
21 tmp.puts "* #{git_url}"
22 tmp.print "\nChanges:\n\n"
25 system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
26 msg = File.readlines(tmp.path)
29 blank == "\n" or abort "no newline after subject!"
31 body = msg.join("").strip!
33 rf = RubyForge.new.configure
35 rf.post_news('rainbows', subject, body)
43 version = ENV['VERSION'] or abort "VERSION= needed"
44 uri = URI.parse('https://freecode.com/projects/rainbows/releases.json')
45 rc = Net::Netrc.locate('rainbows-fm') or abort "~/.netrc not found"
46 api_token = rc.password
47 _, subject, body = `git cat-file tag v#{version}`.split(/\n\n/, 3)
48 tmp = Tempfile.new('fm-changelog')
53 system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
54 changelog = File.read(tmp.path).strip
57 "auth_code" => api_token,
59 "tag_list" => "Stable",
61 "changelog" => changelog,
64 if ! changelog.strip.empty? && version =~ %r{\A[\d\.]+\d+\z}
65 Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
66 p http.post(uri.path, req, {'Content-Type'=>'application/json'})
69 warn "not updating freshmeat for v#{version}"