From ab067831e707b191d6dfdcd01de1f1d85fc90d05 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 18 Oct 2013 10:28:18 +0000 Subject: initial commit --- Rakefile | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Rakefile (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..5d36835 --- /dev/null +++ b/Rakefile @@ -0,0 +1,60 @@ +# Copyright (C) 2013, Eric Wong and all contributors +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +require 'tempfile' +include Rake::DSL +task "NEWS" do + latest = nil + fp = Tempfile.new("NEWS", ".") + fp.sync = true + `git tag -l`.split(/\n/).reverse.each do |tag| + %r{\Av(.+)} =~ tag or next + version = $1 + header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3) + header = header.split(/\n/) + tagger = header.grep(/\Atagger /)[0] + time = Time.at(tagger.split(/ /)[-2].to_i).utc + latest ||= time + date = time.strftime("%Y-%m-%d") + fp.puts "# #{version} / #{date}\n\n#{subject}" + if body && body.strip.size > 0 + fp.puts "\n\n#{body}" + end + fp.puts + end + fp.write("Unreleased\n\n") unless fp.size > 0 + fp.puts "# COPYRIGHT" + bdfl = 'Eric Wong ' + fp.puts "Copyright (C) 2013, #{bdfl} and all contributors" + fp.puts "License: GPLv3 or later (http://www.gnu.org/licenses/gpl-3.0.txt)" + fp.rewind + assert_equal fp.read, File.read("NEWS") rescue nil + fp.chmod 0644 + File.rename(fp.path, "NEWS") + fp.close! +end + +task rsync_docs: "NEWS" do + dest = ENV["RSYNC_DEST"] || "yahns.yhbt.net:/srv/yahns/" + top = %w(NEWS README COPYING) + files = [] + + # git-set-file-times is distributed with rsync, + # Also available at: http://yhbt.net/git-set-file-times + # on Debian systems: /usr/share/doc/rsync/scripts/git-set-file-times.gz + sh("git", "set-file-times", "examples", *top) + + `git ls-files Documentation/*.txt`.split(/\n/).concat(top).each do |txt| + gz = "#{txt}.gz" + tmp = "#{gz}.#$$" + sh("gzip -9 < #{txt} > #{tmp}") + st = File.stat(txt) + File.utime(st.atime, st.mtime, tmp) # make nginx gzip_static happy + File.rename(tmp, gz) + files << txt + files << gz + end + sh("rsync --chmod=Fugo=r -av #{files.join(' ')} #{dest}") + + examples = `git ls-files examples`.split("\n") + sh("rsync --chmod=Fugo=r -av #{examples.join(' ')} #{dest}/examples/") +end -- cgit v1.2.3-24-ge0c7