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) 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 fi
# TODO: Test auto_tag behavior; potential bugs might still be here # Simply auto-tagging
# 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
if [[ "${PLUGIN_AUTO_TAG:-}" == "true" ]]; then if [[ "${PLUGIN_AUTO_TAG:-}" == "true" ]]; then
TAG=$(echo "${CI_COMMIT_TAG:-}" | sed 's/^v//g')
tag_part_count=$(echo "${TAG}" | tr '.' '\n' | wc -l) if [[ -n "${PLUGIN_TAG_STRIP_V:-}" ]]; then
tag_field=${PLUGIN_:-major} TAG=$(echo "${CI_COMMIT_TAG:-}" | sed 's/^v//g')
# expect number else
echo ${TAG} | grep -E "[a-z-]" &>/dev/null && tag_contains_letter=1 || tag_contains_letter=0 TAG="${CI_COMMIT_TAG}"
fi
if [ ! -n "${TAG:-}" ]; then if [ ! -n "${TAG:-}" ]; then
echo "latest" > .tags echo "latest" > .tags
elif [ ${tag_contains_letter} -eq 1 -o ${tag_part_count} -gt 3 ]; then
echo "${TAG},latest" > .tags
else else
major=$(echo "${TAG}" | awk -F'.' '{print $1}') echo "${TAG},latest" > .tags
minor=$(echo "${TAG}" | awk -F'.' '{print $2}') fi
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
fi fi
if [ -n "${PLUGIN_TAGS:-}" ]; then if [ -n "${PLUGIN_TAGS:-}" ]; then