Skip to content

Commit 8db1d8b

Browse files
committed
Add generic binary packaging
1 parent d30a251 commit 8db1d8b

File tree

3 files changed

+88
-2
lines changed

3 files changed

+88
-2
lines changed

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ jobs:
3131
- stage: release
3232
if: tag IS present
3333
script:
34-
- rm -f "./pkg/deb/*.deb"
34+
- rm -f "./pkg/deb/*.deb" "./pkg/bin/*.tar.xz"
3535
- ./pkg/deb/makedeb
36+
- ./pkg/bin/makebin
3637
deploy:
3738
provider: releases
3839

3940
file_glob: true
40-
file: "./pkg/deb/*.deb"
41+
file:
42+
- "./pkg/deb/*.deb"
43+
- "./pkg/bin/*.tar.xz"
4144

4245
api_key:
4346
secure: oqadPMv+UVvrZ/33Bkgch8tc4cSqdaeMNesRm8lcNOGdLfEYhOFWu8kD9ZKSteLgA5KyWYmxKZxfjfqzRLYgPlkSOBb2Xgxhwm/MRZNU0DnqR6TSeyzcLWU9k6EQ5I8JoNferwKosy69MqoOmh0YNQT/lHoGviqsL1GTiiwBiSTUE5Jve73+vNqxbZZ+TnjvZrrSHP+clgbFR15WxR7yxMifZoqNFGLkloxFFKkB/RkArKh+it4SZNv05ZiyuP5AikvqTYlwct/efR8wcu1BOAUSzEPLAP2RFc+anJbnz5UKVH85MDv0Iyru6m35+xMAx6zkmSCBTa1Y8vkoe0OKD7s0tapcpXUyCzP2uMsQPBLssP1c+SkavwSotElLvSx6JZ9RvqyDKn/sMDngrtUf9zCa0ve4g+jlNG7ebQODLUAy1qTgYiELWObAk+eMt61sKmmNIg3teoBJ9YcxdLHCmKmykk+KJaPP0JsexT8m2gs05EScoAVrbs0ZZl8dfONUPHimuF2k1ikrfTtblmtwKxjGMbo9LDyJ++cz1InGvxzl6eK/KCnCO0DCawuWuL2sRtGvhYZgsWOLgaaT5lHnJFQu560xGbScE8swIe30wZ06NfW04zKgEqp5N9YU6eqMpwrY8CBXziDLwQGPvJ2w2kRzTPhxERX/jkWkA1p/Dy8=

pkg/bin/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
src/
2+
pkg/
3+
*.tar
4+
*.xz

pkg/bin/makebin

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/bash
2+
set -e
3+
4+
pkgname="surface-control"
5+
pkgarch="x86_64"
6+
7+
gitver=$(git describe --tags 2> /dev/null | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' || true)
8+
civer=$(echo $TRAVIS_TAG | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')
9+
10+
pkgver=${civer:-${gitver:-0.0.0}}
11+
binpkg="$pkgname-$pkgver-$pkgarch.bin.tar.xz"
12+
13+
branch="HEAD"
14+
basepath="$PWD/pkg/bin"
15+
srcdir="$basepath/src"
16+
pkgdir="$basepath/pkg"
17+
18+
19+
pushd() {
20+
command pushd "$@" > /dev/null
21+
}
22+
23+
popd() {
24+
command popd "$@" > /dev/null
25+
}
26+
27+
28+
chkdir() {
29+
if [ ! -d ".git" ]
30+
then
31+
echo "Error: Script must be run from the root directory"
32+
exit 1
33+
fi
34+
}
35+
36+
prepare() {
37+
archive="$basepath/src.tar"
38+
39+
git archive --format tar "$branch" > "$archive"
40+
41+
mkdir -p "$srcdir"
42+
tar xf "$archive" --directory "$srcdir"
43+
}
44+
45+
build() {
46+
pushd "$srcdir"
47+
env CARGO_TARGET_DIR="$PWD/target" CARGO_INCREMENTAL=0 cargo build --release --locked
48+
popd
49+
}
50+
51+
package() {
52+
pushd "$srcdir"
53+
54+
# clean package directory
55+
rm -rf "$pkgdir"
56+
mkdir -p "$pkgdir"
57+
58+
# copy binary files
59+
install -D -m755 "target/release/surface" "$pkgdir/bin/surface"
60+
61+
# copy completion files
62+
install -D -m644 "target/surface.bash" "$pkgdir/shell-completions/surface.bash"
63+
install -D -m644 "target/_surface" "$pkgdir/shell-completions/surface.zsh"
64+
install -D -m644 "target/surface.fish" "$pkgdir/shell-completions/surface.fish"
65+
66+
# copy license
67+
install -D -m644 "LICENSE" "$pkgdir/LICENSE"
68+
69+
# zip package
70+
tar -C "$pkgdir" -cJf "$basepath/$binpkg" .
71+
72+
popd
73+
}
74+
75+
76+
chkdir
77+
prepare
78+
build
79+
package

0 commit comments

Comments
 (0)