Skip to content

Commit 1f918c1

Browse files
authored
billi release script (#1437)
1 parent 4e4d40b commit 1f918c1

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

agent/release/billi-release.sh

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/usr/bin/env bash
2+
3+
function verify_if_release_image_exists() {
4+
local release_image=$1
5+
if [ ! "$(podman manifest inspect ${release_image})" ]; then
6+
echo "Cannot download image ${release_image}"
7+
fi
8+
}
9+
10+
function clone_agent_repo() {
11+
12+
local commit=$1
13+
14+
if [[ ! -d "installer" ]]; then
15+
git clone https://github.com/openshift/installer.git
16+
fi
17+
18+
if [[ ! -z "${commit}" ]]; then
19+
echo "Building from commit $commit"
20+
fi
21+
22+
pushd installer
23+
git checkout $commit
24+
popd
25+
}
26+
27+
function build_agent_installer() {
28+
pushd installer
29+
hack/build.sh
30+
popd
31+
}
32+
33+
function patch_openshift_install_release_version() {
34+
local version=$1
35+
36+
local res=$(grep -oba ._RELEASE_VERSION_LOCATION_.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX installer/bin/openshift-install)
37+
local location=${res%%:*}
38+
39+
# If the release marker was found then it means that the version is missing
40+
if [[ ! -z ${location} ]]; then
41+
echo "Patching openshift-install with version ${version}"
42+
printf "${version}\0" | dd of=installer/bin/openshift-install bs=1 seek=${location} conv=notrunc &> /dev/null
43+
else
44+
echo "Version already patched"
45+
fi
46+
}
47+
48+
function patch_openshift_install_release_image() {
49+
local image=$1
50+
51+
local res=$(grep -oba ._RELEASE_IMAGE_LOCATION_.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX installer/bin/openshift-install)
52+
local location=${res%%:*}
53+
54+
# If the release marker was found then it means that the image is missing
55+
if [[ ! -z ${location} ]]; then
56+
echo "Patching openshift-install with image ${image}"
57+
printf "${image}\0" | dd of=installer/bin/openshift-install bs=1 seek=${location} conv=notrunc &> /dev/null
58+
else
59+
echo "Image already patched"
60+
fi
61+
}
62+
63+
function complete_release() {
64+
echo
65+
echo "BILLI installer release completed"
66+
echo
67+
68+
installer/bin/openshift-install version
69+
}
70+
71+
if [ "$#" -ne 2 ]; then
72+
echo "Usage: billi-release.sh <commit> <release image>"
73+
echo "[Arguments]"
74+
echo " <commit> The git commit to be used for building the installer"
75+
echo " <release image> The desired OpenShift release image location"
76+
echo
77+
echo "example: ./billi-release.sh 38e719a quay.io/openshift-release-dev/ocp-release@sha256:300bce8246cf880e792e106607925de0a404484637627edf5f517375517d54a4"
78+
79+
exit 1
80+
fi
81+
82+
commit=$1
83+
release_image=$2
84+
release_version=$(oc adm release info -o template --template '{{.metadata.version}}' --insecure=true ${release_image})
85+
86+
verify_if_release_image_exists $release_image
87+
clone_agent_repo $commit
88+
build_agent_installer
89+
patch_openshift_install_release_version $release_version
90+
patch_openshift_install_release_image $release_image
91+
complete_release

0 commit comments

Comments
 (0)