Browse Source

Introduce semantic versioning.

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
changes/61/161/2
Julius Volz 11 years ago
parent
commit
44390d831d
  1. 17
      Makefile
  2. 6
      Makefile.INCLUDE
  3. 1
      VERSION
  4. 4
      build_info.go

17
Makefile

@ -34,8 +34,19 @@ build: config dependencies model preparation tools web
docker: build docker: build
docker build -t prometheus:$(REV) . docker build -t prometheus:$(REV) .
tarball: build tarball: $(ARCHIVE)
tar -C $(BUILD_PATH)/package -czf prometheus.tar.gz .
$(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): $(BUILD_PATH)/cache/$(GOPKG):
curl -o $@ $(GOURL)/$(GOPKG) curl -o $@ $(GOURL)/$(GOPKG)
@ -101,4 +112,4 @@ update:
web: config dependencies model preparation web: config dependencies model preparation
$(MAKE) -C web $(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
Makefile.INCLUDE

@ -78,12 +78,14 @@ BREW_INSTALL := brew install
# Set WGET_OPTIONS to include ``--no-use-server-timestamps`` to alleviate this. # Set WGET_OPTIONS to include ``--no-use-server-timestamps`` to alleviate this.
WGET := wget $(WGET_OPTIONS) -c WGET := wget $(WGET_OPTIONS) -c
VERSION := $(shell cat VERSION)
REV := $(shell git rev-parse --short HEAD) REV := $(shell git rev-parse --short HEAD)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD) BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
HOSTNAME := $(shell hostname -f) HOSTNAME := $(shell hostname -f)
BUILD_DATE := $(shell date +%Y%m%d-%H:%M:%S) BUILD_DATE := $(shell date +%Y%m%d-%H:%M:%S)
BUILDFLAGS := -ldflags \ BUILDFLAGS := -ldflags \
" -X main.buildVersion $(REV)\ " -X main.buildVersion $(VERSION)\
-X main.buildRevision $(REV)\
-X main.buildBranch $(BRANCH)\ -X main.buildBranch $(BRANCH)\
-X main.buildUser $(USER)@$(HOSTNAME)\ -X main.buildUser $(USER)@$(HOSTNAME)\
-X main.buildDate $(BUILD_DATE)\ -X main.buildDate $(BUILD_DATE)\
@ -93,3 +95,5 @@ BUILDFLAGS := -ldflags \
-X main.snappyVersion $(SNAPPY_VERSION)" -X main.snappyVersion $(SNAPPY_VERSION)"
PROTOC := $(LOCAL_BINARIES)/protoc PROTOC := $(LOCAL_BINARIES)/protoc
ARCHIVE := prometheus-$(VERSION).$(GOOS)-$(GOARCH).tar.gz

1
VERSION

@ -0,0 +1 @@
0.1.0

4
build_info.go

@ -20,6 +20,7 @@ import (
// Build information. Populated by Makefile. // Build information. Populated by Makefile.
var ( var (
buildVersion string buildVersion string
buildRevision string
buildBranch string buildBranch string
buildUser string buildUser string
buildDate string buildDate string
@ -33,6 +34,7 @@ var (
// via go tool ld such that this can be reported on-demand. // via go tool ld such that this can be reported on-demand.
var BuildInfo = map[string]string{ var BuildInfo = map[string]string{
"version": buildVersion, "version": buildVersion,
"revision": buildRevision,
"branch": buildBranch, "branch": buildBranch,
"user": buildUser, "user": buildUser,
"date": buildDate, "date": buildDate,
@ -43,7 +45,7 @@ var BuildInfo = map[string]string{
} }
var versionInfoTmpl = template.Must(template.New("version").Parse( var versionInfoTmpl = template.Must(template.New("version").Parse(
`prometheus, version {{.version}} ({{.branch}}) `prometheus, version {{.version}} (branch: {{.branch}}, revision: {{.revision}})
build user: {{.user}} build user: {{.user}}
build date: {{.date}} build date: {{.date}}
go version: {{.go_version}} go version: {{.go_version}}

Loading…
Cancel
Save