Simplify auto-tag functionality for now
ci/woodpecker/push/build_and_release Pipeline was successful Details

This commit is contained in:
Kevin Dorner 2022-09-10 02:34:23 +02:00
parent 8a78141886
commit ce3c29ef57
1 changed files with 9 additions and 21 deletions

View File

@ -58,32 +58,20 @@ if [ -n "${PLUGIN_BUILD_ARGS_FROM_ENV:-}" ]; then
BUILD_ARGS_FROM_ENV=$(echo "${PLUGIN_BUILD_ARGS_FROM_ENV}" | tr ',' '\n' | while read build_arg; do echo "--build-arg ${build_arg}=$(eval "echo \$$build_arg")"; done)
fi
# TODO: Test auto_tag behavior; potential bugs might still be here
# auto_tag, if set auto_tag: true, auto generate .tags file
# support format Major.Minor.Release or start with `v`
# docker tags: Major, Major.Minor, Major.Minor.Release and latest
# Simply auto-tagging
if [[ "${PLUGIN_AUTO_TAG:-}" == "true" ]]; then
TAG=$(echo "${CI_COMMIT_TAG:-}" | sed 's/^v//g')
tag_part_count=$(echo "${TAG}" | tr '.' '\n' | wc -l)
tag_field=${PLUGIN_:-major}
# expect number
echo ${TAG} | grep -E "[a-z-]" &>/dev/null && tag_contains_letter=1 || tag_contains_letter=0
if [[ -n "${PLUGIN_TAG_STRIP_V:-}" ]]; then
TAG=$(echo "${CI_COMMIT_TAG:-}" | sed 's/^v//g')
else
TAG="${CI_COMMIT_TAG}"
fi
if [ ! -n "${TAG:-}" ]; then
echo "latest" > .tags
elif [ ${tag_contains_letter} -eq 1 -o ${tag_part_count} -gt 3 ]; then
echo "${TAG},latest" > .tags
else
major=$(echo "${TAG}" | awk -F'.' '{print $1}')
minor=$(echo "${TAG}" | awk -F'.' '{print $2}')
release=$(echo "${TAG}" | awk -F'.' '{print $3}')
major=${major:-0}
minor=${minor:-0}
release=${release:-0}
echo "${major},${major}.${minor},${major}.${minor}.${release},latest" > .tags
fi
echo "${TAG},latest" > .tags
fi
fi
if [ -n "${PLUGIN_TAGS:-}" ]; then