Skip to content
Myr

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 file

Take it

Set up Travis to upload binary for every releaseAdit Cahya Ramadhanbefore adoptiondbf1ba8

lines 1–33why, one step back
1#!/usr/bin/env bash
2# 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 autocomplete

Fix path of bash completionsharkdpbefore adoption9192bc1

line 34why, one step back
34 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 back
35 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}44

Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560

lines 45–65why, one step back
45make_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* ]]; then

Fix deb buildThayne McCombsbefore adoption8914b43

lines 66–67why, one step back
66 dpkgname=$PROJECT_NAME-musl
67 conflictname=$PROJECT_NAME

Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560

line 68why, one step back
68 else

Fix deb buildThayne McCombsbefore adoption8914b43

lines 69–70why, one step back
69 dpkgname=$PROJECT_NAME
70 conflictname=$PROJECT_NAME-musl

Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560

lines 71–75why, one step back
71 fi
7273 tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)7475 # copy the main binary

Fix deb buildThayne McCombsbefore adoption8914b43

line 76why, one step back
76 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 back
77 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 back
81 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 back
82
83 # readme and license

Fix deb buildThayne McCombsbefore adoption8914b43

lines 84–86why, one step back
84 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 back
87
88 # completions

Fix shell completion directories for Ubuntusharkdpbefore adoptionc5b920b

lines 89–91why, one step back
89 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 back
92
93 # Control file94 mkdir "$tempdir/DEBIAN"95 cat > "$tempdir/DEBIAN/control" <<EOF96Package: $dpkgname97Version: $version98Section: utils99Priority: optional

Fix file owner in deb package, closes #213sharkdpbefore adoption050fa9c

line 100why, one step back
100Maintainer: David Peter <mail@david-peter.de>

Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560

line 101why, one step back
101Architecture: $architecture

Fix deb buildThayne McCombsbefore adoption8914b43

line 102why, one step back
102Provides: $PROJECT_NAME

Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560

lines 103–104why, one step back
103Conflicts: $conflictname
104Description: Simple, fast and user-friendly alternative to find

Fix file owner in deb package, closes #213sharkdpbefore adoption050fa9c

lines 105–106why, one step back
105 While fd does not seek to mirror all of find's powerful functionality, it
106 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 back
107EOF
108

Fix file owner in deb package, closes #213sharkdpbefore adoption050fa9c

line 109why, one step back
109 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 back
110}
111112

Set up Travis to upload binary for every releaseAdit Cahya Ramadhanbefore adoptiondbf1ba8

lines 113–115why, one step back
113main() {
114 build115 pack

Create deb file as part of CI build. WIPThayne McCombsbefore adoption59ea560

lines 116–118why, one step back
116 if [[ $TARGET = *linux* ]]; then
117 make_deb118 fi

Set up Travis to upload binary for every releaseAdit Cahya Ramadhanbefore adoptiondbf1ba8

lines 119–121why, one step back
119}
120121main