Use Travis's tag env var for latest calculation

Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
This commit is contained in:
Nolan Brubaker
2019-08-23 15:44:32 -04:00
parent eccaa81af5
commit 4cccd57cdd
+11 -23
View File
@@ -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