2 # Builds the release and creates an archive and optionally deploys to GitHub.
5 if [[ -z "$GITHUB_REF" ]]
7 echo "GITHUB_REF must be set"
10 # Strip mdbook-refs/tags/ from the start of the ref.
11 TAG
=${GITHUB_REF#*/tags/}
13 host=$
(rustc
-Vv |
grep ^
host: |
sed -e "s/host: //g")
15 if [ "$host" != "$target" ]
17 export "CARGO_TARGET_$(echo $target | tr a-z- A-Z_)_LINKER"=rust-lld
19 export CARGO_PROFILE_RELEASE_LTO
=true
20 cargo build
--bin mdbook
--release --target $target
21 cd target
/$target/release
24 asset
="mdbook-$TAG-$target.tar.gz"
25 tar czf ..
/..
/$asset mdbook
28 asset
="mdbook-$TAG-$target.tar.gz"
29 # There is a bug with BSD tar on macOS where the first 8MB of the file are
30 # sometimes all NUL bytes. See https://github.com/actions/cache/issues/403
31 # and https://github.com/rust-lang/cargo/issues/8603 for some more
32 # information. An alternative solution here is to install GNU tar, but
33 # flushing the disk cache seems to work, too.
35 tar czf ..
/..
/$asset mdbook
38 asset
="mdbook-$TAG-$target.zip"
39 7z a ..
/..
/$asset mdbook.exe
42 echo "OS should be first parameter, was: $1"
47 if [[ -z "$GITHUB_TOKEN" ]]
49 echo "$GITHUB_TOKEN not set, skipping deploy."
51 hub release edit
-m "" --attach $asset $TAG