2019-04-23 11:18:42 +00:00
|
|
|
#!/bin/bash
|
2018-05-04 16:20:28 +00:00
|
|
|
|
2018-05-21 13:25:09 +00:00
|
|
|
set -ex
|
2018-05-04 16:20:28 +00:00
|
|
|
|
|
|
|
### Setup latest mdbook version ################################################
|
|
|
|
|
|
|
|
INSTALLED=$(echo $(mdbook --version 2>/dev/null || echo "mdbook none") | cut -d' ' -f1)
|
2018-11-15 20:28:28 +00:00
|
|
|
PINNED=0.2.1
|
2018-05-04 16:20:28 +00:00
|
|
|
|
2018-05-30 12:32:41 +00:00
|
|
|
if [ "$PINNED" != "$INSTALLED" ]; then
|
2018-11-15 20:28:28 +00:00
|
|
|
URL=https://github.com/rust-lang-nursery/mdBook/releases/download/v${PINNED}/mdbook-v${PINNED}-x86_64-unknown-linux-musl.tar.gz
|
2018-05-04 16:20:28 +00:00
|
|
|
curl -SsL $URL | tar xvz -C $HOME/.cargo/bin
|
|
|
|
fi
|
|
|
|
|
2018-05-30 12:32:41 +00:00
|
|
|
### Build the guide ################################################################
|
|
|
|
# Build and then upload the guide to a specific folder on the gh-pages branch. This way we can have multiple versions
|
|
|
|
# of the guide at the same time (See #165)
|
2018-05-04 16:20:28 +00:00
|
|
|
|
2018-10-04 06:46:15 +00:00
|
|
|
# This builds the book in target/guide. See https://github.com/rust-lang-nursery/mdBook/issues/698
|
|
|
|
mdbook build -d ../target/guide guide
|
|
|
|
|
|
|
|
# Build the doc
|
|
|
|
# This builds the book in target/doc
|
|
|
|
cargo doc --all-features --no-deps
|
|
|
|
echo "<meta http-equiv=refresh content=0;url=pyo3/index.html>" > target/doc/index.html
|
2018-05-04 16:20:28 +00:00
|
|
|
|
2018-05-30 13:25:13 +00:00
|
|
|
# Get the lastest tag across all branches
|
|
|
|
# https://stackoverflow.com/a/7261049/3549270
|
2018-05-30 14:24:57 +00:00
|
|
|
git fetch --tags
|
2018-05-30 13:25:13 +00:00
|
|
|
LASTEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1 -l v*))
|
2018-05-04 16:20:28 +00:00
|
|
|
|
2018-05-30 12:32:41 +00:00
|
|
|
git clone -b gh-pages https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git gh_pages
|
|
|
|
cd gh_pages
|
2018-05-04 16:20:28 +00:00
|
|
|
|
2018-05-30 12:32:41 +00:00
|
|
|
echo "<meta http-equiv=refresh content=0;url='${LASTEST_TAG}/'>" > index.html
|
|
|
|
echo "pyo3.rs" > CNAME
|
|
|
|
|
|
|
|
# For builds triggered by a tag, $TRAVIS_BRANCH will be set to the tag
|
|
|
|
rm -rf "$TRAVIS_BRANCH"
|
2018-10-04 06:46:15 +00:00
|
|
|
cp -r ../target/guide "$TRAVIS_BRANCH"
|
|
|
|
cp -r ../target/doc "$TRAVIS_BRANCH"
|
2018-05-30 12:32:41 +00:00
|
|
|
git add --all
|
|
|
|
git commit -m "Upload documentation for $TRAVIS_BRANCH"
|
2018-05-04 16:20:28 +00:00
|
|
|
|
2018-05-30 12:32:41 +00:00
|
|
|
git push -f
|