forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush-release.sh
executable file
·104 lines (91 loc) · 2.51 KB
/
push-release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/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
#
set -o errexit
set -o nounset
set -o pipefail
STARTTIME=$(date +%s)
OS_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${OS_ROOT}/hack/common.sh"
# Go to the top of the tree.
cd "${OS_ROOT}"
# Allow a release to be repushed with a tag
tag="${OS_PUSH_TAG:-}"
if [[ -n "${tag}" ]]; then
tag=":${tag}"
else
tag=":latest"
fi
# 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
base_images=(
openshift/origin-base
openshift/origin-release
)
images=(
openshift/origin
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-recycler
openshift/origin-gitserver
openshift/hello-openshift
openshift/openvswitch
openshift/node
)
PUSH_OPTS=""
if docker push --help | grep -q force; then
PUSH_OPTS="--force"
fi
# Push the base images to a registry
if [[ "${tag}" == ":latest" ]]; then
if [[ "${OS_PUSH_BASE_IMAGES-}" != "" ]]; then
for image in "${base_images[@]}"; do
if [[ "${OS_PUSH_BASE_REGISTRY-}" != "" ]]; then
docker tag -f "${image}:${source_tag}" "${OS_PUSH_BASE_REGISTRY}${image}${tag}"
fi
docker push ${PUSH_OPTS} "${OS_PUSH_BASE_REGISTRY-}${image}${tag}"
done
fi
fi
# Pull latest in preparation for tagging
if [[ "${tag}" != ":latest" ]]; then
if [[ -z "${OS_PUSH_LOCAL-}" ]]; then
set -e
for image in "${images[@]}"; do
docker pull "${OS_PUSH_BASE_REGISTRY-}${image}:${source_tag}"
done
set +e
else
echo "WARNING: Pushing local :${source_tag} images to ${OS_PUSH_BASE_REGISTRY-}*${tag}"
echo " CTRL+C to cancel, or any other key to continue"
read
fi
fi
if [[ "${OS_PUSH_BASE_REGISTRY-}" != "" || "${tag}" != "" ]]; then
set -e
for image in "${images[@]}"; do
docker tag -f "${image}:${source_tag}" "${OS_PUSH_BASE_REGISTRY-}${image}${tag}"
done
set +e
fi
for image in "${images[@]}"; do
docker push ${PUSH_OPTS} "${OS_PUSH_BASE_REGISTRY-}${image}${tag}"
done
ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret"