forked from mpv-player/mpv.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
52 lines (49 loc) · 1.89 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
52
def rst2html
xs = %w(rst2html rst2html.py)
xs = xs.map {|x| `which #{x}`.chomp}.delete_if {|x| x == ""}
r = xs[0]
r || (raise "rst2html not found")
end
desc "Builds mpv's manual"
task :build_mpv_manual do
unless File.exists?('mpv')
system "git clone https://github.com/mpv-player/mpv.git mpv"
end
system("cd mpv && git checkout master && git pull origin master")
system([
rst2html,
'--template=rst2html_template',
'--strip-elements-with-class=contents',
'--no-toc-backlinks',
'mpv/DOCS/man/mpv.rst',
'source/manual/_master.html.erb'
].join(' '))
system("echo $(cd mpv && git tag -l --contains $(git tag -l --contains $(git rev-list --tags --max-count=1 | head -c16) | tail -1 | head -c16)) > source/manual/_stable_version.html.erb")
system("cd mpv && git checkout $(git tag -l --contains $(git tag -l --contains $(git rev-list --tags --max-count=1 | head -c16) | tail -1 | head -c16))")
system([
rst2html,
'--template=rst2html_template',
'--strip-elements-with-class=contents',
'--no-toc-backlinks',
'mpv/DOCS/man/mpv.rst',
'source/manual/_stable.html.erb'
].join(' '))
end
desc 'Generate site from Travis CI and publish site to GitHub Pages'
task :travis => :build_mpv_manual do
# use public URL for clone
system "git clone https://github.com/mpv-player/mpv-player.github.io.git build"
system "bundle exec middleman build --verbose"
system "cd build && git config user.name 'nadeko'"
system "cd build && git config user.email 'nadeko@travis'"
system 'cd build && git config credential.helper "store --file=.git/credentials"'
File.open('build/.git/credentials', 'w') do |f|
f.write("https://#{ENV['GH_TOKEN']}:@github.com")
end
system [
"cd build",
"git add -A .",
"git commit -m 'travis autodeploy #{ENV['TRAVIS_COMMIT_RANGE']}'",
"git push origin master" ].join(" && ")
File.delete 'build/.git/credentials'
end