Skip to content

Commit 2375111

Browse files
authored
Merge pull request #8 from berndtj/add-makefile
Add makefile for easy releases
2 parents 3d98365 + 5e82b4c commit 2375111

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
GIT_VERSION = $(shell git describe --tags --dirty)
2+
VERSION ?= $(GIT_VERSION)
3+
4+
VERSION_PACKAGE := github.com/dispatchframework/funky/pkg/version
5+
6+
GO_LDFLAGS := -X $(VERSION_PACKAGE).version=$(VERSION)
7+
GO_LDFLAGS += -X $(VERSION_PACKAGE).buildDate=$(shell date +'%Y-%m-%dT%H:%M:%SZ')
8+
GO_LDFLAGS += -X $(VERSION_PACKAGE).commit=$(shell git rev-parse HEAD)
9+
10+
11+
.PHONY: all
12+
all: linux
13+
14+
.PHONY: test
15+
test: ## run tests
16+
@echo running tests...
17+
$(GO) test -v $(shell go list -v ./... | grep -v /vendor/ | grep -v integration )
18+
19+
.PHONY: linux
20+
linux:
21+
GOOS=linux go build -ldflags "$(GO_LDFLAGS)" -o funky main.go
22+
23+
.PHONY: release
24+
release: linux
25+
tar -czf funky$(VERSION).linux-amd64.tgz funky

pkg/version/version.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
///////////////////////////////////////////////////////////////////////
2+
// Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3+
// SPDX-License-Identifier: Apache-2.0
4+
///////////////////////////////////////////////////////////////////////
5+
6+
package version
7+
8+
import (
9+
"fmt"
10+
"runtime"
11+
12+
"github.com/vmware/dispatch/pkg/api/v1"
13+
)
14+
15+
// Filled by -ldflags passed to `go build`
16+
var (
17+
version string
18+
commit string
19+
buildDate string
20+
)
21+
22+
// NO TESTS
23+
24+
// Get returns information about the version/build
25+
func Get() *v1.Version {
26+
return &v1.Version{
27+
Version: version,
28+
Commit: commit,
29+
BuildDate: buildDate,
30+
GoVersion: runtime.Version(),
31+
Compiler: runtime.Compiler,
32+
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
33+
}
34+
}

0 commit comments

Comments
 (0)