-
Notifications
You must be signed in to change notification settings - Fork 55
/
Rakefile
39 lines (32 loc) · 863 Bytes
/
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
task :default do
system "rake --tasks"
end
desc "Build docs using docker"
task :build do
if podman?
exec "podman run --rm -it -v #{__dir__}:/doc #{image} make html"
elsif docker?
exec "docker run --rm -it -v '#{__dir__}:/doc' -u '#{user_group}' #{image} make html"
else
raise StandardError, "Cannot find any suitable container runtime to build. Need 'podman' or 'docker' installed."
end
end
desc "Open built documentation in browser"
task :open do
exec '(command -v xdg-open >/dev/null 2>&1 && xdg-open build/html/index.html) || open build/html/index.html'
end
def user_group
pwnam = Etc.getpwnam(Etc.getlogin)
"#{pwnam.uid}:#{pwnam.gid}"
end
def image
'ohiosupercomputer/ood-doc-build:v2.0.0'
end
def docker?
`which docker 2>/dev/null 2>&1`
$?.success?
end
def podman?
`which podman 2>/dev/null 2>&1`
$?.success?
end