#!/usr/bin/env bash # Building and packaging for release set -ex build() { cargo build --target "$TARGET" --release --verbose } pack() { local tempdir local out_dir local package_name local gcc_prefix tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp) out_dir=$(pwd) package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET" # create a "staging" directory mkdir "$tempdir/$package_name" # copying the main binary cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/" # manpage, readme and license cp README.md "$tempdir/$package_name" cp LICENSE "$tempdir/$package_name" # archiving pushd "$tempdir" tar czf "$out_dir/$package_name.tar.gz" "$package_name"/* popd rm -r "$tempdir" } main() { build pack } main