forked from kanidm/kanidm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_all_the_docs.sh
More file actions
executable file
·65 lines (53 loc) · 1.68 KB
/
build_all_the_docs.sh
File metadata and controls
executable file
·65 lines (53 loc) · 1.68 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
#!/bin/bash
git config --global pull.ff only
DOCS_DIR="/tmp/kanidm_docs"
echo "DOCS DIR: ${DOCS_DIR}"
echo "PWD: $(pwd)"
function build_version() {
BOOK_VERSION=$1
echo "Book version: ${BOOK_VERSION}"
echo "<li><a href=\"/kanidm/${BOOK_VERSION}\">${BOOK_VERSION}</a></li>" >> "${DOCS_DIR}/index.html"
git switch -c "${BOOK_VERSION}" || git switch "${BOOK_VERSION}"
git pull origin "${BOOK_VERSION}"
echo "Running mdbook build"
mdbook build kanidm_book
echo "Running cargo doc"
cargo doc --quiet --no-deps
echo "Moving book to ${DOCS_DIR}/${BOOK_VERSION}/"
mv ./kanidm_book/book/ "${DOCS_DIR}/${BOOK_VERSION}/"
echo "Moving rustdoc to ${DOCS_DIR}/${BOOK_VERSION}/rustdoc/"
mkdir -p "${DOCS_DIR}/${BOOK_VERSION}/rustdoc/"
mv ./target/doc/* "${DOCS_DIR}/${BOOK_VERSION}/rustdoc/"
}
echo "Cleaning old docs dir"
rm -rf "${DOCS_DIR}"
mkdir -p "${DOCS_DIR}"
cat > "${DOCS_DIR}/index.html" <<-'EOM'
<html>
<head>
<title>kanidm docs root</title>
</head>
<body>
<h1>Kanidm docs</h1>
<ul>
EOM
LATEST="$(git tag -l 'v*' --sort "-version:refname" | grep -v '1.1.0alpha' | head -n1)"
{
echo "<li><strong><a href=\"/kanidm/master/\">Latest Dev Version</a></strong></li>"
echo "<li><strong><a href=\"/kanidm/stable/\">Latest Stable Version (${LATEST})</a></strong></li>"
} >> "${DOCS_DIR}/index.html"
# build the current head
build_version master
# build all the other versions
for version in $(git tag -l 'v*' --sort "-version:refname" | grep -v '1.1.0alpha'); do
echo "$version"
build_version "${version}"
done
cat >> "${DOCS_DIR}/index.html" <<-'EOM'
</ul>
</body>
</html>
EOM
ls -la "${DOCS_DIR}"
mv "${DOCS_DIR}" ./docs/
ln -s "${LATEST}" ./docs/stable