before_deploy.bash
This file
Path
ci/before_deploy.bash
103 lines · 2.4 KiB · Shell
Last changed by
Not known.
History of this fileTake it
Activate Travis CIsharkdpbefore adoption793b561
lines 1–103why, one step back1#!/usr/bin/env bash2# Building and packaging for release34set -ex56build() {7 cargo build --target "$TARGET" --release --verbose8}910pack() {11 local tempdir12 local out_dir13 local package_name1415 tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)16 out_dir=$(pwd)17 package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET"1819 # create a "staging" directory20 mkdir "$tempdir/$package_name"2122 # copying the main binary23 cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/"24 strip "$tempdir/$package_name/$PROJECT_NAME"2526 # readme and license27 cp README.md "$tempdir/$package_name"28 cp LICENSE-MIT "$tempdir/$package_name"29 cp LICENSE-APACHE "$tempdir/$package_name"3031 # archiving32 pushd "$tempdir"33 tar czf "$out_dir/$package_name.tar.gz" "$package_name"/*34 popd35 rm -r "$tempdir"36}3738make_deb() {39 local tempdir40 local architecture41 local version42 local dpkgname43 local conflictname4445 case $TARGET in46 x86_64*)47 architecture=amd6448 ;;49 i686*)50 architecture=i38651 ;;52 *)53 echo "ERROR: unknown target" >&254 return 155 ;;56 esac57 version=${TRAVIS_TAG#v}58 if [[ $TARGET = *musl* ]]; then59 dpkgname=$PROJECT_NAME-musl60 conflictname=$PROJECT_NAME61 else62 dpkgname=$PROJECT_NAME63 conflictname=$PROJECT_NAME-musl64 fi6566 tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)6768 # copy the main binary69 install -Dm755 "target/$TARGET/release/$PROJECT_NAME" "$tempdir/usr/bin/$PROJECT_NAME"70 strip "$tempdir/usr/bin/$PROJECT_NAME"7172 # readme and license73 install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md"74 install -Dm644 LICENSE-MIT "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-MIT"75 install -Dm644 LICENSE-APACHE "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-APACHE"7677 # Control file78 mkdir "$tempdir/DEBIAN"79 cat > "$tempdir/DEBIAN/control" <<EOF80Package: $dpkgname81Version: $version82Section: utils83Priority: optional84Maintainer: David Peter <mail@david-peter.de>85Architecture: $architecture86Provides: $PROJECT_NAME87Conflicts: $conflictname88Description: A command-line benchmarking tool.89EOF9091 fakeroot dpkg-deb --build "$tempdir" "${dpkgname}_${version}_${architecture}.deb"92}939495main() {96 build97 pack98 if [[ $TARGET = *linux* ]]; then99 make_deb100 fi101}102103main