summaryrefslogtreecommitdiff
path: root/contrib/cirrus/lib.sh
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-10-29 20:48:09 +0100
committerGitHub <noreply@github.com>2019-10-29 20:48:09 +0100
commit5918f3a5f1d11862fbaaca94ff25f1d9cc1309e2 (patch)
tree1a7130979d09ae282420103426d16bc62a0914a2 /contrib/cirrus/lib.sh
parent6c6e78374f5be949d11a8608080c96e2d22ca872 (diff)
parent8303eb30377a41879c982b62b53cc549c60b74c0 (diff)
downloadpodman-5918f3a5f1d11862fbaaca94ff25f1d9cc1309e2.tar.gz
podman-5918f3a5f1d11862fbaaca94ff25f1d9cc1309e2.tar.bz2
podman-5918f3a5f1d11862fbaaca94ff25f1d9cc1309e2.zip
Merge pull request #4319 from cevich/limit_releases
Cirrus: Only upload tagged releases
Diffstat (limited to 'contrib/cirrus/lib.sh')
-rw-r--r--contrib/cirrus/lib.sh38
1 files changed, 37 insertions, 1 deletions
diff --git a/contrib/cirrus/lib.sh b/contrib/cirrus/lib.sh
index 8a7d3c1a3..051157702 100644
--- a/contrib/cirrus/lib.sh
+++ b/contrib/cirrus/lib.sh
@@ -43,7 +43,7 @@ if type -P git &> /dev/null && [[ -d "$GOSRC/.git" ]]
then
CIRRUS_CHANGE_IN_REPO=${CIRRUS_CHANGE_IN_REPO:-$(git show-ref --hash=8 HEAD || date +%s)}
else # pick something unique and obviously not from Cirrus
- CIRRUS_CHANGE_IN_REPO=${CIRRUS_CHANGE_IN_REPO:-no_git_$(date +%s)}
+ CIRRUS_CHANGE_IN_REPO=${CIRRUS_CHANGE_IN_REPO:-unknown_$(date +%s)}
fi
# Defaults when not running under CI
@@ -233,6 +233,42 @@ ircmsg() {
set -e
}
+# This covers all possible human & CI workflow parallel & serial combinations
+# where at least one caller must definitively discover if within a commit range
+# there is at least one release tag not having any '-' characters (return 0)
+# or otherwise (return non-0).
+is_release() {
+ req_env_var CIRRUS_BASE_SHA CIRRUS_CHANGE_IN_REPO
+ local range="${CIRRUS_BASE_SHA}..${CIRRUS_CHANGE_IN_REPO}"
+ # Easy check first, default non-useful values
+ if echo "${range}$CIRRUS_TAG" | grep -iq 'unknown'; then
+ die 11 "is_release() unusable range ${range} or tag $CIRRUS_TAG"
+ fi
+ # Next easy check, is CIRRUS_TAG set
+ unset RELVER
+ if [[ -n "$CIRRUS_TAG" ]]; then
+ RELVER="$CIRRUS_TAG"
+ else # Lastly, look through the range for tags
+ git fetch --all --tags &> /dev/null|| \
+ die 12 "is_release() failed to fetch tags"
+ RELVER=$(git log --pretty='format:%d' $range | \
+ grep '(tag:' | sed -r -e 's/\s+[(]tag:\s+(v[0-9].*)[)]/\1/' | \
+ sort -uV | tail -1)
+ [[ "$?" -eq "0" ]] || \
+ die 13 "is_release() failed to parse tags"
+ fi
+ echo "Found \$RELVER $RELVER"
+ if [[ -n "$RELVER" ]]; then
+ if echo "$RELVER" | grep -q '-'; then
+ return 2
+ else
+ return 0
+ fi
+ else
+ return 1
+ fi
+}
+
setup_rootless() {
req_env_var ROOTLESS_USER GOSRC SECRET_ENV_RE ROOTLESS_ENV_RE