29 lines
1 KiB
Bash
Executable file
29 lines
1 KiB
Bash
Executable file
#!/bin/bash
|
|
set -eo pipefail
|
|
|
|
baseDir="$( cd "$(dirname "$0")" && pwd )"
|
|
cd "$baseDir"
|
|
|
|
echo "Please notice, that this build script includes metadata into the build."
|
|
echo "This information is useful for debugging and license compliance."
|
|
echo "Run the compiled binary with the version command to see the information included."
|
|
|
|
# Get version.
|
|
VERSION="$(git tag --points-at)" || true
|
|
test -z "$VERSION" && DEV_VERSION="$(git describe --tags --first-parent --abbrev=0)" || true
|
|
test -n "$DEV_VERSION" && VERSION="${DEV_VERSION}_dev_build"
|
|
test -z "$VERSION" && VERSION="dev_build"
|
|
BUILD_SOURCE=$( ( git remote -v | cut -f2 | cut -d" " -f1 | head -n 1 ) || echo "unknown" )
|
|
BUILD_TIME=$(date -u "+%Y-%m-%dT%H:%M:%SZ" || echo "unknown")
|
|
|
|
LDFLAGS="-X main.Version=${VERSION} -X main.BuildSource=${BUILD_SOURCE} -X main.BuildTime=${BUILD_TIME}"
|
|
|
|
# build output name
|
|
BIN_NAME="jess"
|
|
if [[ "$GOOS" == "windows" ]]; then
|
|
BIN_NAME="${BIN_NAME}.exe"
|
|
fi
|
|
|
|
# Build.
|
|
export CGO_ENABLED=0
|
|
go build -o "${BIN_NAME}" -ldflags "$LDFLAGS" "$@"
|