before_deploy.bash
This file
Path
ci/before_deploy.bash
121 lines · 3.7 KiB · Shell
Last changed by
Fix file owner in deb package, closes #213sharkdpbefore adoption050fa9c
History of this fileTake it
Set up Travis to upload binary for every releaseAdit Cahya Ramadhanbefore adoptiondbf1ba8
lines 1–33why, 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"21 mkdir "$tempdir/$package_name/autocomplete"2223 # copying the main binary24 cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/"25 strip "$tempdir/$package_name/$PROJECT_NAME"2627 # manpage, readme and license28 cp "doc/$PROJECT_NAME.1" "$tempdir/$package_name"29 cp README.md "$tempdir/$package_name"30 cp LICENSE-MIT "$tempdir/$package_name"31 cp LICENSE-APACHE "$tempdir/$package_name"3233 # various autocompleteFix path of bash completionsharkdpbefore adoption9192bc1
line 34why, one step back34 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 35–44why, one step back35 cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".fish "$tempdir/$package_name/autocomplete"36 cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/_"$PROJECT_NAME" "$tempdir/$package_name/autocomplete"3738 # archiving39 pushd "$tempdir"40 tar czf "$out_dir/$package_name.tar.gz" "$package_name"/*41 popd42 rm -r "$tempdir"43}44Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 45–65why, one step back45make_deb() {46 local tempdir47 local architecture48 local version49 local dpkgname50 local conflictname5152 case $TARGET in53 x86_64*)54 architecture=amd6455 ;;56 i686*)57 architecture=i38658 ;;59 *)60 echo "ERROR: unknown target" >&261 return 162 ;;63 esac64 version=${TRAVIS_TAG#v}65 if [[ $TARGET = *musl* ]]; thenFix deb buildThayne McCombsbefore adoption8914b43
lines 66–67why, one step back66 dpkgname=$PROJECT_NAME-musl67 conflictname=$PROJECT_NAMECreate deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
line 68why, one step back68 elseFix deb buildThayne McCombsbefore adoption8914b43
lines 69–70why, one step back69 dpkgname=$PROJECT_NAME70 conflictname=$PROJECT_NAME-muslCreate deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 71–75why, one step back71 fi7273 tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)7475 # copy the main binaryFix deb buildThayne McCombsbefore adoption8914b43
line 76why, one step back76 install -Dm755 "target/$TARGET/release/$PROJECT_NAME" "$tempdir/usr/bin/$PROJECT_NAME"Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 77–80why, one step back77 strip "$tempdir/usr/bin/$PROJECT_NAME"7879 # manpage80 install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"Fix file owner in deb package, closes #213sharkdpbefore adoption050fa9c
line 81why, one step back81 gzip --best "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 82–83why, one step back8283 # readme and licenseFix deb buildThayne McCombsbefore adoption8914b43
lines 84–86why, one step back84 install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md"85 install -Dm644 LICENSE-MIT "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-MIT"86 install -Dm644 LICENSE-APACHE "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-APACHE"Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 87–88why, one step back8788 # completionsFix shell completion directories for Ubuntusharkdpbefore adoptionc5b920b
lines 89–91why, one step back89 install -Dm644 target/$TARGET/release/build/$PROJECT_NAME-*/out/$PROJECT_NAME.bash "$tempdir/usr/share/bash-completion/completions/${PROJECT_NAME}"90 install -Dm644 target/$TARGET/release/build/$PROJECT_NAME-*/out/$PROJECT_NAME.fish "$tempdir/usr/share/fish/completions/$PROJECT_NAME.fish"91 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 92–99why, one step back9293 # Control file94 mkdir "$tempdir/DEBIAN"95 cat > "$tempdir/DEBIAN/control" <<EOF96Package: $dpkgname97Version: $version98Section: utils99Priority: optionalFix file owner in deb package, closes #213sharkdpbefore adoption050fa9c
line 100why, one step back100Maintainer: David Peter <mail@david-peter.de>Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
line 101why, one step back101Architecture: $architectureFix deb buildThayne McCombsbefore adoption8914b43
line 102why, one step back102Provides: $PROJECT_NAMECreate deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 103–104why, one step back103Conflicts: $conflictname104Description: Simple, fast and user-friendly alternative to findFix file owner in deb package, closes #213sharkdpbefore adoption050fa9c
lines 105–106why, one step back105 While fd does not seek to mirror all of find's powerful functionality, it106 provides sensible (opinionated) defaults for 80% of the use cases.Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 107–108why, one step back107EOF108Fix file owner in deb package, closes #213sharkdpbefore adoption050fa9c
line 109why, one step back109 fakeroot dpkg-deb --build "$tempdir" "${dpkgname}_${version}_${architecture}.deb"Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 110–112why, one step back110}111112Set up Travis to upload binary for every releaseAdit Cahya Ramadhanbefore adoptiondbf1ba8
lines 113–115why, one step back113main() {114 build115 packCreate deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560
lines 116–118why, one step back116 if [[ $TARGET = *linux* ]]; then117 make_deb118 fiSet up Travis to upload binary for every releaseAdit Cahya Ramadhanbefore adoptiondbf1ba8
lines 119–121why, one step back119}120121main