Skip to content

Commit

Permalink
chore(version): Add codename to v20.07. (#6114)
Browse files Browse the repository at this point in the history
* chore(version): Add release codename to version output. (#6113)

This adds a codename field to the dgraph version output. The codename
is set explicitly in the Makefiles for Dgraph. The codename is also
pushed to Sentry.

Additionally, this updates the Makefile to check if the working
directory has any uncommitted changes. If so, the codename is suffixed
with "-mod" to indicate that the binary was created with uncommitted
modified changes.

Changes
* Update dgraph version output with the codename
* Update build Makefiles to include the codename and "-mod" suffix
* Update Sentry reporting

* Set v20.07 codename to "shuri".

For example:

Dgraph version   : v20.07.0-2-g2af036ef9
Dgraph codename  : shuri
Dgraph SHA-256   : 4b0bb2ccbe0e2267c0ad3bd46570a46facfefd5c237ab6cf2948911cfebc0b18
Commit SHA-1     : 2af036ef9
Commit timestamp : 2020-07-28 15:27:14 -0700
Branch           : release/v20.07
Go version       : go1.14.4
  • Loading branch information
danielmai authored Jul 28, 2020
1 parent 8122a81 commit d65e205
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
# limitations under the License.
#

BUILD ?= $(shell git rev-parse --short HEAD)
BUILD_DATE ?= $(shell git log -1 --format=%ci)
BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BUILD_VERSION ?= $(shell git describe --always --tags)
BUILD ?= $(shell git rev-parse --short HEAD)
BUILD_CODENAME = shuri
BUILD_DATE ?= $(shell git log -1 --format=%ci)
BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BUILD_VERSION ?= $(shell git describe --always --tags)

MODIFIED = $(shell git diff-index --quiet HEAD || echo "-mod")

SUBDIRS = dgraph

Expand All @@ -35,6 +38,7 @@ oss:
version:
@echo Dgraph ${BUILD_VERSION}
@echo Build: ${BUILD}
@echo Codename: ${BUILD_CODENAME}${MODIFIED}
@echo Build date: ${BUILD_DATE}
@echo Branch: ${BUILD_BRANCH}
@echo Go version: $(shell go version)
Expand Down
28 changes: 16 additions & 12 deletions dgraph/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,27 @@
# limitations under the License.
#

BIN = dgraph
BUILD ?= $(shell git rev-parse --short HEAD)
BUILD_DATE ?= $(shell git log -1 --format=%ci)
BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BUILD_VERSION ?= $(shell git describe --always --tags)
BUILD_TAGS ?=
GOPATH ?= $(shell go env GOPATH)
BIN = dgraph
BUILD ?= $(shell git rev-parse --short HEAD)
BUILD_CODENAME = shuri
BUILD_DATE ?= $(shell git log -1 --format=%ci)
BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BUILD_VERSION ?= $(shell git describe --always --tags)
BUILD_TAGS ?=
GOPATH ?= $(shell go env GOPATH)

MODIFIED = $(shell git diff-index --quiet HEAD || echo "-mod")

export GO111MODULE := on

# Build-time Go variables
dgraphVersion = github.com/dgraph-io/dgraph/x.dgraphVersion
gitBranch = github.com/dgraph-io/dgraph/x.gitBranch
lastCommitSHA = github.com/dgraph-io/dgraph/x.lastCommitSHA
lastCommitTime = github.com/dgraph-io/dgraph/x.lastCommitTime
dgraphVersion = github.com/dgraph-io/dgraph/x.dgraphVersion
dgraphCodename = github.com/dgraph-io/dgraph/x.dgraphCodename
gitBranch = github.com/dgraph-io/dgraph/x.gitBranch
lastCommitSHA = github.com/dgraph-io/dgraph/x.lastCommitSHA
lastCommitTime = github.com/dgraph-io/dgraph/x.lastCommitTime

BUILD_FLAGS ?= -ldflags '-X ${lastCommitSHA}=${BUILD} -X "${lastCommitTime}=${BUILD_DATE}" -X "${dgraphVersion}=${BUILD_VERSION}" -X ${gitBranch}=${BUILD_BRANCH}'
BUILD_FLAGS ?= -ldflags '-X ${lastCommitSHA}=${BUILD} -X "${lastCommitTime}=${BUILD_DATE}" -X "${dgraphVersion}=${BUILD_VERSION}" -X "${dgraphCodename}=${BUILD_CODENAME}${MODIFIED}" -X ${gitBranch}=${BUILD_BRANCH}'

# Insert build tags if specified
ifneq ($(strip $(BUILD_TAGS)),)
Expand Down
5 changes: 4 additions & 1 deletion x/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var (

// These variables are set using -ldflags
dgraphVersion string
dgraphCodename string
gitBranch string
lastCommitSHA string
lastCommitTime string
Expand Down Expand Up @@ -74,8 +75,10 @@ func BuildDetails() string {
licenseInfo = "Licensed variously under the Apache Public License 2.0 and Dgraph " +
"Community License"
}

return fmt.Sprintf(`
Dgraph version : %v
Dgraph codename : %v
Dgraph SHA-256 : %x
Commit SHA-1 : %v
Commit timestamp : %v
Expand All @@ -90,7 +93,7 @@ To say hi to the community , visit https://dgraph.slack.com.
Copyright 2015-2020 Dgraph Labs, Inc.
`,
dgraphVersion, ExecutableChecksum(), lastCommitSHA, lastCommitTime, gitBranch,
dgraphVersion, dgraphCodename, ExecutableChecksum(), lastCommitSHA, lastCommitTime, gitBranch,
runtime.Version(), licenseInfo)
}

Expand Down
1 change: 1 addition & 0 deletions x/sentry_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func ConfigureSentryScope(subcmd string) {
scope.SetTag("commit", lastCommitSHA)
scope.SetTag("commit_ts", lastCommitTime)
scope.SetTag("branch", gitBranch)
scope.SetTag("codename", dgraphCodename)
scope.SetLevel(sentry.LevelFatal)
})

Expand Down

0 comments on commit d65e205

Please sign in to comment.