Simplify cAdvisor release versioning

- Eliminate version/VERSION in favor of parsing git versions
- Enforce that releases are built against tagged versions
- Delete the broken release script, change `make release` to build the release
This commit is contained in:
Tim St. Clair 2016-06-27 17:34:33 -07:00
parent 51574ec04f
commit 151d4912dc
4 changed files with 13 additions and 28 deletions

View File

@ -36,10 +36,11 @@ build:
@./build/assets.sh
@./build/build.sh
release: build
@./build/release.sh
release:
@echo ">> building release binaries"
@RELEASE=true ./build/build.sh
docker:
@docker build -t cadvisor:$(shell git rev-parse --short HEAD) -f deploy/Dockerfile .
.PHONY: all format build test vet docker
.PHONY: all build docker format release test vet

View File

@ -20,7 +20,7 @@ RELEASE=${RELEASE:-false} # Whether to build for an official release.
repo_path="github.com/google/cadvisor"
version=$( cat version/VERSION )
version=$( git describe --tags --abbrev=14 HEAD | sed -E 's/-([0-9]+)-g([0-9a-f]+)/.\1+\2/' )
revision=$( git rev-parse --short HEAD 2> /dev/null || echo 'unknown' )
branch=$( git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'unknown' )
build_user="${USER}@${HOSTNAME}"
@ -30,6 +30,14 @@ go_version=$( go version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/' )
GO_CMD="install"
if [ "$RELEASE" == "true" ]; then
# Only allow releases of tagged versions.
TAGGED='^v[0-9]+\.[0-9]+\.[0-9]+$'
if [[ ! "$version" =~ $TAGGED ]]; then
echo "Only tagged versions are allowed for releases" >&2
echo "Found: $version" >&2
exit 1
fi
# Don't include hostname with release builds
build_user="$(git config --get user.email)"
build_date=$( date +%Y%m%d ) # Release date is only to day-granularity

View File

@ -1,23 +0,0 @@
#!/bin/bash
# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
version=$( cat version/VERSION )
branch=$( git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'unknown' )
rm -rf release && mkdir release
cp cadvisor release/cadvisor
go get -u github.com/progrium/gh-release
gh-release create google/cadvisor ${version} ${branch} ${version}

View File

@ -1 +0,0 @@
0.23.6