Skip to content

Commit

Permalink
Merge pull request #129 from ethernetdan/version
Browse files Browse the repository at this point in the history
Added versions to builds
  • Loading branch information
ethernetdan committed Apr 9, 2016
2 parents 492f742 + d6fc468 commit 0c8a9cf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion cmd/spread/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
2 changes: 2 additions & 0 deletions test/mattermost-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ if [ ! -f $KUBECTL ]; then
chmod +x $KUBECTL
fi

spread

echo "Starting up localkube server"
spread cluster start

Expand Down

0 comments on commit 0c8a9cf

Please sign in to comment.