Skip to content

Commit 0e97b0a

Browse files
Allow a new OS_PUSH_BASE_REPO flag to push-release
Will allow us to rename images from openshift/* locally to a different name when we push, for example to a per PR image repository.
1 parent a8deba5 commit 0e97b0a

File tree

1 file changed

+39
-28
lines changed

1 file changed

+39
-28
lines changed

hack/push-release.sh

+39-28
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ if [[ -n "${tag}" ]]; then
1616
echo "error: There must be exactly one tag pointing to HEAD to use OS_PUSH_TAG=HEAD"
1717
exit 1
1818
fi
19-
tag=":$( git tag --points-at HEAD)"
19+
tag=":$( git tag --points-at HEAD )"
2020
else
2121
tag=":${tag}"
2222
fi
2323
else
24-
tag=":latest"
24+
os::build::version::get_vars
25+
if [[ "$( git rev-parse --abbrev-ref HEAD )" == "master" ]]; then
26+
tag=":latest,:v${OS_GIT_MAJOR}.${OS_GIT_MINOR%+},:v${OS_GIT_MAJOR}.${OS_GIT_MINOR%+}.${OS_GIT_PATCH}"
27+
else
28+
tag=":v${OS_GIT_MAJOR}.${OS_GIT_MINOR%+},:v${OS_GIT_MAJOR}.${OS_GIT_MINOR%+}.${OS_GIT_PATCH}"
29+
fi
2530
fi
2631

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

3742
images=(
38-
openshift/origin
39-
openshift/origin-base
40-
openshift/origin-pod
41-
openshift/origin-deployer
42-
openshift/origin-docker-builder
43-
openshift/origin-docker-registry
44-
openshift/origin-keepalived-ipfailover
45-
openshift/origin-sti-builder
46-
openshift/origin-haproxy-router
47-
openshift/origin-f5-router
48-
openshift/origin-egress-router
49-
openshift/origin-egress-http-proxy
50-
openshift/origin-recycler
51-
openshift/origin-gitserver
52-
openshift/origin-cluster-capacity
53-
openshift/origin-service-catalog
54-
openshift/origin-template-service-broker
55-
openshift/hello-openshift
56-
openshift/openvswitch
57-
openshift/node
43+
origin
44+
origin-base
45+
origin-pod
46+
origin-deployer
47+
origin-docker-builder
48+
origin-docker-registry
49+
origin-keepalived-ipfailover
50+
origin-sti-builder
51+
origin-haproxy-router
52+
origin-f5-router
53+
origin-egress-router
54+
origin-egress-http-proxy
55+
origin-recycler
56+
origin-gitserver
57+
origin-cluster-capacity
58+
origin-service-catalog
59+
origin-template-service-broker
60+
hello-openshift
61+
openvswitch
62+
node
5863
)
5964

65+
OS_PUSH_BASE_REPO="${OS_PUSH_BASE_REPO:-openshift/}"
66+
6067
PUSH_OPTS=""
6168
if docker push --help | grep -q force; then
6269
PUSH_OPTS="--force"
@@ -66,27 +73,31 @@ fi
6673
if [[ "${tag}" != ":latest" ]]; then
6774
if [[ -z "${OS_PUSH_LOCAL-}" ]]; then
6875
for image in "${images[@]}"; do
69-
docker pull "${OS_PUSH_BASE_REGISTRY-}${image}:${source_tag}"
76+
docker pull "${OS_PUSH_BASE_REGISTRY-}openshift/${image}:${source_tag}"
7077
done
7178
else
72-
os::log::warning "Pushing local :${source_tag} images to ${OS_PUSH_BASE_REGISTRY-}*${tag}"
79+
os::log::warning "Pushing local :${source_tag} images to ${OS_PUSH_BASE_REGISTRY-}${OS_PUSH_BASE_REPO}*${tag}"
7380
if [[ -z "${OS_PUSH_ALWAYS:-}" ]]; then
7481
echo " CTRL+C to cancel, or any other key to continue"
7582
read
7683
fi
7784
fi
7885
fi
7986

87+
IFS=',' read -r -a tags <<< "$tag"
8088
if [[ "${OS_PUSH_BASE_REGISTRY-}" != "" || "${tag}" != "" ]]; then
8189
for image in "${images[@]}"; do
82-
os::log::info "Tagging ${image}:${source_tag} as ${OS_PUSH_BASE_REGISTRY-}${image}${tag}..."
83-
docker tag "${image}:${source_tag}" "${OS_PUSH_BASE_REGISTRY-}${image}${tag}"
90+
for tag in "${tags[@]}"; do
91+
docker tag "openshift/${image}:${source_tag}" "${OS_PUSH_BASE_REGISTRY-}${OS_PUSH_BASE_REPO}${image}${tag}"
92+
done
8493
done
8594
fi
8695

8796
for image in "${images[@]}"; do
88-
os::log::info "Pushing ${OS_PUSH_BASE_REGISTRY-}${image}${tag}..."
89-
docker push ${PUSH_OPTS} "${OS_PUSH_BASE_REGISTRY-}${image}${tag}"
97+
for tag in "${tags[@]}"; do
98+
os::log::info "Pushing ${OS_PUSH_BASE_REGISTRY-}${OS_PUSH_BASE_REPO}${image}${tag}..."
99+
docker push ${PUSH_OPTS} "${OS_PUSH_BASE_REGISTRY-}${OS_PUSH_BASE_REPO}${image}${tag}"
100+
done
90101
done
91102

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

0 commit comments

Comments
 (0)