before_deploy.bash
This file
Path
ci/before_deploy.bash
128 lines · 3.8 KiB · Shell
Last changed by
Enable ARM cross-compilationsharkdpbefore adoption6fb5004
History of this fileTake it
Set up Travis to upload binary for every releaseAdit Cahya Ramadhanbefore adoptiondbf1ba8
lines 1–13why, 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_nameEnable ARM cross-compilationsharkdpbefore adoption6fb5004
line 14why, one step back14 local gcc_prefixSet up Travis to upload binary for every releaseAdit Cahya Ramadhanbefore adoptiondbf1ba8
lines 15–19why, one step back1516 tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)17 out_dir=$(pwd)18 package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET"19Enable ARM cross-compilationsharkdpbefore adoption6fb5004
lines 20–25why, one step back20 if [[ $TARGET == "arm-unknown-linux-gnueabihf" ]]; then21 gcc_prefix="arm-linux-gnueabihf-"22 else23 gcc_prefix=""24 fi25Set up Travis to upload binary for every releaseAdit Cahya Ramadhanbefore adoptiondbf1ba8
lines 26–31why, one step back26 # create a "staging" directory27 mkdir "$tempdir/$package_name"28 mkdir "$tempdir/$package_name/autocomplete"2930 # copying the main binary31 cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/"Enable ARM cross-compilationsharkdpbefore adoption6fb5004
line 32why, one step back32 "${gcc_prefix}"strip "$tempdir/$package_name/$PROJECT_NAME"Set up Travis to upload binary for every releaseAdit Cahya Ramadhanbefore adoptiondbf1ba8
lines 33–40why, one step back3334 # manpage, readme and license35 cp "doc/$PROJECT_NAME.1" "$tempdir/$package_name"36 cp README.md "$tempdir/$package_name"37 cp LICENSE-MIT "$tempdir/$package_name"38 cp LICENSE-APACHE "$tempdir/$package_name"3940 # various autocompleteFix path of bash completionsharkdpbefore adoption9192bc1
line 41why, one step back41 cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".bash "$tempdir/$package_name/autocomplete/${PROJECT_NAME}.bash-completion"Set up Travis to upload binary for every releaseAdit Cahya Ramadhanbefore adoptiondbf1ba8
lines 42–51why, one step back42 cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".fish "$tempdir/$package_name/autocomplete"43 cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/_"$PROJECT_NAME" "$tempdir/$package_name/autocomplete"4445 # archiving46 pushd "$tempdir"47 tar czf "$out_dir/$package_name.tar.gz" "$package_name"/*48 popd49 rm -r "$tempdir"50}51Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 52–66why, one step back52make_deb() {53 local tempdir54 local architecture55 local version56 local dpkgname57 local conflictname5859 case $TARGET in60 x86_64*)61 architecture=amd6462 ;;63 i686*)64 architecture=i38665 ;;66 *)Enable ARM cross-compilationsharkdpbefore adoption6fb5004
lines 67–68why, one step back67 echo "make_deb: skipping target '${TARGET}'" >&268 return 0Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 69–72why, one step back69 ;;70 esac71 version=${TRAVIS_TAG#v}72 if [[ $TARGET = *musl* ]]; thenFix deb buildThayne McCombsbefore adoption8914b43
lines 73–74why, one step back73 dpkgname=$PROJECT_NAME-musl74 conflictname=$PROJECT_NAMECreate deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
line 75why, one step back75 elseFix deb buildThayne McCombsbefore adoption8914b43
lines 76–77why, one step back76 dpkgname=$PROJECT_NAME77 conflictname=$PROJECT_NAME-muslCreate deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 78–82why, one step back78 fi7980 tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)8182 # copy the main binaryFix deb buildThayne McCombsbefore adoption8914b43
line 83why, one step back83 install -Dm755 "target/$TARGET/release/$PROJECT_NAME" "$tempdir/usr/bin/$PROJECT_NAME"Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 84–87why, one step back84 strip "$tempdir/usr/bin/$PROJECT_NAME"8586 # manpage87 install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"Fix file owner in deb package, closes #213sharkdpbefore adoption050fa9c
line 88why, one step back88 gzip --best "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 89–90why, one step back8990 # readme and licenseFix deb buildThayne McCombsbefore adoption8914b43
lines 91–93why, one step back91 install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md"92 install -Dm644 LICENSE-MIT "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-MIT"93 install -Dm644 LICENSE-APACHE "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-APACHE"Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 94–95why, one step back9495 # completionsFix shell completion directories for Ubuntusharkdpbefore adoptionc5b920b
lines 96–98why, one step back96 install -Dm644 target/$TARGET/release/build/$PROJECT_NAME-*/out/$PROJECT_NAME.bash "$tempdir/usr/share/bash-completion/completions/${PROJECT_NAME}"97 install -Dm644 target/$TARGET/release/build/$PROJECT_NAME-*/out/$PROJECT_NAME.fish "$tempdir/usr/share/fish/completions/$PROJECT_NAME.fish"98 install -Dm644 target/$TARGET/release/build/$PROJECT_NAME-*/out/_$PROJECT_NAME "$tempdir/usr/share/zsh/vendor-completions/_$PROJECT_NAME"Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 99–106why, one step back99100 # Control file101 mkdir "$tempdir/DEBIAN"102 cat > "$tempdir/DEBIAN/control" <<EOF103Package: $dpkgname104Version: $version105Section: utils106Priority: optionalFix file owner in deb package, closes #213sharkdpbefore adoption050fa9c
line 107why, one step back107Maintainer: David Peter <mail@david-peter.de>Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
line 108why, one step back108Architecture: $architectureFix deb buildThayne McCombsbefore adoption8914b43
line 109why, one step back109Provides: $PROJECT_NAMECreate deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 110–111why, one step back110Conflicts: $conflictname111Description: Simple, fast and user-friendly alternative to findFix file owner in deb package, closes #213sharkdpbefore adoption050fa9c
lines 112–113why, one step back112 While fd does not seek to mirror all of find's powerful functionality, it113 provides sensible (opinionated) defaults for 80% of the use cases.Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 114–115why, one step back114EOF115Fix file owner in deb package, closes #213sharkdpbefore adoption050fa9c
line 116why, one step back116 fakeroot dpkg-deb --build "$tempdir" "${dpkgname}_${version}_${architecture}.deb"Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 117–119why, one step back117}118119Set up Travis to upload binary for every releaseAdit Cahya Ramadhanbefore adoptiondbf1ba8
lines 120–122why, one step back120main() {121 build122 packCreate deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 123–125why, one step back123 if [[ $TARGET = *linux* ]]; then124 make_deb125 fiSet up Travis to upload binary for every releaseAdit Cahya Ramadhanbefore adoptiondbf1ba8
lines 126–128why, one step back126}127128main