-
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
01261b1
version is based on git state or BUILD_VERSION
chrisplo b55226e
shfmt build.sh and getGitVersion.sh
chrisplo 9dac643
remove unused netplugin-version artifact
chrisplo 7a91e56
remove duplicate BUILD_VERSION setting
chrisplo 4f4ef53
more comments about target-specific vars
chrisplo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -328,11 +322,8 @@ host-plugin-release: | |
|
||
# build tarball | ||
tar: compile-with-docker | ||
@# $(TAR_FILE) depends on local file netplugin-version (exists in image), | ||
@# but it is evaluated after we have extracted that file to local disk | ||
docker rm netplugin-build || : | ||
c_id=$$(docker create --name netplugin-build netplugin-build:$(NETPLUGIN_CONTAINER_TAG)) && \ | ||
docker cp $${c_id}:/go/src/github.com/contiv/netplugin/netplugin-version ./ && \ | ||
for f in netplugin netmaster netctl contivk8s netcontiv; do \ | ||
docker cp $${c_id}:/go/bin/$$f bin/$$f; done && \ | ||
docker rm $${c_id} | ||
|
@@ -342,11 +333,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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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