-
Notifications
You must be signed in to change notification settings - Fork 20
/
Rakefile
43 lines (37 loc) · 1.3 KB
/
Rakefile
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
# frozen_string_literal: true
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
desc 'Run resort specs'
RSpec::Core::RakeTask.new
require 'yard'
YARD::Rake::YardocTask.new(:docs) do |t|
t.files = ['lib/**/*.rb']
t.options = ['-m', 'markdown', '--no-private', '-r', 'Readme.md', '--title', 'Resort documentation']
end
site = 'doc'
source_branch = 'master'
deploy_branch = 'gh-pages'
desc 'generate and deploy documentation website to github pages'
multitask :pages do
puts ">>> Deploying #{deploy_branch} branch to Github Pages <<<"
require 'git'
repo = Git.open('.')
puts "\n>>> Checking out #{deploy_branch} branch <<<\n"
repo.branch(deploy_branch.to_s).checkout
(Dir['*'] - [site]).each { |f| rm_rf(f) }
Dir["#{site}/*"].each { |f| mv(f, './') }
rm_rf(site)
puts "\n>>> Moving generated site files <<<\n"
Dir['**/*'].each { |f| repo.add(f) }
repo.status.deleted.each { |f, _s| repo.remove(f) }
puts "\n>>> Commiting: Site updated at #{Time.now.utc} <<<\n"
message = ENV['MESSAGE'] || "Site updated at #{Time.now.utc}"
repo.commit(message)
puts "\n>>> Pushing generated site to #{deploy_branch} branch <<<\n"
repo.push
puts "\n>>> Github Pages deploy complete <<<\n"
repo.branch(source_branch.to_s).checkout
end
task doc: [:docs]
task default: [:spec]