hack/push-release.sh
e3bb13a1
 #!/bin/bash
 
 # This script pushes all of the built images to a registry.
 #
 # Set OS_PUSH_BASE_IMAGES=true to push base images
 # Set OS_PUSH_BASE_REGISTRY to prefix the destination images
 #
b52db8df
 STARTTIME=$(date +%s)
614bf6cc
 source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
e3bb13a1
 
e9d5daa7
 # Allow a release to be repushed with a tag
 tag="${OS_PUSH_TAG:-}"
 if [[ -n "${tag}" ]]; then
5829039a
   if [[ "${tag}" == "HEAD" ]]; then
     if [[ "$( git tag --points-at HEAD | wc -l )" -ne 1 ]]; then
       echo "error: There must be exactly one tag pointing to HEAD to use OS_PUSH_TAG=HEAD"
       exit 1
     fi
     tag=":$( git tag --points-at HEAD)"
   else
     tag=":${tag}"
   fi
5d1a2515
 else
   tag=":latest"
e3bb13a1
 fi
 
776b67b2
 # Source tag
 source_tag="${OS_TAG:-}"
 if [[ -z "${source_tag}" ]]; then
   source_tag="latest"
   file="${OS_ROOT}/_output/local/releases/.commit"
   if [[ -e ${file} ]]; then
     source_tag="$(cat $file)"
   fi
 fi
 
e9d5daa7
 base_images=(
   openshift/origin-base
   openshift/origin-release
 )
e3bb13a1
 images=(
   openshift/origin
28b61240
   openshift/origin-pod
e3bb13a1
   openshift/origin-deployer
   openshift/origin-docker-builder
04bc45a0
   openshift/origin-docker-registry
   openshift/origin-keepalived-ipfailover
e3bb13a1
   openshift/origin-sti-builder
   openshift/origin-haproxy-router
54e42d39
   openshift/origin-f5-router
d678d1c6
   openshift/origin-egress-router
bf5af09e
   openshift/origin-recycler
20792254
   openshift/origin-gitserver
e3bb13a1
   openshift/hello-openshift
69b13035
   openshift/openvswitch
   openshift/node
e3bb13a1
 )
e9d5daa7
 
f701cd4a
 PUSH_OPTS=""
 if docker push --help | grep -q force; then
   PUSH_OPTS="--force"
 fi
 
5d1a2515
 # Push the base images to a registry
 if [[ "${tag}" == ":latest" ]]; then
e9d5daa7
   if [[ "${OS_PUSH_BASE_IMAGES-}" != "" ]]; then
     for image in "${base_images[@]}"; do
       if [[ "${OS_PUSH_BASE_REGISTRY-}" != "" ]]; then
776b67b2
         docker tag -f "${image}:${source_tag}" "${OS_PUSH_BASE_REGISTRY}${image}${tag}"
e9d5daa7
       fi
f701cd4a
       docker push ${PUSH_OPTS} "${OS_PUSH_BASE_REGISTRY-}${image}${tag}"
e9d5daa7
     done
e3bb13a1
   fi
e9d5daa7
 fi
 
 # Pull latest in preparation for tagging
5d1a2515
 if [[ "${tag}" != ":latest" ]]; then
   if [[ -z "${OS_PUSH_LOCAL-}" ]]; then
     for image in "${images[@]}"; do
776b67b2
       docker pull "${OS_PUSH_BASE_REGISTRY-}${image}:${source_tag}"
5d1a2515
     done
   else
f2620b99
     echo "WARNING: Pushing local :${source_tag} images to ${OS_PUSH_BASE_REGISTRY-}*${tag}"
5829039a
     if [[ -z "${OS_PUSH_ALWAYS:-}" ]]; then
       echo "  CTRL+C to cancel, or any other key to continue"
       read
     fi
5d1a2515
   fi
e9d5daa7
 fi
 
 if [[ "${OS_PUSH_BASE_REGISTRY-}" != "" || "${tag}" != "" ]]; then
   for image in "${images[@]}"; do
776b67b2
     docker tag -f "${image}:${source_tag}" "${OS_PUSH_BASE_REGISTRY-}${image}${tag}"
e9d5daa7
   done
 fi
 
 for image in "${images[@]}"; do
f701cd4a
   docker push ${PUSH_OPTS} "${OS_PUSH_BASE_REGISTRY-}${image}${tag}"
e3bb13a1
 done
b52db8df
 
 ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret"