mirror of
https://github.com/containers/podman.git
synced 2025-06-17 06:57:43 +08:00
Merge pull request #4379 from cevich/fix_upload_release_archive
Cirrus: Fix upload_release_archive on branch or tag
This commit is contained in:
@ -238,34 +238,46 @@ ircmsg() {
|
|||||||
# there is at least one release tag not having any '-' characters (return 0)
|
# there is at least one release tag not having any '-' characters (return 0)
|
||||||
# or otherwise (return non-0).
|
# or otherwise (return non-0).
|
||||||
is_release() {
|
is_release() {
|
||||||
req_env_var CIRRUS_BASE_SHA CIRRUS_CHANGE_IN_REPO
|
unset RELVER
|
||||||
|
local ret
|
||||||
|
req_env_var CIRRUS_CHANGE_IN_REPO
|
||||||
|
if [[ -n "$CIRRUS_TAG" ]]; then
|
||||||
|
RELVER="$CIRRUS_TAG"
|
||||||
|
elif [[ ! "$CIRRUS_BASE_SHA" =~ "unknown" ]]
|
||||||
|
then
|
||||||
|
# Normally not possible for this to be empty, except when unittesting.
|
||||||
|
req_env_var CIRRUS_BASE_SHA
|
||||||
local range="${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
|
if echo "${range}$CIRRUS_TAG" | grep -iq 'unknown'; then
|
||||||
die 11 "is_release() unusable range ${range} or tag $CIRRUS_TAG"
|
die 11 "is_release() unusable range ${range} or tag $CIRRUS_TAG"
|
||||||
fi
|
fi
|
||||||
# Next easy check, is CIRRUS_TAG set
|
|
||||||
unset RELVER
|
if type -P git &> /dev/null
|
||||||
if [[ -n "$CIRRUS_TAG" ]]; then
|
then
|
||||||
RELVER="$CIRRUS_TAG"
|
|
||||||
else # Lastly, look through the range for tags
|
|
||||||
git fetch --all --tags &> /dev/null|| \
|
git fetch --all --tags &> /dev/null|| \
|
||||||
die 12 "is_release() failed to fetch tags"
|
die 12 "is_release() failed to fetch tags"
|
||||||
RELVER=$(git log --pretty='format:%d' $range | \
|
RELVER=$(git log --pretty='format:%d' $range | \
|
||||||
grep '(tag:' | sed -r -e 's/\s+[(]tag:\s+(v[0-9].*)[)]/\1/' | \
|
grep '(tag:' | sed -r -e 's/\s+[(]tag:\s+(v[0-9].*)[)]/\1/' | \
|
||||||
sort -uV | tail -1)
|
sort -uV | tail -1)
|
||||||
[[ "$?" -eq "0" ]] || \
|
ret=$?
|
||||||
die 13 "is_release() failed to parse tags"
|
else
|
||||||
|
warn -1 "Git command not found while checking for release"
|
||||||
|
ret="-1"
|
||||||
|
fi
|
||||||
|
[[ "$ret" -eq "0" ]] || \
|
||||||
|
die 13 "is_release() failed to parse tags"
|
||||||
|
else # Not testing a PR, but neither CIRRUS_BASE_SHA or CIRRUS_TAG are set
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
echo "Found \$RELVER $RELVER"
|
|
||||||
if [[ -n "$RELVER" ]]; then
|
if [[ -n "$RELVER" ]]; then
|
||||||
|
echo "Found \$RELVER $RELVER"
|
||||||
if echo "$RELVER" | grep -q '-'; then
|
if echo "$RELVER" | grep -q '-'; then
|
||||||
return 2
|
return 2 # development tag
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
return 1
|
return 1 # not a release
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,16 +138,19 @@ function test_is_release() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# FROM TO TAG RET MSG
|
# FROM TO TAG RET MSG
|
||||||
#test_is_release "" "" "" "" ""
|
test_is_release "" "" "" "9" "FATAL: is_release() requires \$CIRRUS_CHANGE_IN_REPO to be non-empty"
|
||||||
|
|
||||||
test_is_release "" "" "" "9" "FATAL: is_release() requires \$CIRRUS_BASE_SHA to be non-empty"
|
|
||||||
test_is_release "x" "" "" "9" "FATAL: is_release() requires \$CIRRUS_CHANGE_IN_REPO to be non-empty"
|
test_is_release "x" "" "" "9" "FATAL: is_release() requires \$CIRRUS_CHANGE_IN_REPO to be non-empty"
|
||||||
|
|
||||||
test_is_release "unknown" "x" "" "11" "is_release() unusable range unknown..x or tag "
|
# post-merge / tag-push testing, FROM will be set 'unknown' by (lib.sh default)
|
||||||
test_is_release "x" "unknown" "" "11" "is_release() unusable range x..unknown or tag "
|
test_is_release "unknown" "x" "" "1" ""
|
||||||
test_is_release "x" "x" "unknown" "11" "is_release() unusable range x..x or tag unknown"
|
# post-merge / tag-push testing, oddball tag is set, FROM will be set 'unknown'
|
||||||
|
test_is_release "unknown" "unknown" "test-tag" "2" "Found \$RELVER test-tag"
|
||||||
|
# post-merge / tag-push testing, sane tag is set, FROM will be set 'unknown'
|
||||||
|
test_is_release "unknown" "unknown" "0.0.0" "0" "Found \$RELVER 0.0.0"
|
||||||
|
# hack/get_ci_vm or PR testing, FROM and TO are set, no tag is set
|
||||||
|
test_is_release "x" "x" "" "1" ""
|
||||||
|
|
||||||
# Negative-testing git with this function is very difficult, assume it works
|
# Negative-testing git with this function is very difficult, assume git works
|
||||||
# test_is_release ... "is_release() failed to fetch tags"
|
# test_is_release ... "is_release() failed to fetch tags"
|
||||||
# test_is_release ... "is_release() failed to parse tags"
|
# test_is_release ... "is_release() failed to parse tags"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user