-
Notifications
You must be signed in to change notification settings - Fork 1
/
release.sh
57 lines (38 loc) · 1.06 KB
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
set -e
PACKAGE="voiceip-b2bua"
function die() {
echo $1;
exit 1
}
function replacePlaceHolders() {
file="$1"
$SED_CMD -i -e "s/_PACKAGE_/$PACKAGE/g" $file
}
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Build Starting...."
else
die "Build only supported on linux os"
fi
SED_CMD="sed"
# if [ "$(uname)" == "Darwin" ]; then
# SED_CMD="gsed"
# fi
BUILD_ROOT=$(mktemp -d)
VERSION=$(date +%s)
cp -r distribution/debian/* $BUILD_ROOT/
mkdir -p $BUILD_ROOT/usr/local/bin/
mkdir -p bin
##build
GOOS=linux go build -gcflags "all=-N -l" -o bin/voiceip-b2bua.linux
cp ./bin/voiceip-b2bua.linux $BUILD_ROOT/usr/local/bin/$PACKAGE
#replacing constants
replacePlaceHolders "${BUILD_ROOT}/DEBIAN/prerm"
replacePlaceHolders "${BUILD_ROOT}/DEBIAN/postrm"
replacePlaceHolders "${BUILD_ROOT}/DEBIAN/postinst"
replacePlaceHolders "${BUILD_ROOT}/DEBIAN/control"
$SED_CMD -i "s/_VERSION_/$VERSION/g" $BUILD_ROOT/DEBIAN/control
echo "Package Version: 1.$VERSION"
rm -f $PACKAGE.deb
dpkg-deb --build $BUILD_ROOT $PACKAGE.deb
rm -rf $BUILD_ROOT