Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
GIT_VERSION = $(shell git describe --tags --dirty)
VERSION ?= $(GIT_VERSION)

VERSION_PACKAGE := github.com/dispatchframework/funky/pkg/version

GO_LDFLAGS := -X $(VERSION_PACKAGE).version=$(VERSION)
GO_LDFLAGS += -X $(VERSION_PACKAGE).buildDate=$(shell date +'%Y-%m-%dT%H:%M:%SZ')
GO_LDFLAGS += -X $(VERSION_PACKAGE).commit=$(shell git rev-parse HEAD)


.PHONY: all
all: linux

.PHONY: test
test: ## run tests
@echo running tests...
$(GO) test -v $(shell go list -v ./... | grep -v /vendor/ | grep -v integration )

.PHONY: linux
linux:
GOOS=linux go build -ldflags "$(GO_LDFLAGS)" -o funky main.go

.PHONY: release
release: linux
tar -czf funky$(VERSION).linux-amd64.tgz funky
34 changes: 34 additions & 0 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
///////////////////////////////////////////////////////////////////////
// Copyright (c) 2018 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
///////////////////////////////////////////////////////////////////////

package version

import (
"fmt"
"runtime"

"github.com/vmware/dispatch/pkg/api/v1"
)

// Filled by -ldflags passed to `go build`
var (
version string
commit string
buildDate string
)

// NO TESTS

// Get returns information about the version/build
func Get() *v1.Version {
return &v1.Version{
Version: version,
Commit: commit,
BuildDate: buildDate,
GoVersion: runtime.Version(),
Compiler: runtime.Compiler,
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
}
}