build: extract the version number from git

Update the tests as well.
This commit is contained in:
Alex Crawford
2015-08-12 10:53:32 -07:00
parent ec8742c9ba
commit 56a80d84cf
3 changed files with 20 additions and 42 deletions

7
build
View File

@@ -1,7 +1,10 @@
#!/bin/bash -e
NAME="coreos-cloudinit"
ORG_PATH="github.com/coreos"
REPO_PATH="${ORG_PATH}/coreos-cloudinit"
REPO_PATH="${ORG_PATH}/${NAME}"
VERSION=$(git describe --dirty --tags)
GLDFLAGS="-X main.version \"${VERSION}\""
if [ ! -h gopath/src/${REPO_PATH} ]; then
mkdir -p gopath/src/${ORG_PATH}
@@ -11,4 +14,4 @@ fi
export GOBIN=${PWD}/bin
export GOPATH=${PWD}/gopath
go build -o bin/coreos-cloudinit ${REPO_PATH}
go build -ldflags "${GLDFLAGS}" -o ${GOBIN}/${NAME} ${REPO_PATH}