2022-01-06 21:55:29 +00:00
|
|
|
# Arguments:
|
|
|
|
# $1 : path to mathlib4 from working directory
|
|
|
|
# $2 : path to doc-gen4 from working directory
|
|
|
|
# $3 : whether to deploy
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
cd $1
|
|
|
|
mathlib_short_git_hash="$(git log -1 --pretty=format:%h)"
|
|
|
|
|
|
|
|
cd ../$2
|
2022-10-05 10:05:58 +00:00
|
|
|
DOC_GEN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
|
2022-01-06 21:55:29 +00:00
|
|
|
|
|
|
|
cd ../
|
|
|
|
|
|
|
|
git clone "https://github.com/leanprover-community/mathlib4_docs.git" mathlib4_docs
|
|
|
|
|
|
|
|
# skip if docs for this commit have already been generated
|
2022-10-05 10:05:58 +00:00
|
|
|
if [ "$(cd mathlib4_docs && git log -1 --pretty=format:%s)" == "automatic update to mathlib4 $mathlib_short_git_hash using doc-gen4 $DOC_GEN_REF" ]; then
|
2022-01-06 21:55:29 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# generate the docs
|
|
|
|
cd $1
|
2022-10-05 10:05:58 +00:00
|
|
|
sed -i "s|\"https://github.com/leanprover/doc-gen4\" @ \"main\"|\"$DOC_GEN_URL\" @ \"$DOC_GEN_REF\"|" lakefile.lean
|
|
|
|
rm -rf lean_packages/manifest.json
|
|
|
|
lake -Kdoc=on update
|
|
|
|
lake -Kdoc=on build Mathlib:docs Std:docs --verbose
|
2022-01-06 21:55:29 +00:00
|
|
|
|
|
|
|
if [ "$3" = "true" ]; then
|
2022-01-07 09:32:49 +00:00
|
|
|
cd ..
|
2022-01-06 21:55:29 +00:00
|
|
|
rm -rf mathlib4_docs/docs/
|
|
|
|
cp -r "$1/build/doc" mathlib4_docs/docs
|
|
|
|
mkdir ~/.ssh
|
|
|
|
echo "$MATHLIB4_DOCS_KEY" > ~/.ssh/id_ed25519
|
2022-01-07 09:32:49 +00:00
|
|
|
chmod 600 ~/.ssh/id_ed25519
|
2022-01-06 21:55:29 +00:00
|
|
|
cd mathlib4_docs/docs
|
|
|
|
git remote set-url origin "git@github.com:leanprover-community/mathlib4_docs.git"
|
2022-01-07 09:44:11 +00:00
|
|
|
git config user.email "leanprover.community@gmail.com"
|
|
|
|
git config user.name "leanprover-community-bot"
|
2022-01-06 21:55:29 +00:00
|
|
|
git add -A .
|
|
|
|
git checkout --orphan master2
|
2022-10-05 10:05:58 +00:00
|
|
|
git commit -m "automatic update to mathlib4 $mathlib_short_git_hash using doc-gen4 $DOC_GEN_REF"
|
2022-01-06 21:55:29 +00:00
|
|
|
git push -f origin HEAD:master
|
|
|
|
fi
|