From ce3c29ef57373dd458fb34f3b8c01937fdfb81f4 Mon Sep 17 00:00:00 2001 From: Kevin Dorner Date: Sat, 10 Sep 2022 02:34:23 +0200 Subject: [PATCH] Simplify auto-tag functionality for now --- plugin.sh | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/plugin.sh b/plugin.sh index bc746de..50c34b5 100755 --- a/plugin.sh +++ b/plugin.sh @@ -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