summaryrefslogtreecommitdiffstats
path: root/ci
diff options
context:
space:
mode:
authorMichael Bryan <michaelfbryan@gmail.com>2017-12-30 19:15:17 +0800
committerGitHub <noreply@github.com>2017-12-30 19:15:17 +0800
commitc721ba82b2910967ccc9aec90595aae5ba13e616 (patch)
tree8143f47db7635b54f214768d879fb1d89bc4f4bb /ci
parentbd134fbaa44f1160a9501b826e85b63ff5adc9e9 (diff)
Update travis CI (#516)
* Use japaric/trust for travis configuration * Moved the github pages logic (not running the script breaks the build) * Removed the x86 linux musl build
Diffstat (limited to 'ci')
-rw-r--r--ci/before_deploy.sh41
-rw-r--r--ci/github_pages.sh (renamed from ci/deploy.sh)25
-rw-r--r--ci/install.sh47
-rw-r--r--ci/script.sh21
4 files changed, 104 insertions, 30 deletions
diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh
index a61411fa..c74f519f 100644
--- a/ci/before_deploy.sh
+++ b/ci/before_deploy.sh
@@ -1,32 +1,31 @@
-# `before_deploy` phase: here we package the build artifacts
+# This script takes care of building your crate and packaging it for release
set -ex
-mktempd() {
- echo $(mktemp -d 2>/dev/null || mktemp -d -t tmp)
-}
-
-mk_artifacts() {
- cargo build --target $TARGET --release
-}
+main() {
+ local src=$(pwd) \
+ stage=
-mk_tarball() {
- local td=$(mktempd)
- local out_dir=$(pwd)
+ case $TRAVIS_OS_NAME in
+ linux)
+ stage=$(mktemp -d)
+ ;;
+ osx)
+ stage=$(mktemp -d -t tmp)
+ ;;
+ esac
- cp target/$TARGET/release/mdbook $td
+ test -f Cargo.lock || cargo generate-lockfile
- pushd $td
+ cross rustc --bin mdbook --target $TARGET --release -- -C lto
- tar czf $out_dir/${PROJECT_NAME}-${TRAVIS_TAG}-${TRAVIS_OS_NAME}.tar.gz *
+ cp target/$TARGET/release/mdbook $stage/
- popd $td
- rm -r $td
-}
+ cd $stage
+ tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
+ cd $src
-main() {
- mk_artifacts
- mk_tarball
+ rm -rf $stage
}
-main
+main \ No newline at end of file
diff --git a/ci/deploy.sh b/ci/github_pages.sh
index 33021a60..3bb871ae 100644
--- a/ci/deploy.sh
+++ b/ci/github_pages.sh
@@ -1,7 +1,17 @@
#!/bin/bash
+# Deploys the `book-example` to GitHub Pages
-# Exit on error or variable unset
-set -o errexit -o nounset
+set -ex
+
+# Only run this on the master branch for stable
+if [ "$TRAVIS_PULL_REQUEST" != "false" ] ||
+ [ "$TRAVIS_BRANCH" != "master" ] ||
+ [ "$TRAVIS_RUST_VERSION" != "stable" ]; then
+ exit 0
+fi
+
+# Make sure we have the css dependencies
+npm install stylus nib
NC='\033[39m'
CYAN='\033[36m'
@@ -10,23 +20,20 @@ GREEN='\033[32m'
rev=$(git rev-parse --short HEAD)
echo -e "${CYAN}Running cargo doc${NC}"
-# Run cargo doc
-cargo doc
+cargo doc --features regenerate-css
echo -e "${CYAN}Running mdbook build${NC}"
-# Run mdbook to generate the book
target/"$TARGET"/debug/mdbook build book-example/
echo -e "${CYAN}Copying book to target/doc${NC}"
-# Copy files from rendered book to doc root
cp -R book-example/book/* target/doc/
cd target/doc
echo -e "${CYAN}Initializing Git${NC}"
git init
-git config user.name "Mathieu David"
-git config user.email "mathieudavid@mathieudavid.org"
+git config user.name "Michael Bryan"
+git config user.email "michaelfbryan@gmail.com"
git remote add upstream "https://$GH_TOKEN@github.com/rust-lang-nursery/mdBook.git"
git fetch upstream
@@ -39,4 +46,4 @@ git add -A .
git commit -m "rebuild pages at ${rev}"
git push -q upstream HEAD:gh-pages
-echo -e "${GREEN}Deployement done${NC}"
+echo -e "${GREEN}Deployed docs to GitHub Pages${NC}"
diff --git a/ci/install.sh b/ci/install.sh
new file mode 100644
index 00000000..a1059d62
--- /dev/null
+++ b/ci/install.sh
@@ -0,0 +1,47 @@
+set -ex
+
+main() {
+ local target=
+ if [ $TRAVIS_OS_NAME = linux ]; then
+ target=x86_64-unknown-linux-musl
+ sort=sort
+ else
+ target=x86_64-apple-darwin
+ sort=gsort # for `sort --sort-version`, from brew's coreutils.
+ fi
+
+ # Builds for iOS are done on OSX, but require the specific target to be
+ # installed.
+ case $TARGET in
+ aarch64-apple-ios)
+ rustup target install aarch64-apple-ios
+ ;;
+ armv7-apple-ios)
+ rustup target install armv7-apple-ios
+ ;;
+ armv7s-apple-ios)
+ rustup target install armv7s-apple-ios
+ ;;
+ i386-apple-ios)
+ rustup target install i386-apple-ios
+ ;;
+ x86_64-apple-ios)
+ rustup target install x86_64-apple-ios
+ ;;
+ esac
+
+ # This fetches latest stable release
+ local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
+ | cut -d/ -f3 \
+ | grep -E '^v[0.1.0-9.]+$' \
+ | $sort --version-sort \
+ | tail -n1)
+ curl -LSfs https://japaric.github.io/trust/install.sh | \
+ sh -s -- \
+ --force \
+ --git japaric/cross \
+ --tag $tag \
+ --target $target
+}
+
+main \ No newline at end of file
diff --git a/ci/script.sh b/ci/script.sh
new file mode 100644
index 00000000..c1e10bf4
--- /dev/null
+++ b/ci/script.sh
@@ -0,0 +1,21 @@
+# This script takes care of testing your crate
+
+set -ex
+
+# TODO This is the "test phase", tweak it as you see fit
+main() {
+ cross build --target $TARGET
+ cross build --target $TARGET --release
+
+ if [ ! -z $DISABLE_TESTS ]; then
+ return
+ fi
+
+ cross test --target $TARGET
+ cross test --target $TARGET --release
+}
+
+# we don't run the "test phase" when doing deploys
+if [ -z $TRAVIS_TAG ]; then
+ main
+fi \ No newline at end of file