-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_gh-pages_doc
executable file
·106 lines (91 loc) · 3.42 KB
/
update_gh-pages_doc
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
#!/bin/bash
# Update gh-pages doc
# ====================
#
# This script allows to automatically update the generated documentation on the
# gh-pages branch.
#
# To use it:
#
# 1. Be sure that you're on a clean (no staged files and no diff) main
# branch.
#
# 2. Call this script.
# Some user interactions will be needed to avoid doing unwanted commits.
#
# 3. That's it!
# A commit should have been pushed to the gh-pages.
set -e
current_branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
current_version=$(npm run --silent getVersion)
if ! [ "$current_branch" == "main" ]; then
echo $current_branch
echo "ERROR: The current branch should be main"
exit 1;
fi
# Generate documentation
npm run doc
if [ -n "$(git status --porcelain doc)" ]; then
echo "ERROR: Please commit your modifications to main"
exit 1;
fi
tmpDir=$(mktemp -d)
tmpDocList=$(mktemp)
cp -r doc-build/* $tmpDir
cp generate_documentation_list.mjs $tmpDocList -v
# update gh-pages
git checkout gh-pages
git pull origin gh-pages
rm -rf "versions/$current_version/doc"
mkdir -p "versions/$current_version/doc"
rm -rf doc
mv $tmpDir/* "versions/$current_version/doc"
ln -s "./versions/$current_version/doc" doc
mv $tmpDocList generate_documentation_list.mjs
node generate_documentation_list.mjs
rm generate_documentation_list.mjs
if [ -n "$(git status --porcelain doc "versions/$current_version/doc" documentation_pages_by_version.html)" ]; then
echo "-- Current Status on gh-pages: --"
echo ""
git status doc "versions/$current_version/doc" documentation_pages_by_version.html
while : ; do
echo ""
echo "We will push the documentation to gh-pages."
REPLY=""
read -p "do you want to continue [y/d/s/a/c/t/h] (h for help) ? " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Hh](elp)?$ ]]; then
echo ""
echo ""
echo "+- help -------------------------------------------------+"
echo "| y: commit and continue |"
echo "| d: see diff |"
echo "| s: see status |"
echo "| a: abort script from here |"
echo "| c: checkout from this commit and go to the next one |"
echo "| t: stash this commit and go to the next one |"
echo "| h: see this help |"
echo "+--------------------------------------------------------+"
elif [[ $REPLY =~ ^[Yy](es)?$ ]]; then
git add doc "versions/$current_version/doc" documentation_pages_by_version.html
git commit -m "doc: deploy $current_version to the gh-pages" -S
git push origin gh-pages
break
elif [[ $REPLY =~ ^[Dd](iff)?$ ]]; then
git diff doc "versions/$current_version/doc" documentation_pages_by_version.html || true # ignore when return 1
elif [[ $REPLY =~ ^[Ss](tatus)?$ ]]; then
git status doc "versions/$current_version/doc" documentation_pages_by_version.html
elif [[ $REPLY =~ ^[Aa](bort)?$ ]]; then
echo "exiting"
exit 0
elif [[ $REPLY =~ ^[Cc](heckout)?$ ]]; then
git checkout doc "versions/$current_version/doc" documentation_pages_by_version.html
elif [[ $REPLY =~ ^([Tt]|([Ss]tash))?$ ]]; then
git stash -u push doc "versions/$current_version/doc" documentation_pages_by_version.html
break
fi
done
else
echo "nothing to do on the gh-pages branch"
fi
git checkout main