You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
581 B

4 years ago
  1. #!/bin/bash
  2. set -e
  3. APP_NAME=$1
  4. APP_VERSION=v$(cat version)
  5. BUILD_VERSION=$(git log -1 --oneline)
  6. BUILD_TIME=$(date "+%FT%T%z")
  7. GIT_REVISION=$(git rev-parse --short HEAD)
  8. GIT_BRANCH=$(git name-rev --name-only HEAD)
  9. GO_VERSION=$(go version)
  10. go build -ldflags " \
  11. -X 'main.AppName=${APP_NAME}' \
  12. -X 'main.AppVersion=${APP_VERSION}' \
  13. -X 'main.BuildVersion=${BUILD_VERSION//\'/_}' \
  14. -X 'main.BuildTime=${BUILD_TIME}' \
  15. -X 'main.GitRevision=${GIT_REVISION}' \
  16. -X 'main.GitBranch=${GIT_BRANCH}' \
  17. -X 'main.GoVersion=${GO_VERSION}' \
  18. " -o $APP_NAME