diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-12-07 02:03:30 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-12-07 02:03:30 -0800 |
commit | 48e206052201d4b5c86f02c9e2fb5772f5a2775d (patch) | |
tree | 1f5c2a61bea11cb76bb050bd5d98e4623e0422cd | |
parent | 6421d6af3aeffb36befd1159c8f58db01d252ecf (diff) | |
download | unicorn-48e206052201d4b5c86f02c9e2fb5772f5a2775d.tar.gz |
No more having bother with a clunky web browser \o/
-rw-r--r-- | Rakefile | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -146,6 +146,35 @@ task :raa_update do puts res.body end +desc "post to FM" +task :fm_update do + require 'tempfile' + require 'net/http' + require 'net/netrc' + require 'json' + version = ENV['VERSION'] or abort "VERSION= needed" + uri = URI.parse('http://freshmeat.net/projects/unicorn/releases.json') + rc = Net::Netrc.locate('unicorn-fm') or abort "~/.netrc not found" + api_token = rc.password + changelog = tags.find { |t| t[:tag] == "v#{version}" }[:body] + tmp = Tempfile.new('fm-changelog') + tmp.syswrite(changelog) + system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?" + changelog = File.read(tmp.path).strip + + req = { + "auth_code" => api_token, + "release" => { + "tag_list" => "Stable", + "version" => version, + "changelog" => changelog, + }, + }.to_json + Net::HTTP.start(uri.host, uri.port) do |http| + p http.post(uri.path, req, {'Content-Type'=>'application/json'}) + end +end + # optional rake-compiler support in case somebody needs to cross compile begin require 'rubygems' |