Add script for pushing container images via Travis

Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
pull/1800/head v1.0.2
Nolan Brubaker 2019-08-23 13:04:52 -04:00
parent 3a0c1be7f0
commit eccaa81af5
1 changed files with 37 additions and 0 deletions

37
hack/gcr-push.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/sh
# Return value is written into LATEST
LATEST=""
function latest_release() {
# Loop through the tags since pre-release versions come before the actual versions.
# Iterate til we find the first non-pre-release
for t in $(git tag -l --sort=-v:refname);
do
# If the tag has alpha, beta or rc in it, it's not "latest"
if [[ "$t" == *"beta"* || "$t" == *"alpha"* || "$t" == *"rc"* ]]; then
continue
fi
LATEST="$t"
break
done
}
# Always publish for master
if [ "$BRANCH" == "master" ]; then
VERSION="$BRANCH" make all-containers all-push
fi
# Publish when TRAVIS_TAG is defined.
if [ ! -z "$TRAVIS_TAG" ]; then
# Calculate the latest release
latest_release
# Default to pre-release
TAG_LATEST=false
if [[ "$TRAVIS_TAG" == "$LATEST" ]]; then
TAG_LATEST=true
fi
VERSION="$TRAVIS_TAG" TAG_LATEST="$TAG_LATEST" make all-containers all-push
fi