Skip to content

Commit

Permalink
Merge pull request #8 from berndtj/add-makefile
Browse files Browse the repository at this point in the history
Add makefile for easy releases
  • Loading branch information
berndtj authored Sep 13, 2018
2 parents 3d98365 + 5e82b4c commit 2375111
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
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),
}
}

0 comments on commit 2375111

Please sign in to comment.