diff --git a/Makefile b/Makefile index b7f57664..ac6aeef1 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/build/build.sh b/build/build.sh index 5ece23e2..86d68c82 100755 --- a/build/build.sh +++ b/build/build.sh @@ -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 diff --git a/build/release.sh b/build/release.sh deleted file mode 100755 index 32162fe8..00000000 --- a/build/release.sh +++ /dev/null @@ -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} diff --git a/version/VERSION b/version/VERSION deleted file mode 100644 index df47809d..00000000 --- a/version/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.23.6