forked from opengeospatial/geopackage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
51 lines (40 loc) · 1.36 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
50
51
require 'fileutils'
task :init_local do
Dir.mkdir 'build' unless File.directory? 'build'
end
task :generate do
system './runasciidoctor -D build ./index.adoc'
FileUtils.cp_r 'images/.', 'build'
end
desc 'Generate site'
task :build => [:init_local, :generate]
task :init_travis do
# if this is a pull request, do a simple build of the site and stop
if ENV['TRAVIS_PULL_REQUEST'].to_s.to_i > 0
puts 'Pull request detected. Executing build only.'
system './runasciidoctor ./index.adoc'
next
end
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'
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]