Skip to content

Commit

Permalink
Handle multiple lightweight tabs on a commit (#1858)
Browse files Browse the repository at this point in the history
The GitHub release process creates lightweight tags, which do not have
associated metadata such as date information. This causes git describe
to fall back to lexicographic ordering to break ties between candidate
tags when multiple exist on a given commit.

When building a new RC build to pick up a new RC build of a component,
we wind up with multiple tags on a single commit in vic-product (since
we simply need to do a new build of the same commit to pick up the new
build of the changed component).

When we are performing a tag build, we expect the corresponding tag to
be used— which may not always be the tag that would be selected by git
describe. Ensure we use the expected tag falling back to git describe
only if the $DRONE_TAG variable is not set.

This should preserve the current behavior for non-tag builds (and when
building outside of our CI/CD environment) and enable continued use of
lightweight tags (while we explore the impacts of using annotated tags
on our CI/CD logic).
  • Loading branch information
zjs committed Jun 28, 2018
1 parent 7f14ecf commit 0be2645
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion installer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ GOLINT ?= $(GOPATH)/bin/golint$(BIN_ARCH)

.PHONY: gas ova

LDFLAGS := $(shell BUILD_NUMBER=${BUILD_NUMBER} $(BASE_DIR)/scripts/version-linker-flags.sh)
LDFLAGS := $(shell BUILD_NUMBER=${BUILD_NUMBER} TAG=${TAG} $(BASE_DIR)/scripts/version-linker-flags.sh)

ovfenv := $(BIN)/ovfenv
vic-ova-ui := $(BIN)/vic-ova-ui
Expand Down
6 changes: 4 additions & 2 deletions installer/build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ADMIRAL=""
VICENGINE=""
VIC_MACHINE_SERVER=""
HARBOR=""
TAG=$(git describe --abbrev=0 --tags) # e.g. `v0.9.0`
TAG=${DRONE_TAG:-$(git describe --abbrev=0 --tags)} # e.g. `v0.9.0`
REV=$(git rev-parse --short=8 HEAD)
DRONE_BUILD_NUMBER=${DRONE_BUILD_NUMBER:-0}
BUILD_OVA_REVISION="${TAG}-${DRONE_BUILD_NUMBER}-${REV}"
Expand Down Expand Up @@ -57,6 +57,7 @@ if [ "$step" == "ova-dev" ]; then
-v /var/run/docker.sock:/var/run/docker.sock \
-e DEBUG=${DEBUG} \
-e BUILD_OVA_REVISION=${BUILD_OVA_REVISION} \
-e TAG=${TAG} \
-e BUILD_NUMBER=${BUILD_NUMBER} \
-e DRONE_BUILD_NUMBER=${DRONE_BUILD_NUMBER} \
-e TERM -w ${ROOT_INSTALLER_WORK_DIR} \
Expand All @@ -65,9 +66,10 @@ elif [ "$step" == "ova-ci" ]; then
echo "starting ci build..."
export DEBUG=${DEBUG}
export BUILD_OVA_REVISION=${BUILD_OVA_REVISION}
export TAG=${TAG}
export BUILD_NUMBER=${BUILD_NUMBER}
export DRONE_BUILD_NUMBER=${DRONE_BUILD_NUMBER}
./build/build-ova.sh $*
else
usage
fi
fi
2 changes: 1 addition & 1 deletion installer/scripts/version-linker-flags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#

echo "-s -w \
-X github.com/vmware/vic-product/installer/pkg/version.Version=`git describe --abbrev=0 --tags` \
-X github.com/vmware/vic-product/installer/pkg/version.Version=`${TAG}` \
-X github.com/vmware/vic-product/installer/pkg/version.BuildNumber=\"${BUILD_NUMBER}\" \
-X github.com/vmware/vic-product/installer/pkg/version.BuildDate=`date -u +%Y/%m/%d@%H:%M:%S` \
-X github.com/vmware/vic-product/installer/pkg/version.GitCommit=`git rev-parse --short HEAD` \
Expand Down

0 comments on commit 0be2645

Please sign in to comment.