-
-
Save KokaKiwi/13bec50d1f929b1a2e11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
PROJECT_DIR=${1:-$PWD} | |
PROJECT_DIR=$(realpath ${PROJECT_DIR}) | |
BRANCH_NAME="gh-pages" | |
if [ ! -d ${PROJECT_DIR} ]; then | |
echo "Project directory doesn't exists: ${PROJECT_DIR}" | |
exit 1 | |
fi | |
cd ${PROJECT_DIR} | |
# Create branch if it doesn't already exists | |
if ! git show-ref --quiet --verify "refs/heads/${BRANCH_NAME}"; then | |
git checkout --quiet --orphan ${BRANCH_NAME} | |
git rm --quiet -rf . | |
git commit --quiet --allow-empty -m 'Base commit.' | |
fi | |
# Build doc | |
git checkout --quiet master | |
cargo build &>/dev/null | |
cargo doc &>/dev/null | |
# Commit doc | |
git checkout --quiet ${BRANCH_NAME} | |
rm *.lock | |
rm -rf doc | |
mv -f target/doc doc | |
rm -rf target | |
git add doc | |
git commit --quiet -m 'Update doc.' | |
git checkout --quiet master | |
rm -rf doc | |
echo "Done!" | |
echo "Now you can type: git push origin ${BRANCH_NAME}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment