From aa0f9a7720b520f369852b8ebbc3cca8ff898812 Mon Sep 17 00:00:00 2001 From: Dan Gillespie Date: Fri, 8 Apr 2016 19:34:57 -0400 Subject: [PATCH 1/2] added version to builds --- .travis.yml | 2 +- Makefile | 17 ++++++++++++----- cmd/spread/info.go | 4 +++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 85ec119..8c5af7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ script: after_success: # If release then crosscompile - - if [ -n "$TRAVIS_TAG" ]; then make crossbuild; else echo "Skipping release build..."; fi + - if [ -n "$TRAVIS_TAG" ]; then SPREAD_VERSION=$TRAVIS_TAG make crossbuild; else echo "Skipping release build..."; fi deploy: provider: releases diff --git a/Makefile b/Makefile index 15c0e91..6d70eb8 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,11 @@ CMD_NAME := spread EXEC_PKG := $(BASE)/cmd/$(CMD_NAME) PKGS := ./pkg/... ./cli/... ./cmd/... +# set spread version if not provided by environment +ifndef SPREAD_VERSION + SPREAD_VERSION := v0.0.0 +endif + GOX_OS ?= linux darwin windows GOX_ARCH ?= amd64 @@ -13,14 +18,16 @@ GOFMT ?= gofmt # eventually should add "-s" GOLINT ?= golint DOCKER ?= docker +VERSION_LDFLAG := -X main.Version=$(SPREAD_VERSION) + GOFILES := find . -name '*.go' -not -path "./vendor/*" -GOBUILD_LDFLAGS ?= +GOBUILD_LDFLAGS ?= $(VERSION_LDFLAG) GOBUILD_FLAGS ?= -i -v GOTEST_FLAGS ?= -v GOX_FLAGS ?= -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}" -os="${GOX_OS}" -arch="${GOX_ARCH}" -STATIC_LDFLAGS ?= --ldflags '-extldflags "-static" --s -w' +STATIC_LDFLAGS ?= -extldflags "-static" --s -w GITLAB_CONTEXT ?= ./build/gitlab @@ -59,15 +66,15 @@ validate: lint checkgofmt vet build: build/spread build/spread: - $(GO) build $(GOBUILD_FLAGS) $(GOBUILD_LDFLAGS) -o $@ $(EXEC_PKG) + $(GO) build $(GOBUILD_FLAGS) -ldflags "$(GOBUILD_LDFLAGS)" -o $@ $(EXEC_PKG) build/spread-linux-static: - GOOS=linux $(GO) build -o $@ $(GOBUILD_FLAGS) $(STATIC_LDFLAGS) $(EXEC_PKG) + GOOS=linux $(GO) build -o $@ $(GOBUILD_FLAGS) -ldflags "$(GOBUILD_LDFLAGS) $(STATIC_LDFLAGS)" $(EXEC_PKG) chmod +x $@ .PHONY: crossbuild crossbuild: deps gox-setup - $(GOX) $(GOX_FLAGS) -gcflags="$(GOBUILD_FLAGS)" -ldflags="$(GOBUILD_LDFLAGS)" $(EXEC_PKG) + $(GOX) $(GOX_FLAGS) -gcflags="$(GOBUILD_FLAGS)" -ldflags="$(GOBUILD_LDFLAGS) $(STATIC_LDFLAGS)" $(EXEC_PKG) .PHONY: build-gitlab build-gitlab: build/spread-linux-static diff --git a/cmd/spread/info.go b/cmd/spread/info.go index b3ba8ab..e51578c 100644 --- a/cmd/spread/info.go +++ b/cmd/spread/info.go @@ -3,7 +3,9 @@ package main const ( // Usage is a short explanation of what spread does Usage = "Quickly iterate with Kubernetes" +) +var ( // Version is the current version number - Version = "0.0.3" + Version = "Unset" ) From d6fc468a78db9690864e1d410aafeb8a9785ef0a Mon Sep 17 00:00:00 2001 From: Dan Gillespie Date: Fri, 8 Apr 2016 19:36:18 -0400 Subject: [PATCH 2/2] added version to test output --- test/mattermost-demo.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/mattermost-demo.sh b/test/mattermost-demo.sh index 7ecb233..8717e33 100755 --- a/test/mattermost-demo.sh +++ b/test/mattermost-demo.sh @@ -32,6 +32,8 @@ if [ ! -f $KUBECTL ]; then chmod +x $KUBECTL fi +spread + echo "Starting up localkube server" spread cluster start