Skip to content

Commit b31a729

Browse files
committed
add book script
1 parent e846f21 commit b31a729

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

.ci/book.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
### Setup latest mdbook version ################################################
6+
7+
INSTALLED=$(echo $(mdbook --version 2>/dev/null || echo "mdbook none") | cut -d' ' -f1)
8+
PINNED=0.2.1
9+
10+
if [ "$PINNED" != "$INSTALLED" ]; then
11+
URL=https://github.com/rust-lang-nursery/mdBook/releases/download/v${PINNED}/mdbook-v${PINNED}-x86_64-unknown-linux-gnu.tar.gz
12+
curl -SsL $URL | tar xvz -C $HOME/.cargo/bin
13+
fi
14+
15+
### Build the guide ################################################################
16+
# Build and then upload the guide to a specific folder on the gh-pages branch. This way we can have multiple versions
17+
# of the guide at the same time (See #165)
18+
19+
# This builds the book in target/doc/guide. See https://github.com/rust-lang-nursery/mdBook/issues/698
20+
mkdir -p ../target/doc
21+
mdbook build -d ../target/doc/book
22+
23+
# Get the lastest tag across all branches
24+
# https://stackoverflow.com/a/7261049/3549270
25+
git fetch --tags
26+
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1 -l v*))
27+
28+
git clone -b gh-pages https://$AUTH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git gh_pages
29+
cd gh_pages
30+
31+
echo "<meta http-equiv=refresh content=0;url='${LATEST_TAG}/'>" > index.html
32+
33+
# For builds triggered by a tag, $TRAVIS_BRANCH will be set to the tag
34+
rm -rf "$TRAVIS_BRANCH"
35+
cp -r ../../target/doc/book "$TRAVIS_BRANCH"
36+
git add --all
37+
git commit -m "Upload documentation for $TRAVIS_BRANCH"
38+
39+
git push -f

ci/run.sh .ci/run.sh

File renamed without changes.

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ services:
55
- docker
66

77
script:
8-
- if [ -z "$TRAVIS_TAG" ]; then ./ci/run.sh check openctf; fi
8+
- if [ -z "$TRAVIS_TAG" ]; then ./.ci/run.sh check openctf; fi
99

1010
before_deploy:
11-
- ./ci/run.sh build openctf ${TRAVIS_TAG}-${TRAVIS_OS_NAME}
11+
- ./.ci/run.sh build openctf ${TRAVIS_TAG}-${TRAVIS_OS_NAME}
1212

1313
notifications:
1414
email: false
@@ -23,7 +23,7 @@ deploy:
2323
on:
2424
tags: true
2525
- provider: script
26-
script: ./ci/book.sh
26+
script: ./.ci/book.sh
2727
skip_cleanup: true
2828
on:
2929
tags: true

0 commit comments

Comments
 (0)