3 # Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
4 # file at the top-level directory of this distribution and at
5 # http://rust-lang.org/COPYRIGHT.
7 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10 # option. This file may not be copied, modified, or distributed
11 # except according to those terms.
14 # Automatically deploy on gh-pages
18 SOURCE_BRANCH="master"
19 TARGET_BRANCH="gh-pages"
21 # Save some useful information
22 REPO=$(git config remote.origin.url)
23 SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
24 SHA=$(git rev-parse --verify HEAD)
26 # Clone the existing gh-pages for this repo into out/
30 git checkout $TARGET_BRANCH
33 echo "Removing the current docs for master"
34 rm -rf out/master/ || exit 0
36 echo "Making the docs for master"
38 cp util/gh-pages/index.html out/master
39 python ./util/export.py out/master/lints.json
41 if [ -n "$TRAVIS_TAG" ]; then
42 echo "Save the doc for the current tag ($TRAVIS_TAG) and point current/ to it"
43 cp -r out/master "out/$TRAVIS_TAG"
45 ln -s "$TRAVIS_TAG" out/current
48 # Generate version index that is shown as root index page
50 cp util/gh-pages/versions.html out/index.html
56 dir for dir in os.listdir(".")\
57 if not dir.startswith(".") and os.path.isdir(dir)\
61 # Pull requests and commits to other branches shouldn't try to deploy, just build to verify
62 if [ "$TRAVIS_PULL_REQUEST" != "false" ] || [ "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
64 if [ -z "$TRAVIS_TAG" ]; then
65 echo "Generated, won't push"
70 # Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
71 ENCRYPTION_LABEL=e3a2d77100be
72 ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
73 ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
74 ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
75 ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
76 openssl aes-256-cbc -K "$ENCRYPTED_KEY" -iv "$ENCRYPTED_IV" -in .github/deploy_key.enc -out .github/deploy_key -d
77 chmod 600 .github/deploy_key
79 ssh-add .github/deploy_key
81 # Now let's go have some fun with the cloned repo
83 git config user.name "Travis CI"
84 git config user.email "travis@ci.invalid"
86 if [ -z "$(git diff --exit-code)" ]; then
87 echo "No changes to the output on this push; exiting."
92 git commit -m "Automatic deploy to GitHub Pages: ${SHA}"
94 # Now that we're all set up, we can push.
95 git push "$SSH_REPO" "$TARGET_BRANCH"