-
Notifications
You must be signed in to change notification settings - Fork 20
/
deploy_docs.sh
executable file
·51 lines (40 loc) · 1.81 KB
/
deploy_docs.sh
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
# Arguments:
# $1 : path to mathlib from working directory (mathlib: ".", doc-gen: "mathlib")
# $2 : path to doc-gen from mathlib (mathlib: "doc-gen", doc-gen: "..")
# $3 : path to mathlib from doc-gen (mathlib: "..", doc-gen: "mathlib")
# $4 : github organization to deploy to
# $5 : github repo to deploy to
# $6 : whether to deploy ("true"/"false")
DEPLOY_GITHUB_USER=leanprover-community-bot
set -e
set -x
cd $1
lean_version="$(sed '/^lean_version/!d;s/.*"\(.*\)".*/\1/' leanpkg.toml)"
mathlib_short_git_hash="$(git log -1 --pretty=format:%h)"
mathlib_git_hash="$(git rev-parse HEAD)"
cd $2
docgen_git_hash="$(git log -1 --pretty=format:%h)"
# use the commit hash in mathlib's leanpkg.toml in doc_gen's leanpkg.toml
sed -i "s/rev = \"\S*\"/rev = \"$mathlib_git_hash\"/" leanpkg.toml
echo -e "builtin_path\npath ./src\npath $3/src" > leanpkg.path
git clone "https://$DEPLOY_GITHUB_USER:[email protected]/$4/$5.git" mathlib_docs
# skip if docs for this commit have already been generated
if [ "$(cd mathlib_docs && git log -1 --pretty=format:%s)" == "automatic update to mathlib $mathlib_short_git_hash using doc-gen $docgen_git_hash" ]; then
exit 0
fi
rm -rf mathlib_docs/docs/
# Force doc_gen project to match the Lean version used in CI.
# If they are incompatible, something in doc_gen will fail to compile,
# but this is better than trying to recompile all of mathlib.
elan override set "$lean_version"
./gen_docs -w "https://$4.github.io/$5/" \
-r "$3/" -t "mathlib_docs/docs/"
if [ "$6" = "true" ]; then
cd mathlib_docs/docs
git config user.email "[email protected]"
git config user.name "leanprover-community-bot"
git add -A .
git checkout --orphan master2
git commit -m "automatic update to mathlib $mathlib_short_git_hash using doc-gen $docgen_git_hash"
git push -f origin HEAD:master
fi