By default, push images as multiple tags beyond :latest
Push :vX.Y and :vX.Y.Z instead of just :latest
@@ -21,7 +21,12 @@ if [[ -n "${tag}" ]]; then
tag=":${tag}"
fi
else
- tag=":latest"
+ os::build::version::get_vars
+ if [[ "$( git rev-parse --abbrev-ref HEAD )" == "master" ]]; then
+ tag=":latest,:v${OS_GIT_MAJOR}.${OS_GIT_MINOR%+},:v${OS_GIT_MAJOR}.${OS_GIT_MINOR%+}.${OS_GIT_PATCH}"
+ else
+ tag=":v${OS_GIT_MAJOR}.${OS_GIT_MINOR%+},:v${OS_GIT_MAJOR}.${OS_GIT_MINOR%+}.${OS_GIT_PATCH}"
+ fi
fi
# Source tag
@@ -56,16 +61,20 @@ if [[ "${tag}" != ":latest" ]]; then
fi
fi
+IFS=',' read -r -a tags <<< "$tag"
if [[ "${OS_PUSH_BASE_REGISTRY-}" != "" || "${tag}" != "" ]]; then
for image in "${images[@]}"; do
- os::log::info "Tagging ${image}:${source_tag} as ${OS_PUSH_BASE_REGISTRY-}${image}${tag}..."
+ for tag in "${tags[@]}"; do
docker tag "${image}:${source_tag}" "${OS_PUSH_BASE_REGISTRY-}${image}${tag}"
done
+ done
fi
for image in "${images[@]}"; do
+ for tag in "${tags[@]}"; do
os::log::info "Pushing ${OS_PUSH_BASE_REGISTRY-}${image}${tag}..."
docker push ${PUSH_OPTS} "${OS_PUSH_BASE_REGISTRY-}${image}${tag}"
done
+done
ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret"
