| 1 |
#!/bin/sh |
| 2 |
# Builds a static stripped binary with version information. |
| 3 |
# |
| 4 |
# This script is used to build a binary for the current platform. Cgo is |
| 5 |
# disabled to make sure the binary is statically linked. Appropriate flags are |
| 6 |
# given to the go compiler to strip the binary. Current git tag is passed to |
| 7 |
# the compiler by default to be used as the version in the binary. |
| 8 |
|
| 9 |
set -o errexit -o nounset |
| 10 |
|
| 11 |
[ -z "${version:-}" ] && version=$(git describe --tags --abbrev=0) |
| 12 |
|
| 13 |
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X main.gVersion=$version" "$@" |
| 14 |
|
| 15 |
# vim: tabstop=4 shiftwidth=4 textwidth=80 colorcolumn=80 |