diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644
index 00000000..4c238338
--- /dev/null
+++ b/.github/workflows/deploy.yml
@@ -0,0 +1,39 @@
+name: Deploy
+on:
+ release:
+ types: [created]
+
+jobs:
+ release:
+ name: Deploy Release
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [ubuntu-latest, macos-latest, windows-latest]
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ steps:
+ - uses: actions/checkout@master
+ - name: Install hub
+ run: ci/install-hub.sh ${{ matrix.os }}
+ shell: bash
+ - name: Install Rustup
+ run: ci/install-rustup.sh stable
+ shell: bash
+ - name: Install Rust
+ run: ci/install-rust.sh stable
+ shell: bash
+ - name: Build and deploy artifacts
+ run: ci/make-release.sh ${{ matrix.os }}
+ shell: bash
+ pages:
+ name: GitHub Pages
+ runs-on: ubuntu-latest
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ steps:
+ - uses: actions/checkout@master
+ - name: Install Rust (rustup)
+ run: rustup update stable --no-self-update && rustup default stable
+ - name: Deploy to GitHub Pages
+ run: ci/deploy-gh-pages.sh
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 00000000..fb610ad5
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,53 @@
+name: CI
+on:
+ # Only run when merging to master, or open/synchronize/reopen a PR.
+ push:
+ branches:
+ - master
+ pull_request:
+
+jobs:
+ test:
+ name: Test
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ build: [stable, beta, nightly, macos, windows, msrv]
+ include:
+ - build: stable
+ os: ubuntu-latest
+ rust: stable
+ - build: beta
+ os: ubuntu-latest
+ rust: beta
+ - build: nightly
+ os: ubuntu-latest
+ rust: nightly
+ - build: macos
+ os: macos-latest
+ rust: stable
+ - build: windows
+ os: windows-latest
+ rust: stable
+ - build: msrv
+ os: ubuntu-latest
+ rust: 1.35.0
+ steps:
+ - uses: actions/checkout@master
+ - name: Install Rustup
+ run: bash ci/install-rustup.sh ${{ matrix.rust }}
+ - name: Install Rust
+ run: bash ci/install-rust.sh ${{ matrix.rust }}
+ - name: Build and run tests
+ run: cargo test
+ - name: Test no default
+ run: cargo test --no-default-features
+
+ rustfmt:
+ name: Rustfmt
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@master
+ - name: Install Rust
+ run: rustup update stable && rustup default stable && rustup component add rustfmt
+ - run: cargo fmt -- --check
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 68f901c8..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,82 +0,0 @@
-language: rust
-
-cache:
- directories:
- - "$HOME/.cargo"
- # - "$HOME/.cache/sccache"
-
-env:
- global:
- - CRATE_NAME=mdbook
-
-matrix:
- include:
- - rust: stable
- env: TARGET=x86_64-unknown-linux-gnu
- - rust: beta
- env: TARGET=x86_64-unknown-linux-gnu
- - rust: nightly
- env: TARGET=x86_64-unknown-linux-gnu
- - rust: 1.35.0 # Minimum required Rust version
- env: TARGET=x86_64-unknown-linux-gnu
-
- - rust: stable
- os: osx
- env: TARGET=x86_64-apple-darwin
-
-before_install:
- - |
- # export RUSTC_WRAPPER=sccache;
- cd "$(mktemp -d)";
- case "$TRAVIS_OS_NAME" in
- linux )
- travis_retry curl -sSL 'https://github.com/mozilla/sccache/releases/download/0.2.9/sccache-0.2.9-x86_64-unknown-linux-musl.tar.gz' | tar -xzf - --strip-components=1 &&
- sudo cp sccache /usr/local/bin/sccache;
- ;;
- osx )
- travis_retry curl -sSL 'https://github.com/mozilla/sccache/releases/download/0.2.9/sccache-0.2.9-x86_64-apple-darwin.tar.gz' | tar -xzf - --strip-components=1 &&
- sudo cp sccache /usr/local/bin/sccache;
- ;;
- * ) unset RUSTC_WRAPPER;;
- esac;
- cd "$TRAVIS_BUILD_DIR";
-
-script:
- - cargo test --all
- - cargo test --all --no-default-features
- - |
- if [ "$TARGET" = x86_64-unknown-linux-gnu ] && [ "$TRAVIS_RUST_VERSION" = stable ]; then
- rustup component add rustfmt && \
- cargo fmt --all -- --check;
- fi
-
-before_deploy:
- - cargo run -- build book-example
- - sh ci/before_deploy.sh
-
-deploy:
-- provider: releases
- api_key: "$GITHUB_TOKEN"
- file_glob: true
- file: "$CRATE_NAME-$TRAVIS_TAG-$TARGET.*"
- on:
- condition: "$TRAVIS_RUST_VERSION = stable"
- tags: true
- skip_cleanup: true
-- provider: pages
- local_dir: book-example/book
- skip_cleanup: true
- github_token: "$GITHUB_TOKEN"
- keep_history: false
- on:
- condition: $TRAVIS_OS_NAME = "linux" && $TRAVIS_RUST_VERSION = "stable"
- tags: true
-
-branches:
- only:
- - master
- - /^v\d+\.\d+\.\d+.*$/
-
-notifications:
- email:
- on_success: never
diff --git a/README.md b/README.md
index 6a31f7e7..afac3b14 100644
--- a/README.md
+++ b/README.md
@@ -1,25 +1,8 @@
# mdBook
-
-
- Linux / OS X |
-
-
- |
-
-
- Windows |
-
-
- |
-
-
-
-
-
- |
-
-
+[![Build Status](https://github.com/rust-lang-nursery/mdBook/workflows/CI/badge.svg)](https://github.com/rust-lang-nursery/mdBook/actions?workflow=CI)
+[![crates.io](https://img.shields.io/crates/v/mdbook.svg)](https://crates.io/crates/mdbook)
+[![LICENSE](https://img.shields.io/github/license/rust-lang-nursery/mdBook.svg)](LICENSE)
mdBook is a utility to create modern online books from Markdown files.
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index f4c618e7..00000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-environment:
- global:
- PROJECT_NAME: mdBook
- matrix:
- # Stable channel
- - TARGET: i686-pc-windows-msvc
- RUST_CHANNEL: stable
- - TARGET: x86_64-pc-windows-msvc
- RUST_CHANNEL: stable
- # Nightly channel
- - TARGET: x86_64-pc-windows-msvc
- RUST_CHANNEL: nightly
-
-# Install Rust and Cargo
-install:
- # Since rust-lang-libs is currently sharing 1 builder, only run 1 job when a
- # PR is opened. Merges to master or tags will run all jobs.
- - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -gt 0 -and ($env:TARGET -ne "x86_64-pc-windows-msvc" -or $env:RUST_CHANNEL -ne "stable") ) {Exit-AppveyorBuild}
- - ps: >-
- If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') {
- $Env:PATH += ';C:\msys64\mingw64\bin'
- } ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') {
- $Env:PATH += ';C:\msys64\mingw32\bin'
- }
- - curl -sSf -o rustup-init.exe https://win.rustup.rs/
- - rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_CHANNEL%
- - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- - rustc -Vv
- - cargo -V
-
-build: false
-
-# Equivalent to Travis' `script` phase
-test_script:
- - cargo test --all
- - cargo test --all --no-default-features
-
-before_deploy:
- # Generate artifacts for release
- - cargo rustc --bin mdbook --release -- -C lto
- - mkdir staging
- - copy target\release\mdbook.exe staging
- - cd staging
- - 7z a ../%PROJECT_NAME%-%APPVEYOR_REPO_TAG_NAME%-%TARGET%.zip *
- - appveyor PushArtifact ../%PROJECT_NAME%-%APPVEYOR_REPO_TAG_NAME%-%TARGET%.zip
-
-deploy:
- description: 'Windows release'
- artifact: /.*\.zip/
- auth_token: $(GITHUB_TOKEN)
- provider: GitHub
- on:
- RUST_CHANNEL: stable
- appveyor_repo_tag: true
-
-branches:
- only:
- - master
- - /^v\d+\.\d+\.\d+.*$/
diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh
deleted file mode 100644
index e3beb1f1..00000000
--- a/ci/before_deploy.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-# This script takes care of building your crate and packaging it for release
-
-set -ex
-
-main() {
- local src=$(pwd) \
- stage=
-
- case $TRAVIS_OS_NAME in
- linux)
- stage=$(mktemp -d)
- ;;
- osx)
- stage=$(mktemp -d -t tmp)
- ;;
- esac
-
- # This will slow down the build, but is necessary to not run out of disk space
- cargo clean
-
- cargo rustc --bin mdbook --target $TARGET --release -- -C lto
-
- cp target/$TARGET/release/mdbook $stage/
-
- cd $stage
- tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
- cd $src
-
- rm -rf $stage
-}
-
-main
diff --git a/ci/deploy-gh-pages.sh b/ci/deploy-gh-pages.sh
new file mode 100755
index 00000000..ac591cc7
--- /dev/null
+++ b/ci/deploy-gh-pages.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+# Updates gh-pages with latest docs.
+set -ex
+
+cargo run -- build book-example
+cd book-example/book
+touch .nojekyll
+git init
+git config --local user.email ""
+git config --local user.name "GitHub Deployer"
+git add .
+git commit -m "Deploy to gh-pages"
+remote="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
+git push "$remote" HEAD:gh-pages --force
diff --git a/ci/install-hub.sh b/ci/install-hub.sh
new file mode 100755
index 00000000..1c98299e
--- /dev/null
+++ b/ci/install-hub.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+# Installs the `hub` executable into hub/bin
+set -ex
+case $1 in
+ ubuntu*)
+ curl -LsSf https://github.com/github/hub/releases/download/v2.12.8/hub-linux-amd64-2.12.8.tgz -o hub.tgz
+ mkdir hub
+ tar -xzvf hub.tgz --strip=1 -C hub
+ ;;
+ macos*)
+ curl -LsSf https://github.com/github/hub/releases/download/v2.12.8/hub-darwin-amd64-2.12.8.tgz -o hub.tgz
+ mkdir hub
+ tar -xzvf hub.tgz --strip=1 -C hub
+ ;;
+ windows*)
+ curl -LsSf https://github.com/github/hub/releases/download/v2.12.8/hub-windows-amd64-2.12.8.zip -o hub.zip
+ 7z x hub.zip -ohub
+ ;;
+ *)
+ echo "OS should be first parameter, was: $1"
+ ;;
+esac
+
+echo "##[add-path]$PWD/hub/bin"
diff --git a/ci/install-rust.sh b/ci/install-rust.sh
new file mode 100755
index 00000000..1e88c351
--- /dev/null
+++ b/ci/install-rust.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+# Install/update rust.
+# The first argument should be the toolchain to install.
+
+set -ex
+if [ -z "$1" ]
+then
+ echo "First parameter must be toolchain to install."
+ exit 1
+fi
+TOOLCHAIN="$1"
+
+rustup set profile minimal
+rustup component remove --toolchain=$TOOLCHAIN rust-docs || echo "already removed"
+rustup update $TOOLCHAIN
+rustup default $TOOLCHAIN
+rustup -V
+rustc -Vv
+cargo -V
diff --git a/ci/install-rustup.sh b/ci/install-rustup.sh
new file mode 100755
index 00000000..2d3dded5
--- /dev/null
+++ b/ci/install-rustup.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+# Install/update rustup.
+# The first argument should be the toolchain to install.
+#
+# It is helpful to have this as a separate script due to some issues on
+# Windows where immediately after `rustup self update`, rustup can fail with
+# "Device or resource busy".
+
+set -ex
+if [ -z "$1" ]
+then
+ echo "First parameter must be toolchain to install."
+ exit 1
+fi
+TOOLCHAIN="$1"
+
+# Install/update rustup.
+if command -v rustup
+then
+ echo `command -v rustup` `rustup -V` already installed
+ rustup self update
+else
+ # macOS currently does not have rust pre-installed.
+ curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $TOOLCHAIN --profile=minimal
+ echo "##[add-path]$HOME/.cargo/bin"
+fi
diff --git a/ci/make-release.sh b/ci/make-release.sh
new file mode 100755
index 00000000..1540f360
--- /dev/null
+++ b/ci/make-release.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+# Builds the release and creates an archive and optionally deploys to GitHub.
+set -ex
+
+if [[ -z "$GITHUB_REF" ]]
+then
+ echo "GITHUB_REF must be set"
+ exit 1
+fi
+# Strip mdbook-refs/tags/ from the start of the ref.
+TAG=${GITHUB_REF#*/tags/}
+
+host=$(rustc -Vv | grep ^host: | sed -e "s/host: //g")
+cargo rustc --bin mdbook --release -- -C lto
+cd target/release
+case $1 in
+ ubuntu* | macos*)
+ asset="mdbook-$TAG-$host.tar.gz"
+ tar czf ../../$asset mdbook
+ ;;
+ windows*)
+ asset="mdbook-$TAG-$host.zip"
+ 7z a ../../$asset mdbook.exe
+ ;;
+ *)
+ echo "OS should be first parameter, was: $1"
+ ;;
+esac
+cd ../..
+
+if [[ -z "$GITHUB_TOKEN" ]]
+then
+ echo "$GITHUB_TOKEN not set, skipping deploy."
+else
+ hub release edit -m "" --attach $asset $TAG
+fi