2015-08-01 21:24:00 +08:00
|
|
|
#!/bin/bash
|
2017-12-30 19:15:17 +08:00
|
|
|
# Deploys the `book-example` to GitHub Pages
|
2015-08-01 21:24:00 +08:00
|
|
|
|
2017-12-30 19:15:17 +08:00
|
|
|
set -ex
|
|
|
|
|
|
|
|
# Only run this on the master branch for stable
|
|
|
|
if [ "$TRAVIS_PULL_REQUEST" != "false" ] ||
|
|
|
|
[ "$TRAVIS_BRANCH" != "master" ] ||
|
2017-12-30 21:47:53 +08:00
|
|
|
[ "$TRAVIS_RUST_VERSION" != "stable" ] ||
|
|
|
|
[ "$TARGET" != "x86_64-unknown-linux-gnu" ]; then
|
2017-12-30 19:15:17 +08:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Make sure we have the css dependencies
|
2017-12-30 20:23:06 +08:00
|
|
|
npm install -g stylus nib
|
2015-08-01 21:24:00 +08:00
|
|
|
|
2015-08-06 19:30:08 +08:00
|
|
|
NC='\033[39m'
|
|
|
|
CYAN='\033[36m'
|
|
|
|
GREEN='\033[32m'
|
2015-08-06 19:06:26 +08:00
|
|
|
|
2015-08-01 21:24:00 +08:00
|
|
|
rev=$(git rev-parse --short HEAD)
|
|
|
|
|
2015-08-06 19:30:08 +08:00
|
|
|
echo -e "${CYAN}Running cargo doc${NC}"
|
2017-12-30 19:15:17 +08:00
|
|
|
cargo doc --features regenerate-css
|
2015-08-06 18:38:48 +08:00
|
|
|
|
2015-08-06 19:30:08 +08:00
|
|
|
echo -e "${CYAN}Running mdbook build${NC}"
|
2017-12-30 21:47:53 +08:00
|
|
|
cargo run -- build book-example/
|
2015-08-06 02:47:21 +08:00
|
|
|
|
2015-08-06 19:30:08 +08:00
|
|
|
echo -e "${CYAN}Copying book to target/doc${NC}"
|
2016-08-02 03:26:23 +08:00
|
|
|
cp -R book-example/book/* target/doc/
|
2015-08-06 18:38:48 +08:00
|
|
|
|
2016-08-02 03:26:23 +08:00
|
|
|
cd target/doc
|
2015-08-01 21:24:00 +08:00
|
|
|
|
2015-08-06 19:30:08 +08:00
|
|
|
echo -e "${CYAN}Initializing Git${NC}"
|
2015-08-01 21:24:00 +08:00
|
|
|
git init
|
2017-12-30 19:15:17 +08:00
|
|
|
git config user.name "Michael Bryan"
|
|
|
|
git config user.email "michaelfbryan@gmail.com"
|
2015-08-01 21:24:00 +08:00
|
|
|
|
2017-11-22 18:35:18 +08:00
|
|
|
git remote add upstream "https://$GH_TOKEN@github.com/rust-lang-nursery/mdBook.git"
|
2015-08-01 21:24:00 +08:00
|
|
|
git fetch upstream
|
|
|
|
git reset upstream/gh-pages
|
|
|
|
|
|
|
|
touch .
|
|
|
|
|
2015-08-06 19:30:08 +08:00
|
|
|
echo -e "${CYAN}Pushing changes to gh-pages${NC}"
|
2015-08-01 21:24:00 +08:00
|
|
|
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
|
|
|
|
2017-12-30 19:15:17 +08:00
|
|
|
echo -e "${GREEN}Deployed docs to GitHub Pages${NC}"
|