Skip to content
This repository has been archived by the owner on Nov 20, 2021. It is now read-only.

Commit

Permalink
Add additional version info
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRx committed Nov 7, 2019
1 parent a798f27 commit 92e1bf2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ builds:
- all=-trimpath={{.Env.GOPATH}}
ldflags:
- -s -w
- -X github.com/criticalstack/e2d/pkg/buildinfo.Version={{.Tag}}
- -X github.com/criticalstack/e2d/pkg/buildinfo.GitSHA={{.ShortCommit}}
- -X github.com/criticalstack/e2d/pkg/buildinfo.Date={{.Date}}
- -X "github.com/criticalstack/e2d/pkg/buildinfo.Date={{.Date}}"
- -X "github.com/criticalstack/e2d/pkg/buildinfo.GitSHA={{.ShortCommit}}"
- -X "github.com/criticalstack/e2d/pkg/buildinfo.Version={{.Tag}}"
archives:
- replacements:
darwin: Darwin
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ ifneq ($(GIT_TAG),)
VERSION = $(GIT_TAG)
endif

LDFLAGS += -X github.com/criticalstack/e2d/pkg/buildinfo.GitSHA=$(GIT_SHA)
LDFLAGS += -X github.com/criticalstack/e2d/pkg/buildinfo.Version=$(VERSION)
LDFLAGS += -X "github.com/criticalstack/e2d/pkg/buildinfo.Date=$(shell date -u +'%Y-%m-%dT%TZ'))"
LDFLAGS += -X "github.com/criticalstack/e2d/pkg/buildinfo.GitSHA=$(GIT_SHA)"
LDFLAGS += -X "github.com/criticalstack/e2d/pkg/buildinfo.Version=$(VERSION)"
GOFLAGS = -gcflags "all=-trimpath=$(PWD)" -asmflags "all=-trimpath=$(PWD)"

GO_BUILD_ENV_VARS := GO111MODULE=on CGO_ENABLED=0

.PHONY: build test test-manager clean

build: clean ## Build the e2d golang binary
@$(GO_BUILD_ENV_VARS) go build -o bin/e2d $(GOFLAGS) -ldflags '$(LDFLAGS)' ./cmd/e2d
$(GO_BUILD_ENV_VARS) go build -o bin/e2d $(GOFLAGS) -ldflags '$(LDFLAGS)' ./cmd/e2d

test: ## Run all tests
go test ./...
Expand Down
4 changes: 4 additions & 0 deletions cmd/e2d/app/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ func newVersionCmd() *cobra.Command {
"Version": buildinfo.Version,
"GitSHA": buildinfo.GitSHA,
},
"build": {
"Date": buildinfo.Date,
"GoVersion": buildinfo.GoVersion,
},
})
if err != nil {
log.Fatal(err)
Expand Down
4 changes: 4 additions & 0 deletions pkg/buildinfo/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
// available at run time.
package buildinfo

import "runtime"

var (
Date string

GitSHA string

GoVersion = runtime.Version()

Version string
)

0 comments on commit 92e1bf2

Please sign in to comment.