on master help sign in
Add CI scripts
commit14615ebd43297b6eb2ee310ed5d556b387cbd125 authorsharkdp <davidpeter@web.de> dateSun 22 Apr 2018, 15:35 (9 years ago) parenteded921
1 file changed+103
ci/before_deploy.bash+103
ci/before_deploy.bashnew file+103
@@ -0,0 +1,103 @@
1+#!/usr/bin/env bash
2+# Building and packaging for release
3+
4+set -ex
5+
6+build() {
7+ cargo build --target "$TARGET" --release --verbose
8+}
9+
10+pack() {
11+ local tempdir
12+ local out_dir
13+ local package_name
14+
15+ tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
16+ out_dir=$(pwd)
17+ package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET"
18+
19+ # create a "staging" directory
20+ mkdir "$tempdir/$package_name"
21+
22+ # copying the main binary
23+ cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/"
24+ strip "$tempdir/$package_name/$PROJECT_NAME"
25+
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"
30+
31+ # archiving
32+ pushd "$tempdir"
33+ tar czf "$out_dir/$package_name.tar.gz" "$package_name"/*
34+ popd
35+ rm -r "$tempdir"
36+}
37+
38+make_deb() {
39+ local tempdir
40+ local architecture
41+ local version
42+ local dpkgname
43+ local conflictname
44+
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
65+
66+ tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
67+
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"
71+
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"
76+
77+ # Control file
78+ mkdir "$tempdir/DEBIAN"
79+ cat > "$tempdir/DEBIAN/control" <<EOF
80+Package: $dpkgname
81+Version: $version
82+Section: utils
83+Priority: optional
84+Maintainer: David Peter <mail@david-peter.de>
85+Architecture: $architecture
86+Provides: $PROJECT_NAME
87+Conflicts: $conflictname
88+Description: A cat(1) clone with wings.
89+EOF
90+
91+ fakeroot dpkg-deb --build "$tempdir" "${dpkgname}_${version}_${architecture}.deb"
92+}
93+
94+
95+main() {
96+ build
97+ pack
98+ if [[ $TARGET = *linux* ]]; then
99+ make_deb
100+ fi
101+}
102+
103+main