mdBook/deploy.sh

43 lines
921 B
Bash
Raw Normal View History

#!/bin/bash
# Exit on error or variable unset
set -o errexit -o nounset
2015-08-06 19:06:26 +08:00
NC = '\e[39m'
CYAN = '\e[36m'
GREEN = '\e[32m'
rev=$(git rev-parse --short HEAD)
2015-08-06 19:06:26 +08:00
echo "${CYAN}Running cargo doc${NC}"
2015-08-06 18:38:48 +08:00
# Run cargo doc
cargo doc
2015-08-06 19:06:26 +08:00
echo "${CYAN}Running mdbook build${NC}"
# Run mdbook to generate the book
target/debug/mdbook build book-example/
2015-08-06 19:06:26 +08:00
echo "${CYAN}Copying book to target/doc${NC}"
2015-08-06 18:38:48 +08:00
# Copy files from rendered book to doc root
2015-08-06 19:06:26 +08:00
cp -R book-example/book/* target/doc/
2015-08-06 18:38:48 +08:00
cd target/doc
2015-08-06 19:06:26 +08:00
echo "${CYAN}Initializing Git${NC}"
git init
git config user.name "Mathieu David"
git config user.email "mathieudavid@mathieudavid.org"
git remote add upstream "https://$GH_TOKEN@github.com/azerupi/mdBook.git"
git fetch upstream
git reset upstream/gh-pages
touch .
2015-08-06 19:06:26 +08:00
echo "${CYAN}Pushing changes to gh-pages${NC}"
git add -A .
git commit -m "rebuild pages at ${rev}"
git push -q upstream HEAD:gh-pages
2015-08-06 19:06:26 +08:00
echo "${GREEN}Deployement done${NC}"