Add post_push hooks to tag with redis version

Signed-off-by: Qi Zheng <qi.zheng@intel.com>
This commit is contained in:
Qi Zheng
2019-11-11 17:15:24 -08:00
committed by William Douglas
parent cff5e52231
commit 7e62245281
2 changed files with 57 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash
CLR_URL="https://cdn.download.clearlinux.org/releases"
# Return tag value or NULL if not found
function get_tag {
pkg=$1
clr_ver=`docker run --rm clearlinux/os-core cat /usr/lib/os-release | grep VERSION_ID`
clr_ver=${clr_ver##*=}
src_url="$CLR_URL/$clr_ver/clear/source/package-sources"
matches=$(curl $src_url 2>/dev/null | grep $pkg)
# no matches, return NULL tag
if [ -z "$matches" ]; then
echo ""
echo "no $pkg found on the release $clr_ver"
exit 0
fi
matches=($matches)
for((j=0;j<${#matches[@]};j++))
do
if [ ${matches[j]} == $pkg ]; then
ver=${matches[j+1]}
fi
done
echo "$ver"
}
function get_tags_in_docker {
img=$1
tag_url="https://registry.hub.docker.com/v2/repositories/$img/tags/"
tags=$(curl $tag_url 2>/dev/null | docker run -i stedolan/jq '."results"[]["name"]')
echo $tags
}
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
echo "=> Tagging the image"
set -e
. ../docker-hooks.sh
image="clearlinux/redis"
tag=$(get_tag redis-native)
if [ -z "$tag" ]; then
echo "no $pkg found on the release $clr_ver"
else
docker tag $image:latest $image:$tag
docker push $image:$tag
major_tag=${tag%%.*}
docker tag $image:latest $image:$major_tag
docker push $image:$major_tag
fi