about summary refs log tree commit homepage
path: root/Rakefile
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-12-13 12:39:01 -0800
committerEric Wong <normalperson@yhbt.net>2009-12-13 12:39:01 -0800
commit613cf0e32e6060befaae848a0f7d994565f293af (patch)
treea8536d436dc25afa1cce4ca04cc92dc60ebf8b15 /Rakefile
parent33a65633ee9ba4b9b7383124af09eb399616df54 (diff)
downloadrainbows-613cf0e32e6060befaae848a0f7d994565f293af.tar.gz
* cleanup NEWS.atom.xml feed
* add freshmeat update task
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile33
1 files changed, 32 insertions, 1 deletions
diff --git a/Rakefile b/Rakefile
index 986353a..3cfc6be 100644
--- a/Rakefile
+++ b/Rakefile
@@ -50,7 +50,9 @@ task :news_atom do
           url = "#{cgit_url}/tag/?id=#{tag[:tag]}"
           link! :rel => "alternate", :type => "text/html", :href =>url
           id! url
-          content({:type => 'text'}, tag[:body])
+          message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/s).first.strip
+          content({:type =>:text}, message_only)
+          content(:type =>:xhtml) { pre tag[:body] }
         end
       end
     end
@@ -154,3 +156,32 @@ task :raa_update do
   p res
   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