From 4cccd57cdd80927d1f09ca95a5d81a780cbc1039 Mon Sep 17 00:00:00 2001 From: Nolan Brubaker Date: Fri, 23 Aug 2019 15:44:32 -0400 Subject: [PATCH] Use Travis's tag env var for latest calculation Signed-off-by: Nolan Brubaker --- hack/gcr-push.sh | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/hack/gcr-push.sh b/hack/gcr-push.sh index 94167ecd0..d0c3aef64 100755 --- a/hack/gcr-push.sh +++ b/hack/gcr-push.sh @@ -1,22 +1,16 @@ #!/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 +LATEST=false +function is_latest_release() { + # If the tag has alpha, beta or rc in it, it's not "latest" + if [[ "$TRAVIS_TAG" == *"beta"* || "$TRAVIS_TAG" == *"alpha"* || "$TRAVIS_TAG" == *"rc"* ]]; then + LATEST=false + else + LATEST=true + fi } - # Always publish for master if [ "$BRANCH" == "master" ]; then VERSION="$BRANCH" make all-containers all-push @@ -24,14 +18,8 @@ fi # Publish when TRAVIS_TAG is defined. if [ ! -z "$TRAVIS_TAG" ]; then - # Calculate the latest release - latest_release + # Check if this is the latest release. + is_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 + VERSION="$TRAVIS_TAG" TAG_LATEST="$LATEST" make all-containers all-push fi