Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 66 lines (54 sloc) 1.603 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
require "time"

desc "Build the manual"
task :man do
  ENV['RONN_MANUAL'] = "Foreman Manual"
  ENV['RONN_ORGANIZATION'] = "Foreman #{Foreman::VERSION}"
  sh "ronn -w -s toc -r5 --markdown man/*.ronn"
end

desc "Commit the manual to git"
task "man:commit" => :man do
  sh "git add README.md"
  sh "git commit -am 'update docs' || echo 'nothing to commit'"
end

desc "Generate the Github docs"
task :pages => "man:commit" do
  sh %{
cp man/foreman.1.html /tmp/foreman.1.html
git checkout gh-pages
rm ./index.html
cp /tmp/foreman.1.html ./index.html
git add -u index.html
git commit -m "saving man page to github docs"
git push origin -f gh-pages
git checkout master
}
end

def latest_release
  latest = File.read("Changelog.md").split("\n").first.split(" ")[1]
end

def newer_release
  tags = %x{ git tag --contains v#{latest_release} | grep -v pre }.split("\n").sort_by do |tag|
    Gem::Version.new(tag[1..-1])
  end
  tags[1]
end

desc "Generate a Changelog"
task :changelog do
  while release = newer_release
    entry = %x{ git show --format="%cd" #{release} | head -n 1 }
    date = Time.parse(entry.chomp).strftime("%Y-%m-%d")

    message = "## #{release[1..-1]} (#{date})\n\n"
    message += %x{ git log --format="* %s [%an]" v#{latest_release}..#{release} }

    changelog = File.read("Changelog.md")
    changelog = message + "\n" + changelog

    puts release

    File.open("Changelog.md", "w") do |file|
      file.print changelog
    end
  end
end

desc "Cut a release"
task :release do
  Rake::Task["changelog"].invoke
  Rake::Task["pages"].invoke
end
Something went wrong with that request. Please try again.