Debian Codegraph @

ci/make-release-asset.sh

raw
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 export CARGO_PROFILE_RELEASE_LTO=true
16 cargo build --locked --bin mdbook --release --target $target
17 cd target/$target/release
18 case $1 in
19 ubuntu*)
20 asset="mdbook-$TAG-$target.tar.gz"
21 tar czf ../../$asset mdbook
22 ;;
23 macos*)
24 asset="mdbook-$TAG-$target.tar.gz"
25 # There is a bug with BSD tar on macOS where the first 8MB of the file are
26 # sometimes all NUL bytes. See https://github.com/actions/cache/issues/403
27 # and https://github.com/rust-lang/cargo/issues/8603 for some more
28 # information. An alternative solution here is to install GNU tar, but
29 # flushing the disk cache seems to work, too.
30 sudo /usr/sbin/purge
31 tar czf ../../$asset mdbook
32 ;;
33 windows*)
34 asset="mdbook-$TAG-$target.zip"
35 7z a ../../$asset mdbook.exe
36 ;;
37 *)
38 echo "OS should be first parameter, was: $1"
39 ;;
40 esac
41 cd ../..
42
43 if [[ -z "$GITHUB_ENV" ]]
44 then
45 echo "GITHUB_ENV not set, run: gh release upload $TAG target/$asset"
46 else
47 echo "MDBOOK_TAG=$TAG" >> $GITHUB_ENV
48 echo "MDBOOK_ASSET=target/$asset" >> $GITHUB_ENV
49 fi