about summary refs log tree commit homepage
path: root/Rakefile
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-10-18 10:28:18 +0000
committerEric Wong <normalperson@yhbt.net>2013-10-18 10:28:18 +0000
commitab067831e707b191d6dfdcd01de1f1d85fc90d05 (patch)
treeb02861eb1521fb325ee4e1d91e1a194ca73e7a9e /Rakefile
downloadyahns-ab067831e707b191d6dfdcd01de1f1d85fc90d05.tar.gz
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile60
1 files changed, 60 insertions, 0 deletions
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 <normalperson@yhbt.net> 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 <normalperson@yhbt.net>'
+  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