Skip to content

Commit

Permalink
Allow a new OS_PUSH_BASE_REPO flag to push-release
Browse files Browse the repository at this point in the history
Will allow us to rename images from openshift/* locally to a different
name when we push, for example to a per PR image repository.
  • Loading branch information
smarterclayton committed Mar 15, 2018
1 parent a8deba5 commit 0e97b0a
Showing 1 changed file with 39 additions and 28 deletions.
67 changes: 39 additions & 28 deletions hack/push-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ if [[ -n "${tag}" ]]; 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)"
tag=":$( git tag --points-at HEAD )"
else
tag=":${tag}"
fi
else
tag=":latest"
os::build::version::get_vars
if [[ "$( git rev-parse --abbrev-ref HEAD )" == "master" ]]; then
tag=":latest,:v${OS_GIT_MAJOR}.${OS_GIT_MINOR%+},:v${OS_GIT_MAJOR}.${OS_GIT_MINOR%+}.${OS_GIT_PATCH}"
else
tag=":v${OS_GIT_MAJOR}.${OS_GIT_MINOR%+},:v${OS_GIT_MAJOR}.${OS_GIT_MINOR%+}.${OS_GIT_PATCH}"
fi
fi

# Source tag
Expand All @@ -35,28 +40,30 @@ if [[ -z "${source_tag}" ]]; then
fi

images=(
openshift/origin
openshift/origin-base
openshift/origin-pod
openshift/origin-deployer
openshift/origin-docker-builder
openshift/origin-docker-registry
openshift/origin-keepalived-ipfailover
openshift/origin-sti-builder
openshift/origin-haproxy-router
openshift/origin-f5-router
openshift/origin-egress-router
openshift/origin-egress-http-proxy
openshift/origin-recycler
openshift/origin-gitserver
openshift/origin-cluster-capacity
openshift/origin-service-catalog
openshift/origin-template-service-broker
openshift/hello-openshift
openshift/openvswitch
openshift/node
origin
origin-base
origin-pod
origin-deployer
origin-docker-builder
origin-docker-registry
origin-keepalived-ipfailover
origin-sti-builder
origin-haproxy-router
origin-f5-router
origin-egress-router
origin-egress-http-proxy
origin-recycler
origin-gitserver
origin-cluster-capacity
origin-service-catalog
origin-template-service-broker
hello-openshift
openvswitch
node
)

OS_PUSH_BASE_REPO="${OS_PUSH_BASE_REPO:-openshift/}"

PUSH_OPTS=""
if docker push --help | grep -q force; then
PUSH_OPTS="--force"
Expand All @@ -66,27 +73,31 @@ fi
if [[ "${tag}" != ":latest" ]]; then
if [[ -z "${OS_PUSH_LOCAL-}" ]]; then
for image in "${images[@]}"; do
docker pull "${OS_PUSH_BASE_REGISTRY-}${image}:${source_tag}"
docker pull "${OS_PUSH_BASE_REGISTRY-}openshift/${image}:${source_tag}"
done
else
os::log::warning "Pushing local :${source_tag} images to ${OS_PUSH_BASE_REGISTRY-}*${tag}"
os::log::warning "Pushing local :${source_tag} images to ${OS_PUSH_BASE_REGISTRY-}${OS_PUSH_BASE_REPO}*${tag}"
if [[ -z "${OS_PUSH_ALWAYS:-}" ]]; then
echo " CTRL+C to cancel, or any other key to continue"
read
fi
fi
fi

IFS=',' read -r -a tags <<< "$tag"
if [[ "${OS_PUSH_BASE_REGISTRY-}" != "" || "${tag}" != "" ]]; then
for image in "${images[@]}"; do
os::log::info "Tagging ${image}:${source_tag} as ${OS_PUSH_BASE_REGISTRY-}${image}${tag}..."
docker tag "${image}:${source_tag}" "${OS_PUSH_BASE_REGISTRY-}${image}${tag}"
for tag in "${tags[@]}"; do
docker tag "openshift/${image}:${source_tag}" "${OS_PUSH_BASE_REGISTRY-}${OS_PUSH_BASE_REPO}${image}${tag}"
done
done
fi

for image in "${images[@]}"; do
os::log::info "Pushing ${OS_PUSH_BASE_REGISTRY-}${image}${tag}..."
docker push ${PUSH_OPTS} "${OS_PUSH_BASE_REGISTRY-}${image}${tag}"
for tag in "${tags[@]}"; do
os::log::info "Pushing ${OS_PUSH_BASE_REGISTRY-}${OS_PUSH_BASE_REPO}${image}${tag}..."
docker push ${PUSH_OPTS} "${OS_PUSH_BASE_REGISTRY-}${OS_PUSH_BASE_REPO}${image}${tag}"
done
done

ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret"

0 comments on commit 0e97b0a

Please sign in to comment.