Skip to content

Commit

Permalink
Introduce semantic versioning.
Browse files Browse the repository at this point in the history
This introduces semantic versioning (http://semver.org/) in Prometheus:

- A new VERSION file contains the semantic version string.

- The "tarball" target now includes versioning and build information in
  the tarball name, like: "prometheus-0.1.0.linux-amd64.tar.gz".

- A new "release" target allows scp-ing the versioned tarball to a
  remote machine (file server).

- A new "tag" target allows git-tagging the current revision with the
  version specified in VERSION.

Change-Id: I1f19f38b9b317bfa9eb513754750df5a9c602d94
  • Loading branch information
juliusv committed Mar 11, 2014
1 parent cb9fa1b commit 44390d8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,19 @@ build: config dependencies model preparation tools web
docker: build
docker build -t prometheus:$(REV) .

tarball: build
tar -C $(BUILD_PATH)/package -czf prometheus.tar.gz .
tarball: $(ARCHIVE)

$(ARCHIVE): build
tar -C $(BUILD_PATH)/package -czf $(ARCHIVE) .

release: REMOTE ?= $(error "can't upload, REMOTE not set")
release: REMOTE_DIR ?= $(error "can't upload, REMOTE_DIR not set")
release: $(ARCHIVE)
scp $< $(REMOTE):$(REMOTE_DIR)/

tag:
git tag $(VERSION)
git push --tags

$(BUILD_PATH)/cache/$(GOPKG):
curl -o $@ $(GOURL)/$(GOPKG)
Expand Down Expand Up @@ -101,4 +112,4 @@ update:
web: config dependencies model preparation
$(MAKE) -C web

.PHONY: advice binary build clean config dependencies documentation format model package preparation race_condition_binary race_condition_run run search_index tarball test tools update
.PHONY: advice binary build clean config dependencies documentation format model preparation race_condition_binary race_condition_run release run search_index tag tarball test tools update
6 changes: 5 additions & 1 deletion Makefile.INCLUDE
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ BREW_INSTALL := brew install
# Set WGET_OPTIONS to include ``--no-use-server-timestamps`` to alleviate this.
WGET := wget $(WGET_OPTIONS) -c

VERSION := $(shell cat VERSION)
REV := $(shell git rev-parse --short HEAD)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
HOSTNAME := $(shell hostname -f)
BUILD_DATE := $(shell date +%Y%m%d-%H:%M:%S)
BUILDFLAGS := -ldflags \
" -X main.buildVersion $(REV)\
" -X main.buildVersion $(VERSION)\
-X main.buildRevision $(REV)\
-X main.buildBranch $(BRANCH)\
-X main.buildUser $(USER)@$(HOSTNAME)\
-X main.buildDate $(BUILD_DATE)\
Expand All @@ -93,3 +95,5 @@ BUILDFLAGS := -ldflags \
-X main.snappyVersion $(SNAPPY_VERSION)"

PROTOC := $(LOCAL_BINARIES)/protoc

ARCHIVE := prometheus-$(VERSION).$(GOOS)-$(GOARCH).tar.gz
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
4 changes: 3 additions & 1 deletion build_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
// Build information. Populated by Makefile.
var (
buildVersion string
buildRevision string
buildBranch string
buildUser string
buildDate string
Expand All @@ -33,6 +34,7 @@ var (
// via go tool ld such that this can be reported on-demand.
var BuildInfo = map[string]string{
"version": buildVersion,
"revision": buildRevision,
"branch": buildBranch,
"user": buildUser,
"date": buildDate,
Expand All @@ -43,7 +45,7 @@ var BuildInfo = map[string]string{
}

var versionInfoTmpl = template.Must(template.New("version").Parse(
`prometheus, version {{.version}} ({{.branch}})
`prometheus, version {{.version}} (branch: {{.branch}}, revision: {{.revision}})
build user: {{.user}}
build date: {{.date}}
go version: {{.go_version}}
Expand Down

0 comments on commit 44390d8

Please sign in to comment.