diff --git a/.travis.yml b/.travis.yml index 4cf93ae..f1b6aa6 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..de49018 100755 --- a/deploy.sh +++ b/deploy.sh @@ -14,20 +14,11 @@ 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..e153f57 --- /dev/null +++ b/release.sh @@ -0,0 +1,26 @@ +#!/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 +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