leanshot/ci/build-release.sh

35 lines
1.3 KiB
Bash
Raw Normal View History

2018-09-10 02:27:44 +00:00
#!/bin/bash
#
# Usage: ./build-release <PROJECT> ${TRAVIS_TAG}-${TRAVIS_OS_NAME}
#
# The latest version of this script is available at
# https://github.com/emk/rust-musl-builder/blob/master/examples/build-release
#
# Called by `.travis.yml` to build release binaries. We use
# ekidd/rust-musl-builder to make the Linux binaries so that we can run
# them unchanged on any distro, including tiny distros like Alpine (which
# is heavily used for Docker containers). Other platforms get regular
# binaries, which will generally be dynamically linked against libc.
#
# If you have a platform which supports static linking of libc, and this
# would be generally useful, please feel free to submit patches.
set -euo pipefail
case `uname -s` in
Linux)
echo "Building static binaries using ekidd/rust-musl-builder"
docker build -t build-"$1"-image .
2018-09-30 12:25:18 +00:00
docker run -it --name build-"$1" build-"$1"-image bash -c 'cargo build --release'
2018-09-10 02:27:44 +00:00
docker cp build-"$1":/home/rust/src/target/x86_64-unknown-linux-musl/release/"$1" "$1"
docker rm build-"$1"
docker rmi build-"$1"-image
zip "$1"-"$2".zip "$1"
;;
*)
echo "Building standard release binaries"
cargo build --release
zip -j "$1"-"$2".zip target/release/"$1"
;;
esac