From 06ca5f333c5c060e39488476b0a67d86fcfb9fec Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Date: Mon, 17 Feb 2020 14:38:46 +0100 Subject: [PATCH] Fix travis/ci release process --- .travis.yml | 14 ++++++++++---- scripts/e2e | 2 ++ scripts/kind-e2e/e2e.sh | 2 +- scripts/lib/version | 8 ++++---- scripts/release | 8 ++++++-- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index d5b8f4d03..832fa0d09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ language: go branches: only: - master + - /^v\d+\.\d+\.\d+.*$/ git: depth: 1 @@ -13,7 +14,12 @@ services: script: - make ci e2e status=keep deploy: - provider: script - script: bash scripts/release - on: - branch: master + - provider: script + script: bash scripts/release + on: + branch: master + - provider: script + script: bash scripts/release $TRAVIS_TAG + skip_cleanup: true + on: + tags: true diff --git a/scripts/e2e b/scripts/e2e index 1cb3af390..d6d578796 100755 --- a/scripts/e2e +++ b/scripts/e2e @@ -2,6 +2,8 @@ set -e source $(dirname $0)/lib/debug_functions +source $(dirname $0)/lib/version + cd $(dirname $0) diff --git a/scripts/kind-e2e/e2e.sh b/scripts/kind-e2e/e2e.sh index a35dee5f9..80db945ae 100755 --- a/scripts/kind-e2e/e2e.sh +++ b/scripts/kind-e2e/e2e.sh @@ -91,7 +91,7 @@ function kind_import_images() { docker tag quay.io/submariner/submariner:latest submariner:local docker pull quay.io/submariner/submariner-route-agent:latest docker tag quay.io/submariner/submariner-route-agent:latest submariner-route-agent:local - docker tag quay.io/submariner/submariner-operator:dev submariner-operator:local + docker tag quay.io/submariner/submariner-operator:$VERSION submariner-operator:local if [[ $lighthouse = true ]]; then docker pull quay.io/openshift/kubefed-operator:v0.1.0-rc3 docker pull quay.io/kubernetes-multicluster/kubefed:v0.1.0-rc6 diff --git a/scripts/lib/version b/scripts/lib/version index 783f1616f..30eb4d173 100644 --- a/scripts/lib/version +++ b/scripts/lib/version @@ -8,11 +8,11 @@ if [ -n "$(git status --porcelain --untracked-files=no)" ]; then DIRTY="-dirty" fi -COMMIT=$(git rev-parse --short HEAD) -GIT_TAG=$(git tag -l --contains HEAD | head -n 1) +export COMMIT=$(git rev-parse --short HEAD) +export GIT_TAG=$(git tag -l --contains HEAD | head -n 1) if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then - VERSION=$GIT_TAG + export VERSION=$GIT_TAG else - VERSION="dev" + export VERSION="dev" fi diff --git a/scripts/release b/scripts/release index bd044fdc8..f6303a002 100755 --- a/scripts/release +++ b/scripts/release @@ -2,8 +2,12 @@ set -e source $(dirname $0)/lib/debug_functions +source $(dirname $0)/lib/version + + +DOCKER_TAG=${1:-latest} echo "$QUAY_PASSWORD" | docker login quay.io -u "$QUAY_USERNAME" --password-stdin -docker tag quay.io/submariner/submariner-operator:dev quay.io/submariner/submariner-operator:latest -docker tag quay.io/submariner/submariner-operator:dev quay.io/submariner/submariner-operator:"${TRAVIS_COMMIT:0:7}" +docker tag quay.io/submariner/submariner-operator:$VERSION quay.io/submariner/submariner-operator:${DOCKER_TAG#"v"} +docker tag quay.io/submariner/submariner-operator:$VERSION quay.io/submariner/submariner-operator:"${TRAVIS_COMMIT:0:7}" for i in $(docker images --format "{{.Repository}}:{{.Tag}}" | grep "quay.io/submariner"); do docker push $i; done