Skip to content
This repository was archived by the owner on Aug 2, 2019. It is now read-only.

Commit 3bd3449

Browse files
authored
Merge pull request #27 from bbrowning/release-script
Add simple release script
2 parents a80c9d9 + c23cdcc commit 3bd3449

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

etc/scripts/knative_release.sh

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# This script mirrors the Knative images built by OpenShift CI to
6+
# quay.io. It also pushes tags to GitHub for each repository in the
7+
# release except knative-operators.
8+
#
9+
# For every new major or minor version, bump RELEASE_MAJOR_MINOR to
10+
# the correct value. If doing a patch release, the script may need to
11+
# be adjusted a bit. At a minimum, RELEASE_VERSION will need to be
12+
# updated to not assume the patch version is 0.
13+
#
14+
# Also check CI_TAGS and add/remove/rename any images if they've
15+
# changed since the last release.
16+
#
17+
# The definitive list of images for each repo in Knative can be found
18+
# by looking at the bottom of the build logs for each Knative release
19+
# promotion job at
20+
# https://openshift-gce-devel.appspot.com/jobs/origin-ci-test/logs/.
21+
#
22+
# For example,
23+
# https://openshift-gce-devel.appspot.com/builds/origin-ci-test/logs/branch-ci-openshift-knative-build-release-0.3-images/
24+
# and then click on the most recent job for the 0.3 release branch, view the entire log, and you'll see lines like:
25+
#
26+
# 2019/02/19 21:41:32 Promoting tags to openshift/knative-v0.3:${component}: knative-build-controller, knative-build-creds-init, knative-build-git-init, knative-build-nop, knative-build-test-panic, knative-build-webhook
27+
#
28+
29+
30+
RELEASE_MAJOR_MINOR="0.3"
31+
32+
RELEASE_VERSION="${RELEASE_MAJOR_MINOR}.0"
33+
RELEASE_BRANCH="release-${RELEASE_MAJOR_MINOR}"
34+
RELEASE_TAG="openshift-v${RELEASE_VERSION}"
35+
RELEASE_DOCKER_REPO="quay.io/openshift-knative/knative-${RELEASE_VERSION}"
36+
37+
CI_DOCKER_REGISTRY="registry.svc.ci.openshift.org"
38+
CI_DOCKER_ORG="openshift"
39+
CI_DOCKER_IMAGE="knative-v${RELEASE_MAJOR_MINOR}"
40+
41+
CI_TAGS=$(cat <<EOF
42+
knative-build-controller
43+
knative-build-creds-init
44+
knative-build-git-init
45+
knative-build-nop
46+
knative-build-webhook
47+
knative-eventing-controller
48+
knative-eventing-fanoutsidecar
49+
knative-eventing-in-memory-channel-controller
50+
knative-eventing-kafka
51+
knative-eventing-webhook
52+
knative-eventing-sources-awssqs-receive-adapter
53+
knative-eventing-sources-cronjob-receive-adapter
54+
knative-eventing-sources-github-receive-adapter
55+
knative-eventing-sources-heartbeats
56+
knative-eventing-sources-heartbeats-receiver
57+
knative-eventing-sources-kuberneteseventsource
58+
knative-eventing-sources-manager
59+
knative-eventing-sources-message-dumper
60+
knative-eventing-sources-websocketsource
61+
knative-serving-activator
62+
knative-serving-autoscaler
63+
knative-serving-controller
64+
knative-serving-queue
65+
knative-serving-webhook
66+
EOF
67+
)
68+
69+
function push_knative_images(){
70+
# First pull all the images
71+
for tag in ${CI_TAGS}; do
72+
echo "Pulling image ${CI_DOCKER_REGISTRY}/${CI_DOCKER_ORG}/${CI_DOCKER_IMAGE}:${tag}"
73+
docker pull ${CI_DOCKER_REGISTRY}/${CI_DOCKER_ORG}/${CI_DOCKER_IMAGE}:${tag}
74+
done
75+
76+
# Then tag them
77+
for tag in ${CI_TAGS}; do
78+
echo "Tagging image ${RELEASE_DOCKER_REPO}:${tag}"
79+
docker tag ${CI_DOCKER_REGISTRY}/${CI_DOCKER_ORG}/${CI_DOCKER_IMAGE}:${tag} ${RELEASE_DOCKER_REPO}:${tag}
80+
done
81+
82+
# Then, only if pulling and tagging were successful, push them
83+
for tag in ${CI_TAGS}; do
84+
echo "Pushing image ${RELEASE_DOCKER_REPO}:${tag}"
85+
docker push ${RELEASE_DOCKER_REPO}:${tag}
86+
done
87+
}
88+
89+
function tag_knative_forks(){
90+
for project in build serving eventing eventing-sources; do
91+
echo "Tagging ${project} with ${RELEASE_TAG}"
92+
git clone -q -b ${RELEASE_BRANCH} [email protected]:openshift/knative-${project}.git
93+
94+
pushd knative-${project} > /dev/null
95+
git tag -f ${RELEASE_TAG}
96+
git push origin ${RELEASE_TAG}
97+
popd > /dev/null
98+
done
99+
}
100+
101+
function update_and_tag_repos(){
102+
local tmpdir=$(mktemp -d)
103+
echo "Using ${tmpdir} as a temporary directory for repo clones"
104+
pushd $tmpdir > /dev/null
105+
106+
tag_knative_forks ${RELEASE_VERSION}
107+
108+
echo "Tagging Documentation with ${RELEASE_TAG}"
109+
git clone -q [email protected]:openshift-cloud-functions/Documentation.git
110+
pushd Documentation
111+
git tag -f ${RELEASE_TAG}
112+
git push -f origin ${RELEASE_TAG}
113+
popd
114+
115+
popd > /dev/null
116+
117+
# Just a sanity check before we rm -rf something...
118+
if [[ $(echo "${tmpdir}" | grep "/tmp/tmp") ]]; then
119+
rm -rf "${tmpdir}"
120+
fi
121+
}
122+
123+
echo "Releasing OpenShift Knative ${RELEASE_VERSION}"
124+
125+
push_knative_images
126+
127+
update_and_tag_repos
128+
129+
exit 0

0 commit comments

Comments
 (0)