-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.sh
executable file
·27 lines (23 loc) · 889 Bytes
/
build.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
#!/bin/bash
# Get the directory of this script
# https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Get the name of the repository
# https://stackoverflow.com/questions/23162299/how-to-get-the-last-part-of-dirname-in-bash/23162553
REPO="$(basename "$DIR")"
# For non-interactive shells (e.g. the server running this script to build itself),
# $HOME must be specified or it will result in a cache error when compiling the Go code
# (but don't do this in Travis, since doing this will cause it to break)
if [[ -z $CI ]]; then
export HOME=/root
fi
# Compile the Golang code
cd "$DIR/src"
go test
cd "$DIR/src/cmd/server"
go build -o "$DIR/$REPO"
if [[ $? -ne 0 ]]; then
echo "$REPO - Go compilation failed!"
exit 1
fi
echo "$REPO - Go compilation succeeded."