-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·64 lines (52 loc) · 1.44 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
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
set -e
# TODO: detect versions from main.go and dockerfiles and make this more dynamic
FORCE=0
VERSION=""
for i in "$@"
do
case ${i} in
-f|--force)
FORCE=1
shift
;;
*)
;;
esac
done
function get_version() {
V=$(grep 'const version' cmd/fdb-clusterfile/main.go | awk '{print $4}')
VERSION="${V%\"}"
VERSION="${VERSION#\"}"
if ! [[ ${VERSION} =~ [0-9]+\.[0-9]+\.[0-9] ]]; then
echo "Invalid version from cmd/fdb-clusterfile/main.go"
exit
fi
}
function already_built() {
OS=$1
if [[ -f ./releases/${OS}/${VERSION}/fdb-clusterfile ]]; then
echo "1"
else
echo "0"
fi
}
function build() {
OS=$1
built=$(already_built ${OS})
if [[ "$built" == "1" ]] && [[ ${FORCE} -eq 0 ]]; then
echo "$OS: binary already in ./releases/${OS}/${VERSION}/fdb-clusterfile. Use -f to rebuild"
return
fi
mkdir -p ./releases/${OS}/${VERSION}
docker build -t fdb-clusterfile-${OS}:${VERSION} -f ${OS}.dockerfile .
docker run -d --name fdb-clusterfile-${OS} fdb-clusterfile-${OS}:${VERSION}
docker cp fdb-clusterfile-${OS}:/build/cmd/fdb-clusterfile/fdb-clusterfile ./releases/${OS}/${VERSION}/
docker stop fdb-clusterfile-${OS}
docker rm fdb-clusterfile-${OS}
echo "$OS: binary built and placed in ./releases/${OS}/${VERSION}/fdb-clusterfile"
}
get_version
build alpine
build debian
build ubuntu