Merge pull request #631 from breerly/verify-version
Verify version during build
diff --git a/.travis.yml b/.travis.yml
index 0078c9c..8b4daa9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,7 +18,7 @@
# in the vendor directory. We don't need to test all dependent packages.
# Only testing this project.
script:
- - GO15VENDOREXPERIMENT=1 make test integration-test
+ - GO15VENDOREXPERIMENT=1 make test integration-test verify-version
notifications:
webhooks:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b5bbb29..2acae4d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# Release 0.13.0 (unreleased)
+
+- Nothing yet
+
# Release 0.12.3 (2016-10-03)
## Fixed
diff --git a/Makefile b/Makefile
index a71b9db..946edfe 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,8 @@
GLIDE_GO_EXECUTABLE ?= go
-VERSION := $(shell git describe --tags)
DIST_DIRS := find * -type d -exec
+VERSION := $(shell git describe --tags)
+VERSION_INCODE = $(shell perl -ne '/^var version.*"([^"]+)".*$$/ && print "v$$1\n"' glide.go)
+VERSION_INCHANGELOG = $(shell perl -ne '/^\# Release (\d+(\.\d+)+) / && print "$$1\n"' CHANGELOG.md | head -n1)
build:
${GLIDE_GO_EXECUTABLE} build -o glide -ldflags "-X main.version=${VERSION}" glide.go
@@ -27,7 +29,6 @@
cd ${GOPATH}/src/github.com/franciscocpg/gox && git checkout dc50315fc7992f4fa34a4ee4bb3d60052eeb038e
cd ${GOPATH}/src/github.com/franciscocpg/gox && ${GLIDE_GO_EXECUTABLE} install
-
build-all:
gox -verbose \
-ldflags "-X main.version=${VERSION}" \
@@ -44,5 +45,16 @@
$(DIST_DIRS) zip -r glide-${VERSION}-{}.zip {} \; && \
cd ..
+verify-version:
+ @if [ "$(VERSION_INCODE)" = "v$(VERSION_INCHANGELOG)" ]; then \
+ echo "glide: $(VERSION_INCHANGELOG)"; \
+ elif [ "$(VERSION_INCODE)" = "v$(VERSION_INCHANGELOG)-dev" ]; then \
+ echo "glide (development): $(VERSION_INCHANGELOG)"; \
+ else \
+ echo "Version number in glide.go does not match CHANGELOG.md"; \
+ echo "glide.go: $(VERSION_INCODE)"; \
+ echo "CHANGELOG : $(VERSION_INCHANGELOG)"; \
+ exit 1; \
+ fi
-.PHONY: build test install clean bootstrap-dist build-all dist integration-test
+.PHONY: build test install clean bootstrap-dist build-all dist integration-test verify-version