Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify version during build #631

Merged
merged 6 commits into from
Oct 11, 2016
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ sudo: false
# 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:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Release 0.13.0 (unreleased)

- Nothing yet

# Release 0.12.3 (2016-10-03)

## Fixed
Expand Down
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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 '/^const Version.*"([^"]+)".*$$/ && print "v$$1\n"' version.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
Expand All @@ -27,7 +29,6 @@ bootstrap-dist:
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}" \
Expand All @@ -44,5 +45,16 @@ dist: build-all
$(DIST_DIRS) zip -r glide-${VERSION}-{}.zip {} \; && \
cd ..


.PHONY: build test install clean bootstrap-dist build-all dist integration-test
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 version.go does not match CHANGELOG.md"; \
echo "version.go: $(VERSION_INCODE)"; \
echo "CHANGELOG : $(VERSION_INCHANGELOG)"; \
exit 1; \
fi

.PHONY: build test install clean bootstrap-dist build-all dist integration-test verify-version
4 changes: 1 addition & 3 deletions glide.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import (
"os"
)

var version = "0.13.0-dev"

const usage = `Vendor Package Management for your Go projects.

Each project should have a 'glide.yaml' file in the project directory. Files
Expand All @@ -60,7 +58,7 @@ func main() {
app := cli.NewApp()
app.Name = "glide"
app.Usage = usage
app.Version = version
app.Version = Version
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "yaml, y",
Expand Down
4 changes: 4 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package main

// Version is the current version of Glide
const Version = "0.13.0-dev"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can unexport this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be useful for exterior libs to be able to get at this, in the case that they use glide as a lib.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to keep the visibility the same as it was previously as part of this change.

However since this is a main package, other's can't import it anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Point taken - I updated to maintain the old api!