Skip to content
Myr

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 file

Take it

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

lines 1–13why, 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_name

Enable ARM cross-compilationsharkdpbefore adoption6fb5004

line 14why, one step back
14 local gcc_prefix

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

lines 15–19why, one step back
15
16 tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)17 out_dir=$(pwd)18 package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET"19

Enable ARM cross-compilationsharkdpbefore adoption6fb5004

lines 20–25why, one step back
20 if [[ $TARGET == "arm-unknown-linux-gnueabihf" ]]; then
21 gcc_prefix="arm-linux-gnueabihf-"22 else23 gcc_prefix=""24 fi25

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

lines 26–31why, one step back
26 # create a "staging" directory
27 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 back
32 "${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 back
33
34 # 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 autocomplete

Fix path of bash completionsharkdpbefore adoption9192bc1

line 41why, one step back
41 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 back
42 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}51

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

lines 52–66why, one step back
52make_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 back
67 echo "make_deb: skipping target '${TARGET}'" >&2
68 return 0

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

lines 69–72why, one step back
69 ;;
70 esac71 version=${TRAVIS_TAG#v}72 if [[ $TARGET = *musl* ]]; then

Fix deb buildThayne McCombsbefore adoption8914b43

lines 73–74why, one step back
73 dpkgname=$PROJECT_NAME-musl
74 conflictname=$PROJECT_NAME

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

line 75why, one step back
75 else

Fix deb buildThayne McCombsbefore adoption8914b43

lines 76–77why, one step back
76 dpkgname=$PROJECT_NAME
77 conflictname=$PROJECT_NAME-musl

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

lines 78–82why, one step back
78 fi
7980 tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)8182 # copy the main binary

Fix deb buildThayne McCombsbefore adoption8914b43

line 83why, one step back
83 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 back
84 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 back
88 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 back
89
90 # readme and license

Fix deb buildThayne McCombsbefore adoption8914b43

lines 91–93why, one step back
91 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 back
94
95 # completions

Fix shell completion directories for Ubuntusharkdpbefore adoptionc5b920b

lines 96–98why, one step back
96 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 back
99
100 # Control file101 mkdir "$tempdir/DEBIAN"102 cat > "$tempdir/DEBIAN/control" <<EOF103Package: $dpkgname104Version: $version105Section: utils106Priority: optional

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

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

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

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

Fix deb buildThayne McCombsbefore adoption8914b43

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

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

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

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

lines 112–113why, one step back
112 While fd does not seek to mirror all of find's powerful functionality, it
113 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 back
114EOF
115

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

line 116why, one step back
116 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 back
117}
118119

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

lines 120–122why, one step back
120main() {
121 build122 pack

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

lines 123–125why, one step back
123 if [[ $TARGET = *linux* ]]; then
124 make_deb125 fi

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

lines 126–128why, one step back
126}
127128main