http_server: fixup comments for PID file renaming
[unicorn.git] / Rakefile
blob01ff5d0f2604ddc1adc701151f63deb488c08064
1 # -*- encoding: binary -*-
2 autoload :Gem, 'rubygems'
3 require 'wrongdoc'
5 cgit_url = Wrongdoc.config[:cgit_url]
6 git_url = Wrongdoc.config[:git_url]
8 desc "post to FM"
9 task :fm_update do
10   require 'tempfile'
11   require 'net/http'
12   require 'net/netrc'
13   require 'json'
14   version = ENV['VERSION'] or abort "VERSION= needed"
15   uri = URI.parse('https://freecode.com/projects/unicorn/releases.json')
16   rc = Net::Netrc.locate('unicorn-fm') or abort "~/.netrc not found"
17   api_token = rc.password
18   _, subject, body = `git cat-file tag v#{version}`.split(/\n\n/, 3)
19   tmp = Tempfile.new('fm-changelog')
20   tmp.puts subject
21   tmp.puts
22   tmp.puts body
23   tmp.flush
24   system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
25   changelog = File.read(tmp.path).strip
27   req = {
28     "auth_code" => api_token,
29     "release" => {
30       "tag_list" => "Experimental",
31       "version" => version,
32       "changelog" => changelog,
33     },
34   }.to_json
36   if ! changelog.strip.empty? && version =~ %r{\A[\d\.]+\d+\z}
37     Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
38       p http.post(uri.path, req, {'Content-Type'=>'application/json'})
39     end
40   else
41     warn "not updating freshmeat for v#{version}"
42   end
43 end
45 # optional rake-compiler support in case somebody needs to cross compile
46 begin
47   mk = "ext/unicorn_http/Makefile"
48   if File.readable?(mk)
49     warn "run 'gmake -C ext/unicorn_http clean' and\n" \
50          "remove #{mk} before using rake-compiler"
51   elsif ENV['VERSION']
52     unless File.readable?("ext/unicorn_http/unicorn_http.c")
53       abort "run 'gmake ragel' or 'make ragel' to generate the Ragel source"
54     end
55     spec = Gem::Specification.load('unicorn.gemspec')
56     require 'rake/extensiontask'
57     Rake::ExtensionTask.new('unicorn_http', spec)
58   end
59 rescue LoadError
60 end