-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgenerate-gh-page.sh
More file actions
executable file
·113 lines (87 loc) · 3.13 KB
/
Copy pathgenerate-gh-page.sh
File metadata and controls
executable file
·113 lines (87 loc) · 3.13 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
# Referenced from
# https://gist.github.com/domenic/ec8b0fc8ab45f39403dd<Paste>
#
# Exit with nonzero exit code if anything fails
set -e
echo "cmake path: $(which cmake)"
echo "cmake version: $(cmake --version)"
# SOURCE_BRANCH="master"
TARGET_BRANCH="gh-pages"
function doCompileCXX {
echo "Compile for C++"
mkdir buildC_gh-page
cd buildC_gh-page
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ..
make document
cd html
echo -e '\n' | cat - index.html > temp && mv temp index.html
echo -e '---' | cat - index.html > temp && mv temp index.html
echo -e 'title: C++ Documentation' | cat - index.html > temp && mv temp index.html
echo -e 'sidebar_link: true' | cat - index.html > temp && mv temp index.html
echo -e '---' | cat - index.html > temp && mv temp index.html
cd ../..
# Update gh-pages
rm -rf out/CXX || true
mv buildC_gh-page/html/ out/CXX
rm -rf buildC_gh-page
}
function doCompileR {
echo "Compile for R"
cd RAnalogs/releases
rm -rf RAnEn || true
unamestr=$(uname)
if [[ "$unamestr" == 'Darwin' ]]; then
tar xopf RAnEn_latest.tar.gz
else
tar -xvzf RAnEn_latest.tar.gz
fi
cd RAnEn
Rscript ../../../notes/generate_site.R
cd docs
echo -e '\n' | cat - index.html > temp && mv temp index.html
echo -e '---' | cat - index.html > temp && mv temp index.html
echo -e 'title: R Documentation' | cat - index.html > temp && mv temp index.html
echo -e 'sidebar_link: true' | cat - index.html > temp && mv temp index.html
echo -e '---' | cat - index.html > temp && mv temp index.html
cd ../../../../
# Update gh-pages
rm -rf out/R || true
mv RAnalogs/releases/RAnEn/docs out/R
}
function doGenerateNewsPost {
echo "Generate changelog site"
cd out
cp ../NEWS.md Changelog.md
postName=Changelog.md
echo -e '\n' | cat - $postName > temp && mv temp $postName
echo -e '---' | cat - $postName > temp && mv temp $postName
echo -e 'sidebar_link: true' | cat - $postName > temp && mv temp $postName
echo -e 'title: Changelog' | cat - $postName > temp && mv temp $postName
echo -e 'layout: page' | cat - $postName > temp && mv temp $postName
echo -e '---' | cat - $postName > temp && mv temp $postName
cd ..
}
# Save some useful information
REPO=$(git config remote.origin.url)
# SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
# SHA=$(git rev-parse --verify HEAD)
# Clone the existing gh-pages for this repo into out/
# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
git clone "$REPO" out
cd out
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
rm README.md
cp ../README.md .
cp ../README.md ./doc.md
echo -e '\n' | cat - doc.md > temp && mv temp doc.md
echo -e '---' | cat - doc.md > temp && mv temp doc.md
echo -e 'layout: default' | cat - doc.md > temp && mv temp doc.md
echo -e '---' | cat - doc.md > temp && mv temp doc.md
cd ..
# Call the compile functions
doGenerateNewsPost
doCompileCXX
doCompileR
echo "Build is done. Please deploy the document manually. The updated gh-page is in the folder out/"
exit 0