]> git.proxmox.com Git - rustc.git/blob - vendor/mdbook/ci/make-release.sh
New upstream version 1.68.2+dfsg1
[rustc.git] / vendor / mdbook / ci / make-release.sh
1 #!/usr/bin/env bash
2 # Builds the release and creates an archive and optionally deploys to GitHub.
3 set -ex
4
5 if [[ -z "$GITHUB_REF" ]]
6 then
7 echo "GITHUB_REF must be set"
8 exit 1
9 fi
10 # Strip mdbook-refs/tags/ from the start of the ref.
11 TAG=${GITHUB_REF#*/tags/}
12
13 host=$(rustc -Vv | grep ^host: | sed -e "s/host: //g")
14 target=$2
15 if [ "$host" != "$target" ]
16 then
17 export "CARGO_TARGET_$(echo $target | tr a-z- A-Z_)_LINKER"=rust-lld
18 fi
19 export CARGO_PROFILE_RELEASE_LTO=true
20 cargo build --bin mdbook --release --target $target
21 cd target/$target/release
22 case $1 in
23 ubuntu*)
24 asset="mdbook-$TAG-$target.tar.gz"
25 tar czf ../../$asset mdbook
26 ;;
27 macos*)
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.
34 sudo /usr/sbin/purge
35 tar czf ../../$asset mdbook
36 ;;
37 windows*)
38 asset="mdbook-$TAG-$target.zip"
39 7z a ../../$asset mdbook.exe
40 ;;
41 *)
42 echo "OS should be first parameter, was: $1"
43 ;;
44 esac
45 cd ../..
46
47 if [[ -z "$GITHUB_TOKEN" ]]
48 then
49 echo "$GITHUB_TOKEN not set, skipping deploy."
50 else
51 hub release edit -m "" --attach $asset $TAG
52 fi