fix: DRONE_TAG default value. wip https://github.com/banzaicloud/drone-kaniko/issues/15
This commit is contained in:
parent
1379e9d724
commit
0712ed76e9
20
plugin.sh
20
plugin.sh
@ -51,16 +51,18 @@ if [ -n "${PLUGIN_BUILD_ARGS_FROM_ENV:-}" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# auto_tag, if set auto_tag: true, auto generate .tags file
|
# 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
|
||||||
# only support va.b.c and a.b.c
|
TAG=$(echo "${DRONE_TAG:-}" |sed 's/^v//g')
|
||||||
TAG=$(echo "${DRONE_TAG}" |sed 's/^v//g')
|
part=$(echo "${TAG}" |tr '.' '\n' |wc -l)
|
||||||
l=$(echo "${TAG}" |tr '.' '\n' |wc -l)
|
# expect number
|
||||||
echo ${TAG} |grep -E "[a-z-]" &>/dev/null && r=0 || r=1
|
echo ${TAG} |grep -E "[a-z-]" &>/dev/null && isNum=1 || isNum=0
|
||||||
|
|
||||||
if [ ! -n "${TAG:-}" ];then
|
if [ ! -n "${TAG:-}" ];then
|
||||||
echo "latest" > .tags
|
echo "latest" > .tags
|
||||||
elif [ ${r} -eq 0 -o ${l} -gt 3 ];then
|
elif [ ${isNum} -eq 1 -o ${part} -gt 3 ];then
|
||||||
echo "v${TAG},latest" > .tags
|
echo "${TAG},latest" > .tags
|
||||||
else
|
else
|
||||||
major=$(echo "${TAG}" |awk -F'.' '{print $1}')
|
major=$(echo "${TAG}" |awk -F'.' '{print $1}')
|
||||||
minor=$(echo "${TAG}" |awk -F'.' '{print $2}')
|
minor=$(echo "${TAG}" |awk -F'.' '{print $2}')
|
||||||
@ -70,7 +72,7 @@ if [[ "${PLUGIN_AUTO_TAG:-}" == "true" ]]; then
|
|||||||
minor=${minor:-0}
|
minor=${minor:-0}
|
||||||
release=${release:-0}
|
release=${release:-0}
|
||||||
|
|
||||||
echo "v${major},v${major}.${minor},v${major}.${minor}.${release},latest" > .tags
|
echo "${major},${major}.${minor},${major}.${minor}.${release},latest" > .tags
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user