forked from opengeospatial/geopackage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
49 lines (39 loc) · 1.38 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
44
45
46
47
48
49
require 'fileutils'
task :init_local do
Dir.mkdir 'build' unless File.directory? 'build'
end
task :generate do
system './runasciidoctor -D build/spec -a stylesheet=./asciidoctor.css ./spec/index.adoc'
FileUtils.cp_r 'images/.', 'build/spec'
FileUtils.cp_r 'stylesheets/.', 'build/spec'
end
desc 'Generate site'
task :build => [:init_local, :generate]
task :init_travis do
repo = %x(git config remote.origin.url).gsub(/^git:/, 'https:').strip
deploy_branch = 'gh-pages'
system "git clone --depth 1 -b #{deploy_branch} #{repo} build"
Dir.chdir 'build/spec'
system 'git rm -r .'
Dir.chdir '../..'
end
task :publish do
Dir.chdir 'build'
system "git config user.name '#{ENV['GIT_NAME']}'"
system "git config user.email '#{ENV['GIT_EMAIL']}'"
system 'git config credential.helper "store --file=.git/credentials"'
File.open('.git/credentials', 'w') do |f|
f.write("https://#{ENV['GH_TOKEN']}:@github.com")
end
system 'git add *'
system 'git commit -m "Publish specification to github pages"'
system 'git config --global push.default simple'
system 'git push origin'
File.delete '.git/credentials'
end
desc 'Generate site from Travis CI and publish site to GitHub Pages'
task :travis => [:init_travis, :build, :publish]
unless ENV['TRAVIS_PULL_REQUEST'].to_s.to_i > 0
# Only publish when we're not building to validate a pull request
task :travis => [:publish]
end