-
Notifications
You must be signed in to change notification settings - Fork 15
/
make.sh
executable file
·59 lines (48 loc) · 1.32 KB
/
make.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
#!/bin/bash
set -e
check_prerequisites() {
[[ "$GOPATH" == "" ]] && \
errors=(${errors[@]} "GOPATH env missing")
[[ -x "$GOPATH/bin/dep" ]] || \
errors=("${errors[@]}" "dep not found in \"$GOPATH/bin/\"")
if [[ "${#errors[@]}" > 0 ]]; then
echo "Errors:"
for error in "${errors[@]}"; do
echo " $error"
done
return 1
fi
return 0
}
check_versions() {
VERS="${LATEST_RELEASE}\n${MAIN_VER}"
DKR_TAG="master"
# For tagged commits
if [ "$(git describe --tags)" = "$(git describe --tags --abbrev=0)" ] ; then
if [ $(printf ${VERS} | uniq | wc -l) -gt 1 ] ; then
echo "This is a release, all versions should match"
return 1
fi
DKR_TAG="latest"
else
if [ $(printf ${VERS} | uniq | wc -l) -eq 1 ] ; then
echo "Please increment the version in main.go"
return 1
fi
if [ "$(printf ${VERS} | sort -V | tail -n 1)" != "${MAIN_VER}" ] ; then
echo "Please increment the version in main.go"
return 1
fi
fi
}
LATEST_RELEASE=$(git describe --tags --abbrev=0 | sed "s/^v//g")
MAIN_VER=$(grep "\t*version *= " main.go | sed 's/\t*version *= //g' | sed 's/"//g')
check_prerequisites || exit 1
check_versions || exit 1
echo "Installing Dependencies..."
$GOPATH/bin/dep ensure
echo "Linting..."
gometalinter --vendor ./...
echo "Building..."
mkdir bin 2>/dev/null || true
go build -o bin/docker-zfs-plugin .