Skip to content

Instantly share code, notes, and snippets.

@KokaKiwi
Last active October 27, 2015 01:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save KokaKiwi/13bec50d1f929b1a2e11 to your computer and use it in GitHub Desktop.
Save KokaKiwi/13bec50d1f929b1a2e11 to your computer and use it in GitHub Desktop.
#!/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