Skip to content

Commit

Permalink
Merge pull request #64 from displague/git-versions
Browse files Browse the repository at this point in the history
derive version at "make build" time from git tags
  • Loading branch information
displague authored Aug 6, 2020
2 parents 1982aee + 56cd8d9 commit 1b36a84
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ K := $(foreach exec,$(EXECUTABLES),\

ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

BINARY=packet
VERSION=0.0.5
PACKAGE_NAME?=github.com/packethost/packet-cli
BINARY?=packet
GIT_VERSION?=$(shell git log -1 --format="%h")
VERSION?=$(GIT_VERSION)
RELEASE_TAG?=$(shell git tag --points-at HEAD)
ifneq (,$(RELEASE_TAG))
VERSION:=$(RELEASE_TAG)-$(VERSION)
endif

BUILD=`git rev-parse --short HEAD`
PLATFORMS=darwin linux windows freebsd
ARCHITECTURES=amd64 arm64
PLATFORMS?=darwin linux windows freebsd
ARCHITECTURES?=amd64 arm64

# Setup linker flags option for build that interoperate with variable names in src code
LDFLAGS=-ldflags "-X github.com/packethost/packet-cli/cmd.Version=${VERSION} -X github.com/packethost/packet-cli/cmd.Build=${BUILD}"
LDFLAGS?=-ldflags "-X $(PACKAGE_NAME)/cmd.Version=$(VERSION) -X $(PACKAGE_NAME)/cmd.Build=$(BUILD)"

default: generate-docs
go fmt ./...
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Cli struct {

// VERSION build
var (
Version string = "0.0.7"
Version string = "devel"
)

// NewCli struct
Expand Down

0 comments on commit 1b36a84

Please sign in to comment.