Streamline release process
This commit is contained in:
parent
c52cb944ad
commit
6ce987b702
2
Makefile
2
Makefile
@ -41,7 +41,7 @@ assets:
|
|||||||
|
|
||||||
release:
|
release:
|
||||||
@echo ">> building release binaries"
|
@echo ">> building release binaries"
|
||||||
@RELEASE=true ./build/build.sh
|
@./build/release.sh
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
@docker build -t cadvisor:$(shell git rev-parse --short HEAD) -f deploy/Dockerfile .
|
@docker build -t cadvisor:$(shell git rev-parse --short HEAD) -f deploy/Dockerfile .
|
||||||
|
@ -16,40 +16,19 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
RELEASE=${RELEASE:-false} # Whether to build for an official release.
|
|
||||||
GO_FLAGS=${GO_FLAGS:-} # Extra go flags to use in the build.
|
GO_FLAGS=${GO_FLAGS:-} # Extra go flags to use in the build.
|
||||||
|
GO_CMD=${GO_CMD:-"install"}
|
||||||
|
BUILD_USER=${BUILD_USER:-"${USER}@${HOSTNAME}"}
|
||||||
|
BUILD_DATE=${BUILD_DATE:-$( date +%Y%m%d-%H:%M:%S )}
|
||||||
|
VERBOSE=${VERBOSE:-}
|
||||||
|
|
||||||
repo_path="github.com/google/cadvisor"
|
repo_path="github.com/google/cadvisor"
|
||||||
|
|
||||||
version=$( git describe --tags --dirty --abbrev=14 | sed -E 's/-([0-9]+)-g/.\1+/' )
|
version=$( git describe --tags --dirty --abbrev=14 | sed -E 's/-([0-9]+)-g/.\1+/' )
|
||||||
revision=$( git rev-parse --short HEAD 2> /dev/null || echo 'unknown' )
|
revision=$( git rev-parse --short HEAD 2> /dev/null || echo 'unknown' )
|
||||||
branch=$( git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'unknown' )
|
branch=$( git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'unknown' )
|
||||||
build_user="${USER}@${HOSTNAME}"
|
|
||||||
build_date=$( date +%Y%m%d-%H:%M:%S )
|
|
||||||
go_version=$( go version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/' )
|
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]+(-(alpha|beta)[0-9]*)?$'
|
|
||||||
if [[ ! "$version" =~ $TAGGED ]]; then
|
|
||||||
echo "Error: Only tagged versions are allowed for releases" >&2
|
|
||||||
echo "Found: $version" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Don't include hostname with release builds
|
|
||||||
if ! build_user="$(git config --get user.email)"; then
|
|
||||||
echo "Error: git user not set, use:"
|
|
||||||
echo "git config user.email <email>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
build_date=$( date +%Y%m%d ) # Release date is only to day-granularity
|
|
||||||
|
|
||||||
# Don't use cached build objects for releases.
|
|
||||||
GO_CMD="build"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# go 1.4 requires ldflags format to be "-X key value", not "-X key=value"
|
# go 1.4 requires ldflags format to be "-X key value", not "-X key=value"
|
||||||
ldseparator="="
|
ldseparator="="
|
||||||
@ -62,14 +41,14 @@ ldflags="
|
|||||||
-X ${repo_path}/version.Version${ldseparator}${version}
|
-X ${repo_path}/version.Version${ldseparator}${version}
|
||||||
-X ${repo_path}/version.Revision${ldseparator}${revision}
|
-X ${repo_path}/version.Revision${ldseparator}${revision}
|
||||||
-X ${repo_path}/version.Branch${ldseparator}${branch}
|
-X ${repo_path}/version.Branch${ldseparator}${branch}
|
||||||
-X ${repo_path}/version.BuildUser${ldseparator}${build_user}
|
-X ${repo_path}/version.BuildUser${ldseparator}${BUILD_USER}
|
||||||
-X ${repo_path}/version.BuildDate${ldseparator}${build_date}
|
-X ${repo_path}/version.BuildDate${ldseparator}${BUILD_DATE}
|
||||||
-X ${repo_path}/version.GoVersion${ldseparator}${go_version}"
|
-X ${repo_path}/version.GoVersion${ldseparator}${go_version}"
|
||||||
|
|
||||||
echo ">> building cadvisor"
|
echo ">> building cadvisor"
|
||||||
|
|
||||||
if [ "$RELEASE" == "true" ]; then
|
if [ -n "$VERBOSE" ]; then
|
||||||
echo "Building release candidate with -ldflags $ldflags"
|
echo "Building with -ldflags $ldflags"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
GOBIN=$PWD go "$GO_CMD" ${GO_FLAGS} -ldflags "${ldflags}" "${repo_path}"
|
GOBIN=$PWD go "$GO_CMD" ${GO_FLAGS} -ldflags "${ldflags}" "${repo_path}"
|
||||||
|
56
build/release.sh
Executable file
56
build/release.sh
Executable file
@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env 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.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
VERSION=$( git describe --tags --dirty --abbrev=14 | sed -E 's/-([0-9]+)-g/.\1+/' )
|
||||||
|
# Only allow releases of tagged versions.
|
||||||
|
TAGGED='^v[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta)[0-9]*)?$'
|
||||||
|
if [[ ! "$VERSION" =~ $TAGGED ]]; then
|
||||||
|
echo "Error: Only tagged versions are allowed for releases" >&2
|
||||||
|
echo "Found: $VERSION" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Don't include hostname with release builds
|
||||||
|
if ! git_user="$(git config --get user.email)"; then
|
||||||
|
echo "Error: git user not set, use:"
|
||||||
|
echo "git config user.email <email>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build the release.
|
||||||
|
export BUILD_USER="$git_user"
|
||||||
|
export BUILD_DATE=$( date +%Y%m%d ) # Release date is only to day-granularity
|
||||||
|
export GO_CMD="build" # Don't use cached build objects for releases.
|
||||||
|
export VERBOSE=true
|
||||||
|
build/build.sh
|
||||||
|
|
||||||
|
# Build the docker image
|
||||||
|
echo ">> building cadvisor docker image"
|
||||||
|
docker_tag="google/cadvisor:$VERSION"
|
||||||
|
gcr_tag="gcr.io/google_containers/cadvisor:$VERSION"
|
||||||
|
docker build -t $docker_tag -t $gcr_tag -f deploy/Dockerfile .
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Release info:"
|
||||||
|
echo "VERSION=$VERSION"
|
||||||
|
sha1sum --tag cadvisor
|
||||||
|
md5sum --tag cadvisor
|
||||||
|
echo "docker image: $docker_tag"
|
||||||
|
echo "gcr.io image: $gcr_tag"
|
||||||
|
|
||||||
|
exit 0
|
@ -47,28 +47,11 @@ Command: `make release`
|
|||||||
- Try to build it from the release branch, since we include that in the binary version
|
- Try to build it from the release branch, since we include that in the binary version
|
||||||
- Verify the ldflags output, in particular check the Version, BuildUser, and GoVersion are expected
|
- Verify the ldflags output, in particular check the Version, BuildUser, and GoVersion are expected
|
||||||
|
|
||||||
Once the build is complete, record the sh1 and md5 hashes:
|
Once the build is complete, check the VERSION and note the sha1 and md5 hashes.
|
||||||
|
|
||||||
```
|
## 4. Push the Docker images
|
||||||
$ sha1sum cadvisor
|
|
||||||
$ md5sum cadvisor
|
|
||||||
```
|
|
||||||
|
|
||||||
Update the github release by uploading the release binary, and filling in the hashes.
|
|
||||||
|
|
||||||
## 4. Build & push the Docker images
|
|
||||||
|
|
||||||
```
|
|
||||||
$ VERSION=v0.23.1 # Example
|
|
||||||
$ docker build -t google/cadvisor:$VERSION -f deploy/Dockerfile .
|
|
||||||
...
|
|
||||||
Successfully built a811aa33809f
|
|
||||||
$ docker tag google/cadvisor:$VERSION \
|
|
||||||
gcr.io/google_containers/cadvisor:$VERSION
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4.a Push to Docker Hub
|
|
||||||
|
|
||||||
|
Docker Hub:
|
||||||
```
|
```
|
||||||
$ docker login
|
$ docker login
|
||||||
Username: ****
|
Username: ****
|
||||||
@ -77,7 +60,7 @@ $ docker push google/cadvisor:$VERSION
|
|||||||
$ docker logout # Good practice with shared account
|
$ docker logout # Good practice with shared account
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4.b Push to Google Container Registry
|
Google Container Registry:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ gcloud auth login <account>
|
$ gcloud auth login <account>
|
||||||
@ -100,6 +83,7 @@ Go to https://github.com/google/cadvisor/releases and click "Draft a new release
|
|||||||
- Body should start with release notes (from CHANGELOG.md)
|
- Body should start with release notes (from CHANGELOG.md)
|
||||||
- Next is the Docker image: `google/cadvisor:$VERSION`
|
- Next is the Docker image: `google/cadvisor:$VERSION`
|
||||||
- Next are the binary hashes (from step 3)
|
- Next are the binary hashes (from step 3)
|
||||||
|
- Upload the binary build in step 3
|
||||||
- If this is an alpha or beta release, mark the release as a "pre-release"
|
- If this is an alpha or beta release, mark the release as a "pre-release"
|
||||||
- Click publish when done
|
- Click publish when done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user