@@ -21,11 +21,18 @@ PULL_SECRET_FILE="${HOME}/.pull-secret.json"
21
21
22
22
RELEASE_JSON=" ${REPOROOT} /assets/optional/rhoai/release-x86_64.json"
23
23
24
+ KEEP_STAGING=" ${KEEP_STAGING:- false} "
25
+
24
26
title () {
25
27
echo -e " \E[34m$1 \E[00m" ;
26
28
}
27
29
28
30
check_preconditions () {
31
+ if [[ " ${REPOROOT} " != " $( pwd) " ]]; then
32
+ echo " Script must be executed from root of the MicroShift repository"
33
+ exit 1
34
+ fi
35
+
29
36
if ! hash yq; then
30
37
title " Installing yq"
31
38
@@ -83,7 +90,7 @@ get_auth() {
83
90
download_rhoai_manifests () {
84
91
local -r bundle_ref=" ${1} "
85
92
86
- # Jan 2025: Only x86_64 is supported (https://access.redhat.com/articles/rhoai-supported-configs)
93
+ # Jan/Feb 2025: Only x86_64 is supported (https://access.redhat.com/articles/rhoai-supported-configs)
87
94
# therefore there's no loop over architectures.
88
95
89
96
rm -rf " ${STAGING_RHOAI} " && mkdir -p " ${STAGING_BUNDLE} " " ${STAGING_OPERATOR} "
@@ -110,7 +117,7 @@ process_rhoai_manifests() {
110
117
" ${REPOROOT} /scripts/auto-rebase/handle_assets.py" ./scripts/auto-rebase/assets_rhoai.yaml
111
118
112
119
title " Initializing release.json file"
113
- local -r version=$( yq ' .spec.version ' " ${STAGING_BUNDLE} / ${CSV_FILENAME} " )
120
+ local -r version=$( get_rhoai_bundle_version )
114
121
echo " { \" release\" : {\" base\" : \" ${version} \" }, \" images\" : {}}" | yq -o json > " ${RELEASE_JSON} "
115
122
116
123
update_runtimes
@@ -138,7 +145,7 @@ update_runtimes() {
138
145
done
139
146
done
140
147
141
- title " Creating ServingRuntime images kustomization"
148
+ title " Creating ClusterServingRuntimes images kustomization"
142
149
143
150
local -r kustomization_images=" ${REPOROOT} /assets/optional/rhoai/runtimes/kustomization.x86_64.yaml"
144
151
cat << EOF > "${kustomization_images} "
153
160
local image_ref_repo=" ${image_ref%@* } "
154
161
local image_ref_digest=" ${image_ref#*@ } "
155
162
156
- tee -a " ${kustomization_images} " << EOF
163
+ cat << EOF >> "${kustomization_images} "
157
164
- name: ${image_name}
158
165
newName: ${image_ref_repo}
159
166
digest: ${image_ref_digest}
163
170
done
164
171
}
165
172
166
- download_rhoai_manifests " registry.redhat.io/rhoai/odh-operator-bundle:v2.16.0"
167
- process_rhoai_manifests
173
+ get_rhoai_bundle_version () {
174
+ yq ' .spec.version' " ${STAGING_BUNDLE} /${CSV_FILENAME} "
175
+ }
176
+
177
+ update_last_rebase_rhoai_sh () {
178
+ local -r operator_bundle=" ${1} "
179
+
180
+ title " Updating last_rebase_rhoai.sh"
181
+ local -r last_rebase_script=" ${REPOROOT} /scripts/auto-rebase/last_rebase_rhoai.sh"
182
+
183
+ rm -f " ${last_rebase_script} "
184
+ cat - > " ${last_rebase_script} " << EOF
185
+ #!/bin/bash -x
186
+ ./scripts/auto-rebase/rebase_rhoai.sh to "${operator_bundle} "
187
+ EOF
188
+ chmod +x " ${last_rebase_script} "
189
+ }
190
+
191
+ rebase_model_serving_to () {
192
+ local -r operator_bundle=" ${1} "
193
+
194
+ title " Rebasing RHOAI Model Serving for MicroShift to ${operator_bundle} "
195
+
196
+ download_rhoai_manifests " ${operator_bundle} "
197
+ local -r version=$( get_rhoai_bundle_version)
198
+
199
+ update_last_rebase_rhoai_sh " ${operator_bundle} "
200
+
201
+ process_rhoai_manifests
202
+
203
+ if [[ -n " $( git status -s assets ./scripts/auto-rebase/last_rebase_rhoai.sh) " ]]; then
204
+ branch=" rebase-rhoai-${version} "
205
+ title " Detected changes to assets/ or last_rebase_rhoai.sh - creating branch ${branch} "
206
+ git branch -D " ${branch} " 2> /dev/null || true && git checkout -b " ${branch} "
207
+
208
+ title " Committing changes"
209
+ git add assets ./scripts/auto-rebase/last_rebase_rhoai.sh
210
+ git commit -m " Update RHOAI"
211
+ else
212
+ title " No changes to assets/ or last_rebase_rhoai.sh"
213
+ fi
214
+
215
+ if ! " ${KEEP_STAGING} " ; then
216
+ title " Removing staging directory"
217
+ rm -rf " ${STAGING_RHOAI} "
218
+ fi
219
+ }
220
+
221
+ usage () {
222
+ echo " Usage:"
223
+ echo " $( basename " $0 " ) to RHOAI_OPERATOR_BUNDLE Performs all the steps to rebase RHOAI Model Serving for MicroShift"
224
+ echo " $( basename " $0 " ) download RHOAI_OPERATOR_BUNDLE Downloads the contents of the RHOAI Operator (Bundle) to disk in preparation for rebasing"
225
+ echo " $( basename " $0 " ) process Process already downloaded RHOAI Operator (Bundle) artifacts to update RHOAI Model Serving for MicroShift"
226
+ exit 1
227
+ }
228
+
229
+ check_preconditions
230
+
231
+ command=${1:- help}
232
+ case " ${command} " in
233
+ to)
234
+ rebase_model_serving_to " $2 "
235
+ ;;
236
+ download)
237
+ download_rhoai_manifests " $2 "
238
+ ;;
239
+ process)
240
+ process_rhoai_manifests
241
+ ;;
242
+ * ) usage;;
243
+ esac
0 commit comments