Skip to content

Commit 598b5eb

Browse files
committed
Push semver containers during a release build.
1 parent 82a2df3 commit 598b5eb

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

circle.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ jobs:
1212
- run: |
1313
docker login -u $DOCKER_USER -p $DOCKER_PASS
1414
IS_RELEASE=$(if [ "$CIRCLE_TAG" != "" ] ; then echo release; else echo ci; fi;)
15-
/build.sh $IS_RELEASE
15+
/build.sh $IS_RELEASE || exit 1
16+
chmod 755 /src/dockerfile/push_containers.sh
17+
if [ "$CIRCLE_TAG" != "" ] ; then /src/dockerfile/push_containers.sh $CIRCLE_TAG; fi;
1618
1719
- store_artifacts:
1820
path: /src/dist/

dockerfile/push_containers.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
PROGNAME=$(basename $0)
4+
VERSION_BUILD=$1
5+
6+
function error_exit
7+
{
8+
echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
9+
exit 1
10+
}
11+
12+
if [ "$1" = "" ]; then
13+
error_exit "Please provide version as first argument."
14+
fi
15+
16+
SEMVER=${VERSION_BUILD#*v}
17+
VERSION=`echo $SEMVER | awk '{split($0,a,"."); print a[1]}'`
18+
BUILD=`echo $SEMVER | awk '{split($0,a,"."); print a[2]}'`
19+
PATCH=`echo $SEMVER | awk '{split($0,a,"."); print a[3]}'`
20+
21+
if [ "${VERSION}" = "" ]; then
22+
echo "Please provide a semantic version."
23+
exit 1
24+
fi
25+
26+
if [ "${BUILD}" = "" ]; then
27+
BUILD='0'
28+
fi
29+
30+
if [ "${PATCH}" = "" ]; then
31+
PATCH='0'
32+
fi
33+
34+
push_docker() {
35+
echo " -> push $1 $2"
36+
docker tag $1 $2 || exit 1
37+
docker push $2 || exit 1
38+
}
39+
40+
push_all() {
41+
IMAGE_NAME_VERSION=${1}${VERSION}.${BUILD}.${PATCH}
42+
echo "Pulling $IMAGE_NAME_VERSION..."
43+
docker pull ${IMAGE_NAME_VERSION} || exit 1
44+
echo "Pushing $IMAGE_NAME_VERSION..."
45+
push_docker ${IMAGE_NAME_VERSION} ${1}${VERSION}.${BUILD}
46+
push_docker ${IMAGE_NAME_VERSION} ${1}${VERSION}
47+
push_docker ${IMAGE_NAME_VERSION} ${1}latest
48+
}
49+
50+
IMAGE_NAME=v2tec/watchtower
51+
push_all ${IMAGE_NAME}:
52+
push_all ${IMAGE_NAME}:armhf-

0 commit comments

Comments
 (0)