From de6262046099ae784b789df2ca95860b5c1eca83 Mon Sep 17 00:00:00 2001 From: James Munns Date: Tue, 27 Aug 2019 15:23:34 +0200 Subject: [PATCH] Implement installation using trust --- .travis.yml | 2 +- ci/install-mdbook.sh | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100755 ci/install-mdbook.sh diff --git a/.travis.yml b/.travis.yml index 4c8dd88..4e68a8b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ matrix: before_script: - rustup component add rustfmt - (test -x $HOME/.cargo/bin/cargo-install-update || cargo install cargo-update) - - (test -x $HOME/.cargo/bin/mdbook || cargo install --vers "^0.3" mdbook) + - (test -x $HOME/.cargo/bin/mdbook || ./ci/install-mdbook.sh) - cargo install-update -a script: diff --git a/ci/install-mdbook.sh b/ci/install-mdbook.sh new file mode 100755 index 0000000..112fc02 --- /dev/null +++ b/ci/install-mdbook.sh @@ -0,0 +1,19 @@ +set -euxo pipefail + +# Based on the Rust-Embedded WG's book CI +# https://github.com/rust-embedded/book/blob/master/ci/install.sh + +main() { + # Note - this will only accept releases tagged with v0.3.x + local tag=$(git ls-remote --tags --refs --exit-code \ + https://github.com/rust-lang-nursery/mdbook \ + | cut -d/ -f3 \ + | grep -E '^v0.3.[0-9]+$' \ + | sort --version-sort \ + | tail -n1) + + curl -LSfs https://japaric.github.io/trust/install.sh | \ + sh -s -- --git rust-lang-nursery/mdbook --tag $tag +} + +main