on v0.4.1 help sign in
bat/ci/before_deploy.bash
103 lines 2.4 kB history raw
1#!/usr/bin/env bash
2# Building and packaging for release
4set -ex
6build() {
7 cargo build --target "$TARGET" --release --verbose
8}
10pack() {
11 local tempdir
12 local out_dir
13 local package_name
15 tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
16 out_dir=$(pwd)
17 package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET"
19 # create a "staging" directory
20 mkdir "$tempdir/$package_name"
22 # copying the main binary
23 cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/"
24 strip "$tempdir/$package_name/$PROJECT_NAME"
26 # readme and license
27 cp README.md "$tempdir/$package_name"
28 cp LICENSE-MIT "$tempdir/$package_name"
29 cp LICENSE-APACHE "$tempdir/$package_name"
31 # archiving
32 pushd "$tempdir"
33 tar czf "$out_dir/$package_name.tar.gz" "$package_name"/*
34 popd
35 rm -r "$tempdir"
38make_deb() {
39 local tempdir
40 local architecture
41 local version
42 local dpkgname
43 local conflictname
45 case $TARGET in
46 x86_64*)
47 architecture=amd64
48 ;;
49 i686*)
50 architecture=i386
51 ;;
52 *)
53 echo "ERROR: unknown target" >&2
54 return 1
55 ;;
56 esac
57 version=${TRAVIS_TAG#v}
58 if [[ $TARGET = *musl* ]]; then
59 dpkgname=$PROJECT_NAME-musl
60 conflictname=$PROJECT_NAME
61 else
62 dpkgname=$PROJECT_NAME
63 conflictname=$PROJECT_NAME-musl
64 fi
66 tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
68 # copy the main binary
69 install -Dm755 "target/$TARGET/release/$PROJECT_NAME" "$tempdir/usr/bin/$PROJECT_NAME"
70 strip "$tempdir/usr/bin/$PROJECT_NAME"
72 # readme and license
73 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"
77 # Control file
78 mkdir "$tempdir/DEBIAN"
79 cat > "$tempdir/DEBIAN/control" <<EOF
80Package: $dpkgname
81Version: $version
82Section: utils
83Priority: optional
84Maintainer: David Peter <mail@david-peter.de>
85Architecture: $architecture
86Provides: $PROJECT_NAME
87Conflicts: $conflictname
88Description: A cat(1) clone with wings.
89EOF
91 fakeroot dpkg-deb --build "$tempdir" "${dpkgname}_${version}_${architecture}.deb"
95main() {
96 build
97 pack
98 if [[ $TARGET = *linux* ]]; then
99 make_deb
100 fi
103main