migrate images to docker hub (#1966)

* travis: add pushing to docker hub

Signed-off-by: Adnan Abdulhussein <aadnan@vmware.com>

* add comment describing how secrets were generated

Signed-off-by: Adnan Abdulhussein <aadnan@vmware.com>
pull/1968/head
Adnan Abdulhussein 2019-10-16 10:03:23 -07:00 committed by Steve Kriss
parent bedd4b1274
commit b50e0f5a1d
3 changed files with 100 additions and 25 deletions

View File

@ -1,31 +1,23 @@
dist: xenial
language: go
go:
- 1.12.x
- 1.12.x
sudo: required
services:
- docker
- docker
script:
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
- echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$TRAVIS_PULL_REQUEST, BRANCH=$BRANCH"
- hack/ci-check.sh
# gcloud sdk is needed to upload docker images, but we want an updated version
# Do this outside our script so that it's clearly separated in the logs
before_deploy:
- sudo apt-get remove google-cloud-sdk
- if [ ! -d ${HOME}/google-cloud-sdk ]; then curl https://sdk.cloud.google.com | bash
/dev/stdin --disable-prompts; fi
- export PATH=${HOME}/google-cloud-sdk/bin:$PATH && echo "$PATH"
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH;
else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
- echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$TRAVIS_PULL_REQUEST, BRANCH=$BRANCH"
deploy:
- provider: script
skip_cleanup: true
script: hack/gcr-push.sh
on:
repo: vmware-tanzu/velero
all_branches: true
- provider: script
skip_cleanup: true
script: hack/docker-push.sh
on:
repo: vmware-tanzu/velero
all_branches: true
env:
global:
# generated using `travis encrypt`: https://docs.travis-ci.com/user/environment-variables#encrypting-environment-variables
- secure: Sa0R7bhOvrybIWvURjEpOLQ3/v1IqiSM2uwYTSMhLtwHunkiYXpbXi/wVPkujM7kgnFeJzGfNTZI6blkl3Vnz6Ca48avxiv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LmzEC/BhilzCt/jhRuYInpsMBeasGQ6Rg8gjos4AQamdaXJRI520o7zFWXVYqctfPr+mrVOYCfUISnSS3uqb4UlvLBqXDPVWBBIgmPrSgvHXxbjsajFuyWTULm60nj/JUuh7BC9HF9pil3g4/2E9cpLZCFQxVYu6+30eEv4dCO7Ptq3XIINDWbbS6Pmw62/ZsE8ABU=

View File

@ -21,7 +21,7 @@ BIN ?= velero
PKG := github.com/vmware-tanzu/velero
# Where to push the docker image.
REGISTRY ?= gcr.io/heptio-images
REGISTRY ?= velero
# Which architecture to build - see $(ALL_ARCH) for options.
# if the 'local' rule is being run, detect the ARCH from 'go env'

83
hack/docker-push.sh Executable file
View File

@ -0,0 +1,83 @@
#!/bin/bash
# Copyright 2019 the Velero contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# docker-push is invoked by the CI/CD system to deploy docker images to Docker Hub.
# It will build images for all commits to master and all git tags.
# The highest, non-prerelease semantic version will also be given the `latest` tag.
set +x
if [[ -z "$TRAVIS" ]]; then
echo "This script is intended to be run only on Travis." >&2
exit 1
fi
# Return value is written into HIGHEST
HIGHEST=""
function highest_release() {
# Loop through the tags since pre-release versions come before the actual versions.
# Iterate til we find the first non-pre-release
# This is not necessarily the most recently made tag; instead, we want it to be the highest semantic version.
# The most recent tag could potentially be a lower semantic version, made as a point release for a previous series.
# As an example, if v1.3.0 exists and we create v1.2.2, v1.3.0 should still be `latest`.
# `git describe --tags $(git rev-list --tags --max-count=1)` would return the most recently made tag.
for t in $(git tag -l --sort=-v:refname);
do
# If the tag has alpha, beta or rc in it, it's not "latest"
if [[ "$t" == *"beta"* || "$t" == *"alpha"* || "$t" == *"rc"* ]]; then
continue
fi
HIGHEST="$t"
break
done
}
if [[ "$BRANCH" == "master" ]]; then
VERSION="$BRANCH"
elif [[ ! -z "$TRAVIS_TAG" ]]; then
# Tags aren't fetched by Travis on checkout, and we don't need them for master
git fetch --tags
# Calculate the latest release if there's a tag.
highest_release
VERSION="$TRAVIS_TAG"
else
# If we're not on master and we're not building a tag, exit early.
exit 0
fi
# Assume we're not tagging `latest` by default, and never on master.
TAG_LATEST=false
if [[ "$BRANCH" == "master" ]]; then
echo "Building master, not tagging latest."
elif [[ "$TRAVIS_TAG" == "$HIGHEST" ]]; then
TAG_LATEST=true
fi
# Debugging info
echo "Highest tag found: $HIGHEST"
echo "BRANCH: $BRANCH"
echo "TRAVIS_TAG: $TRAVIS_TAG"
echo "TAG_LATEST: $TAG_LATEST"
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
unset GIT_HTTP_USER_AGENT
echo "Building and pushing container images."
VERSION="$VERSION" TAG_LATEST="$TAG_LATEST" make all-containers all-push