Skip to content

Commit

Permalink
Determine the version using git describe (#2388)
Browse files Browse the repository at this point in the history
`v0.18.0-16-g4721f834` - the current head of my current branch is based on v0.18.0, but since it has a few commits on top of that, describe has added the number of additional commits ("16") and an abbreviated object name for the commit itself ("4721f834") at the end.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored Jan 20, 2021
1 parent ccee4eb commit 96b226a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ TOOLS_MOD_DIR := ./internal/tools

GOOS=$(shell go env GOOS)
GOARCH=$(shell go env GOARCH)
# BUILD_TYPE should be one of (dev, release).
BUILD_TYPE?=release

GIT_SHA=$(shell git rev-parse --short HEAD)
BUILD_INFO_IMPORT_PATH=go.opentelemetry.io/collector/internal/version
GIT_SHA=$(shell git rev-parse --short HEAD)
BUILD_X1=-X $(BUILD_INFO_IMPORT_PATH).GitHash=$(GIT_SHA)
ifdef VERSION
VERSION=$(shell git describe --match "v[0-9]*" HEAD)
BUILD_X2=-X $(BUILD_INFO_IMPORT_PATH).Version=$(VERSION)
endif
# BUILD_TYPE should be one of (dev, release).
BUILD_TYPE?=release
BUILD_X3=-X $(BUILD_INFO_IMPORT_PATH).BuildType=$(BUILD_TYPE)
BUILD_INFO=-ldflags "${BUILD_X1} ${BUILD_X2} ${BUILD_X3}"

Expand Down

0 comments on commit 96b226a

Please sign in to comment.