From 8301a96e8f11f668a717afbdf95f3695cdc9ca3b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 1 Feb 2011 07:08:30 +0000 Subject: add update-freshmeat script We use it to... update freshmeat! --- update-freshmeat.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 update-freshmeat.rb diff --git a/update-freshmeat.rb b/update-freshmeat.rb new file mode 100755 index 0000000..9f9252e --- /dev/null +++ b/update-freshmeat.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby +require "tempfile" +require "net/http" +require "net/netrc" +require "json" +version = ENV["VERSION"] or abort "VERSION= needed" +uri = URI.parse("http://freshmeat.net/projects/libnodelay/releases.json") +rc = Net::Netrc.locate("libnodelay-fm") or abort "~/.netrc not found" +api_token = rc.password +_, subject, body = `git cat-file tag v#{version}`.split(/\n\n/, 3) +tmp = Tempfile.new("fm-changelog") +tmp.puts subject +tmp.puts +tmp.puts body +tmp.flush +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 + +if ! changelog.strip.empty? && version =~ %r{\A[\d\.]+\d+\z} + Net::HTTP.start(uri.host, uri.port) do |http| + p http.post(uri.path, req, {"Content-Type"=>"application/json"}) + end +else + warn "not updating freshmeat for v#{version}" +end -- cgit v1.2.3-24-ge0c7