11#! /bin/bash
2+ set -euo pipefail
23
34# Target repos: "clone-url local-directory"
45# Add or remove entries here to sync to more/fewer upstreams.
@@ -22,8 +23,43 @@ if [ ! -f "$CSV_PATH" ]; then
2223fi
2324
2425VERSION=$( grep " ^ version:" " $CSV_PATH " | awk ' {print $2}' )
26+ if [ -z " $VERSION " ]; then
27+ echo " Error: failed to extract VERSION from $CSV_PATH " >&2
28+ echo " Expected a line matching '^ version:' in $CSV_PATH but got nothing." >&2
29+ exit 1
30+ fi
2531echo " Bundle version: ${VERSION} "
2632
33+ REPLACES=$( grep " ^ replaces:" " $CSV_PATH " | awk ' {print $2}' )
34+ if [ -z " $REPLACES " ]; then
35+ echo " Error: 'spec.replaces' is not set in $CSV_PATH " >&2
36+ echo " Set 'replaces: jumpstarter-operator.vX.Y.Z' in the CSV base before contributing." >&2
37+ exit 1
38+ fi
39+
40+ REPLACES_VERSION=" ${REPLACES# jumpstarter-operator.v} "
41+ if [ " $REPLACES_VERSION " = " $VERSION " ]; then
42+ echo " Error: 'spec.replaces' version ($REPLACES_VERSION ) is the same as the bundle version ($VERSION )." >&2
43+ echo " Update 'replaces' in the CSV base to point to the previous release." >&2
44+ exit 1
45+ fi
46+
47+ echo " "
48+ echo " ============================================"
49+ echo " Bundle version : ${VERSION} "
50+ echo " Replaces : ${REPLACES} (v${REPLACES_VERSION} )"
51+ echo " ============================================"
52+ echo " "
53+ read -r -p " Proceed with contribution? [y/N] " confirm
54+ if [[ ! " $confirm " =~ ^[Yy]$ ]]; then
55+ echo " "
56+ echo " Aborted. To update these values, edit:"
57+ echo " - VERSION in: ${OPERATOR_DIR} /Makefile"
58+ echo " - replaces in: ${OPERATOR_DIR} /config/manifests/bases/jumpstarter-operator.clusterserviceversion.yaml"
59+ echo " Then re-run 'make bundle' followed by 'make contribute'."
60+ exit 1
61+ fi
62+
2763# Clone any missing repos and ensure "user" remote points to the GITHUB_USER fork
2864for entry in " ${COMMUNITY_OPS[@]} " ; do
2965 read -r url dir <<< " $entry"
@@ -40,7 +76,7 @@ for entry in "${COMMUNITY_OPS[@]}"; do
4076
4177 # Add or update the "user" remote for the fork
4278 (
43- cd " $dir "
79+ cd " $dir " || exit 1
4480 if git remote get-url user & > /dev/null; then
4581 git remote set-url user " $user_fork "
4682 else
@@ -55,7 +91,7 @@ BRANCH="jumpstarter-operator-release-${VERSION}"
5591for entry in " ${COMMUNITY_OPS[@]} " ; do
5692 read -r url dir <<< " $entry"
5793 echo " --- $dir : switching to branch $BRANCH ---"
58- (cd " $dir " && git fetch --all && git checkout remotes/origin/main -B " $BRANCH " )
94+ (cd " $dir " || exit 1 ; git fetch --all && git checkout remotes/origin/main -B " $BRANCH " )
5995done
6096
6197# Copy bundle into each repo and commit
@@ -65,7 +101,7 @@ for entry in "${COMMUNITY_OPS[@]}"; do
65101 echo " Updating ${dir} to version ${VERSION} "
66102 mkdir -p " $dest "
67103 cp -v -r -f " ${BUNDLE_DIR} " /* " $dest "
68- (cd " $dir " && git add -A && git commit -s -m " operator jumpstarter-operator (${VERSION} )" )
104+ (cd " $dir " || exit 1 ; git add -A && git commit -s -m " operator jumpstarter-operator (${VERSION} )" )
69105done
70106
71107echo " "
0 commit comments