-
Notifications
You must be signed in to change notification settings - Fork 181
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
version is based on git state or BUILD_VERSION #1042
Changes from 1 commit
01261b1
b55226e
9dac643
7a91e56
4f4ef53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# make BUILD_VERSION=1.2.3 [compile-with-docker] will set netplugin -version output | ||
# make BUILD_VERSION=1.2.3 tar will set the tar filename | ||
# default naming will otherwise be value of version/CURRENT_VERSION | ||
# BUILD_VERSION will affect archive filenames as well as -version | ||
# default version will be based on $(git describe --tags --always) | ||
|
||
|
||
.PHONY: all all-CI build clean default unit-test release tar checks go-version gofmt-src \ | ||
|
@@ -14,13 +13,9 @@ TO_BUILD := ./netplugin/ ./netmaster/ ./netctl/netctl/ ./mgmtfn/k8splugin/contiv | |
HOST_GOBIN := `if [ -n "$$(go env GOBIN)" ]; then go env GOBIN; else dirname $$(which go); fi` | ||
HOST_GOROOT := `go env GOROOT` | ||
NAME := netplugin | ||
# We are using date based versioning, so for consistent version during a build | ||
# we evaluate and set the value of version once in a file and use it in 'tar' | ||
# and 'release' targets. | ||
VERSION_FILE := $(NAME)-version | ||
VERSION := `cat $(VERSION_FILE)` | ||
VERSION := $(shell scripts/getGitVersion.sh) | ||
TAR_EXT := tar.bz2 | ||
NETPLUGIN_CONTAINER_TAG := $(shell ./scripts/getGitCommit.sh) | ||
NETPLUGIN_CONTAINER_TAG := $(shell ./scripts/getGitVersion.sh) | ||
TAR_FILENAME := $(NAME)-$(VERSION).$(TAR_EXT) | ||
TAR_LOC := . | ||
TAR_FILE := $(TAR_LOC)/$(TAR_FILENAME) | ||
|
@@ -97,17 +92,16 @@ checks-with-docker: | |
|
||
compile: | ||
cd $(GOPATH)/src/github.com/contiv/netplugin && \ | ||
NIGHTLY_RELEASE=${NIGHTLY_RELEASE} BUILD_VERSION=${BUILD_VERSION} \ | ||
TO_BUILD="${TO_BUILD}" VERSION_FILE=${VERSION_FILE} \ | ||
scripts/build.sh | ||
NIGHTLY_RELEASE=${NIGHTLY_RELEASE} TO_BUILD="${TO_BUILD}" \ | ||
BUILD_VERSION=$(VERSION) scripts/build.sh | ||
|
||
# fully prepares code for pushing to branch, includes building binaries | ||
run-build: deps checks clean compile | ||
|
||
compile-with-docker: | ||
docker build \ | ||
--build-arg NIGHTLY_RELEASE=${NIGHTLY_RELEASE} \ | ||
--build-arg BUILD_VERSION=${BUILD_VERSION} \ | ||
--build-arg NIGHTLY_RELEASE=$(NIGHTLY_RELEASE) \ | ||
--build-arg BUILD_VERSION=$(VERSION) \ | ||
-t netplugin-build:$(NETPLUGIN_CONTAINER_TAG) . | ||
|
||
build-docker-image: start | ||
|
@@ -342,11 +336,12 @@ tar: compile-with-docker | |
|
||
clean-tar: | ||
@rm -f $(TAR_LOC)/*.$(TAR_EXT) | ||
@rm -f ${VERSION_FILE} | ||
|
||
# GITHUB_USER and GITHUB_TOKEN are needed be set to run github-release | ||
release: tar | ||
TAR_FILENAME=$(TAR_FILENAME) TAR_FILE=$(TAR_FILE) \ | ||
OLD_VERSION=${OLD_VERSION} BUILD_VERSION=${BUILD_VERSION} \ | ||
release-built-version: tar | ||
TAR_FILENAME=$(TAR_FILENAME) TAR_FILE=$(TAR_FILE) OLD_VERSION=${OLD_VERSION} \ | ||
NIGHTLY_RELEASE=${NIGHTLY_RELEASE} scripts/release.sh | ||
@make clean-tar | ||
release: export BUILD_VERSION=$(shell cat version/CURRENT_VERSION) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems wrong. There are two release targets. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not a target: |
||
release: | ||
@make release-built-version BUILD_VERSION=$(shell cat version/CURRENT_VERSION) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,28 +2,15 @@ | |
|
||
set -euxo pipefail | ||
|
||
BUILD_TIME=$(date -u +%m-%d-%Y.%H-%M-%S.UTC) | ||
VERSION=$(cat version/CURRENT_VERSION | tr -d '\n') | ||
PKG_NAME=github.com/contiv/netplugin/version | ||
|
||
# BUILD_VERSION overrides the version from CURRENT_VERSION | ||
if [ -n "$BUILD_VERSION" ]; then | ||
VERSION=$BUILD_VERSION | ||
fi | ||
|
||
if [ -z "$NIGHTLY_RELEASE" ]; then | ||
BUILD_VERSION="$VERSION" | ||
else | ||
BUILD_VERSION="$VERSION-$BUILD_TIME" | ||
fi | ||
|
||
GIT_COMMIT=$(./scripts/getGitCommit.sh) | ||
|
||
echo $BUILD_VERSION >$VERSION_FILE | ||
# TODO(chrisplo): remove when contiv/install no longer needs | ||
echo $BUILD_VERSION > netplugin-version | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this new filename for? I don't see it referenced anywhere else There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VERSION was $NAME-version, name was netplugin There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let me double check, but I thought contiv/install uses it still |
||
|
||
PKG_NAME=github.com/contiv/netplugin/version | ||
GOGC=1500 go install -v \ | ||
-ldflags "-X $PKG_NAME.version=$BUILD_VERSION \ | ||
-X $PKG_NAME.buildTime=$BUILD_TIME \ | ||
-X $PKG_NAME.buildTime=$(date -u +%m-%d-%Y.%H-%M-%S.UTC) \ | ||
-X $PKG_NAME.gitCommit=$GIT_COMMIT \ | ||
-s -w" \ | ||
$TO_BUILD |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
BUILD_VERSION=${BUILD_VERSION:-} | ||
NIGHTLY_RELEASE=${NIGHTLY_RELEASE:-} | ||
|
||
# calculate version | ||
if command -v git &>/dev/null && git rev-parse &>/dev/null; then | ||
GIT_COMMIT=$(git describe --tags --always 2>/dev/null || echo unknown) | ||
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then | ||
GIT_COMMIT="$GIT_COMMIT-unsupported" | ||
fi | ||
VERSION=$GIT_COMMIT | ||
else | ||
echo >&2 'error: unable to determine the git revision' | ||
exit 1 | ||
fi | ||
|
||
# BUILD_VERSION overrides the git calculated version | ||
if [ -n "$BUILD_VERSION" ]; then | ||
VERSION=$BUILD_VERSION | ||
fi | ||
|
||
if [ -z "$NIGHTLY_RELEASE" ]; then | ||
VERSION="$VERSION" | ||
else | ||
BUILD_TIME=$(date -u +%m-%d-%Y.%H-%M-%S.UTC) | ||
VERSION="$VERSION-$BUILD_TIME" | ||
fi | ||
|
||
echo $VERSION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this meant to be release-built-version or does it refer to the built version of netplugin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a helper for release target, the release target sets BUILD_VERSION so that version is externally set instead of through scripts/getGitVersion.sh
Though I see I have BUILD_VERSION duplicated in the release target, should be able to remove one, will update