From c84f4b48c03e85ffee2fe2476df4a5b1e3fd91e5 Mon Sep 17 00:00:00 2001 From: Aleksandr Volochnev Date: Wed, 23 Jan 2019 21:29:48 +0100 Subject: [PATCH] #9 Switch to git tag Added retagging. Todo: normalise git tag for docker tag --- scripts/docker-publish.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/docker-publish.sh b/scripts/docker-publish.sh index 3db7647..a436bd4 100755 --- a/scripts/docker-publish.sh +++ b/scripts/docker-publish.sh @@ -1,15 +1,15 @@ #!/bin/bash +set -xu # Print debug output, fail on empty env vars + # This script assumes the following environment variables are present # # DOCKER_USER=username # DOCKER_PASS=somesecretpassword DOCKER_IMAGE=killrvideo/killrvideo-generator -# Allow git describe to fail (which it will if this isn't a tagged commit) -set +e +set +e # Allow git describe to fail (which it will if this isn't a tagged commit) CURRENT_TAG=`git describe --tags --exact-match 2> /dev/null` - set -e # Exit with nonzero exit code if anything fails # Only allow publish for tags @@ -24,8 +24,12 @@ if [[ -z "$DOCKER_USER" ]] || [[ -z "$DOCKER_PASS" ]]; then exit 1 fi +docker tag $DOCKER_IMAGE $CURRENT_TAG + echo "Publishing $DOCKER_IMAGE for git tag $CURRENT_TAG" # Login to Docker and push the image which should have been built +set +x # Suppress credentials output. Travis CI promises to hide them but we should trust no one docker login -u $DOCKER_USER -p $DOCKER_PASS -docker push $DOCKER_IMAGE +set -x # Bring back output +docker push $DOCKER_IMAGE:$CURRENT_TAG