From c8f12bd58959f42081b7650421e5bffea7d69357 Mon Sep 17 00:00:00 2001 From: Jakub Bartel Date: Thu, 8 Mar 2018 10:34:07 +0100 Subject: [PATCH 1/4] Travis script updated to use release and deploy phases --- .travis.yml | 2 ++ deploy.sh | 22 +++++----------------- release.sh | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 17 deletions(-) create mode 100755 release.sh diff --git a/.travis.yml b/.travis.yml index 4cf93ae..16904c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ script: after_success: - docker images + - ./release.sh deploy: provider: script @@ -19,3 +20,4 @@ deploy: script: ./deploy.sh on: tags: true + condition: "$TRAVIS_TAG =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$" diff --git a/deploy.sh b/deploy.sh index f6c30ee..327f00f 100755 --- a/deploy.sh +++ b/deploy.sh @@ -14,20 +14,8 @@ eval $(docker run --rm \ quay.io/keboola/developer-portal-cli-v2:latest \ ecr:get-login ${KBC_DEVELOPERPORTAL_VENDOR} ${KBC_DEVELOPERPORTAL_APP}) -# Push to the repository -docker tag ${APP_IMAGE}:latest ${REPOSITORY}:${TRAVIS_TAG} -docker tag ${APP_IMAGE}:latest ${REPOSITORY}:latest -docker push ${REPOSITORY}:${TRAVIS_TAG} -docker push ${REPOSITORY}:latest - -# Update the tag in Keboola Developer Portal -> Deploy to KBC -if echo ${TRAVIS_TAG} | grep -c '^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$' -then - docker run --rm \ - -e KBC_DEVELOPERPORTAL_USERNAME \ - -e KBC_DEVELOPERPORTAL_PASSWORD \ - quay.io/keboola/developer-portal-cli-v2:latest \ - update-app-repository ${KBC_DEVELOPERPORTAL_VENDOR} ${KBC_DEVELOPERPORTAL_APP} ${TRAVIS_TAG} ecr ${REPOSITORY} -else - echo "Skipping deployment to KBC, tag ${TRAVIS_TAG} is not allowed." -fi +docker run --rm \ + -e KBC_DEVELOPERPORTAL_USERNAME \ + -e KBC_DEVELOPERPORTAL_PASSWORD \ + quay.io/keboola/developer-portal-cli-v2:latest \ + update-app-repository ${KBC_DEVELOPERPORTAL_VENDOR} ${KBC_DEVELOPERPORTAL_APP} ${TRAVIS_TAG} ecr ${REPOSITORY} diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..b772057 --- /dev/null +++ b/release.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +# Obtain the component repository and log in +docker pull quay.io/keboola/developer-portal-cli-v2:latest +export REPOSITORY=`docker run --rm \ + -e KBC_DEVELOPERPORTAL_USERNAME \ + -e KBC_DEVELOPERPORTAL_PASSWORD \ + quay.io/keboola/developer-portal-cli-v2:latest \ + ecr:get-repository ${KBC_DEVELOPERPORTAL_VENDOR} ${KBC_DEVELOPERPORTAL_APP}` +eval $(docker run --rm \ + -e KBC_DEVELOPERPORTAL_USERNAME \ + -e KBC_DEVELOPERPORTAL_PASSWORD \ + quay.io/keboola/developer-portal-cli-v2:latest \ + ecr:get-login ${KBC_DEVELOPERPORTAL_VENDOR} ${KBC_DEVELOPERPORTAL_APP}) + +# Push to the repository +docker tag ${APP_IMAGE}:latest ${REPOSITORY}:${TRAVIS_TAG} +docker tag ${APP_IMAGE}:latest ${REPOSITORY}:latest +docker push ${REPOSITORY}:${TRAVIS_TAG} +docker push ${REPOSITORY}:latest From 77a581fe23fbd3d4cd3a29dec2482f34928a93e5 Mon Sep 17 00:00:00 2001 From: Jakub Bartel Date: Thu, 8 Mar 2018 10:57:34 +0100 Subject: [PATCH 2/4] Fix quoted condition --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 16904c0..f1b6aa6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,4 +20,4 @@ deploy: script: ./deploy.sh on: tags: true - condition: "$TRAVIS_TAG =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$" + condition: $TRAVIS_TAG =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ From 946ca509b3fd0e0eaae256a20bad405ac537e826 Mon Sep 17 00:00:00 2001 From: Jakub Bartel Date: Thu, 8 Mar 2018 11:35:34 +0100 Subject: [PATCH 3/4] Release branch images, push latest tag only on deployment --- deploy.sh | 3 +++ release.sh | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/deploy.sh b/deploy.sh index 327f00f..de49018 100755 --- a/deploy.sh +++ b/deploy.sh @@ -14,6 +14,9 @@ eval $(docker run --rm \ quay.io/keboola/developer-portal-cli-v2:latest \ ecr:get-login ${KBC_DEVELOPERPORTAL_VENDOR} ${KBC_DEVELOPERPORTAL_APP}) +docker tag ${APP_IMAGE}:latest ${REPOSITORY}:latest +docker push ${REPOSITORY}:latest + docker run --rm \ -e KBC_DEVELOPERPORTAL_USERNAME \ -e KBC_DEVELOPERPORTAL_PASSWORD \ diff --git a/release.sh b/release.sh index b772057..b3dbd23 100755 --- a/release.sh +++ b/release.sh @@ -15,7 +15,12 @@ eval $(docker run --rm \ ecr:get-login ${KBC_DEVELOPERPORTAL_VENDOR} ${KBC_DEVELOPERPORTAL_APP}) # Push to the repository -docker tag ${APP_IMAGE}:latest ${REPOSITORY}:${TRAVIS_TAG} -docker tag ${APP_IMAGE}:latest ${REPOSITORY}:latest -docker push ${REPOSITORY}:${TRAVIS_TAG} -docker push ${REPOSITORY}:latest +if [[ ${TRAVIS_TAG} != "" ]] +then + docker tag ${APP_IMAGE}:latest ${REPOSITORY}:${TRAVIS_TAG} + docker push ${REPOSITORY}:${TRAVIS_TAG} +elif [[ ${TRAVIS_PULL_REQUEST} != "false" && ${TRAVIS_BRANCH} != "" ]] +then + docker tag ${APP_IMAGE}:latest ${REPOSITORY}:${TRAVIS_BRANCH} + docker push ${REPOSITORY}:${TRAVIS_BRANCH} +fi From 9eea39828024bd9061d68163c49a12313d7e42ac Mon Sep 17 00:00:00 2001 From: Jakub Bartel Date: Thu, 8 Mar 2018 11:48:25 +0100 Subject: [PATCH 4/4] Fix push condition --- release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.sh b/release.sh index b3dbd23..e153f57 100755 --- a/release.sh +++ b/release.sh @@ -19,7 +19,7 @@ if [[ ${TRAVIS_TAG} != "" ]] then docker tag ${APP_IMAGE}:latest ${REPOSITORY}:${TRAVIS_TAG} docker push ${REPOSITORY}:${TRAVIS_TAG} -elif [[ ${TRAVIS_PULL_REQUEST} != "false" && ${TRAVIS_BRANCH} != "" ]] +elif [[ ${TRAVIS_PULL_REQUEST} == "false" && ${TRAVIS_BRANCH} != "" ]] then docker tag ${APP_IMAGE}:latest ${REPOSITORY}:${TRAVIS_BRANCH} docker push ${REPOSITORY}:${TRAVIS_BRANCH}