Skip to content

Commit

Permalink
Merge pull request #32 from seatgeek/fix-version-from-tag
Browse files Browse the repository at this point in the history
Use version from git tag
  • Loading branch information
burdandrei authored May 29, 2019
2 parents a16f727 + 1927c6d commit 2e9e42f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ BUILD_DIR ?= $(abspath build)
GET_GOARCH = $(word 2,$(subst -, ,$1))
GET_GOOS = $(word 1,$(subst -, ,$1))
GOBUILD ?= $(shell go env GOOS)-$(shell go env GOARCH)
GIT_COMMIT := $(shell git describe --tags)
GIT_DIRTY := $(if $(shell git status --porcelain),+CHANGES)
GO_LDFLAGS := "-X main.Version=$(GIT_COMMIT)$(GIT_DIRTY)"

$(BUILD_DIR):
mkdir -p $@
Expand All @@ -28,7 +31,7 @@ ci: install
BINARIES = $(addprefix $(BUILD_DIR)/hashi-helper-, $(GOBUILD))
$(BINARIES): $(BUILD_DIR)/hashi-helper-%: $(BUILD_DIR)
@echo "=> building $@ ..."
GOOS=$(call GET_GOOS,$*) GOARCH=$(call GET_GOARCH,$*) CGO_ENABLED=0 go build -o $@
GOOS=$(call GET_GOOS,$*) GOARCH=$(call GET_GOARCH,$*) CGO_ENABLED=0 go build -o $@ -ldflags $(GO_LDFLAGS)

.PHONY: dist
dist: install
Expand Down
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ import (
cli "gopkg.in/urfave/cli.v1"
)

var (
// Version is filled in by the compiler (git tag + changes)
Version = "local-dev"
)

func main() {
app := cli.NewApp()
app.Name = "vault-manager"
app.Usage = "easily restore / snapshot your secrets"
app.Version = "0.1"
app.Version = Version

app.Flags = []cli.Flag{
cli.IntFlag{
Expand Down

0 comments on commit 2e9e42f

Please sign in to comment.