Skip to content

Commit be3818a

Browse files
authored
fix bump scripts (#3013)
1 parent da130f1 commit be3818a

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

hack/bump-charts.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,15 @@ TO_MINOR="${3:?TO_MINOR (3rd arg) not set or empty}"
2121
# example usage: hack/bump-release.sh 28 28 1
2222
# should replace 1.28.x with 1.28.1 / 2.28.x with 2.28.1
2323

24-
find charts -type f -exec sed -i -re 's/((ersion)?: ?v?)?([1-2]\.)'${FROM_MAJOR}'\.([0-9][0-9a-zA-Z.-]*)/\1\3'${TO_MAJOR}'.'${TO_MINOR}'/g' "{}" \;
24+
# Use portable sed syntax that works on both Linux (GNU sed) and macOS (BSD sed)
25+
if sed --version >/dev/null 2>&1; then
26+
# GNU sed (Linux)
27+
SED_INPLACE=(-i)
28+
SED_EXTENDED=(-r)
29+
else
30+
# BSD sed (macOS)
31+
SED_INPLACE=(-i '')
32+
SED_EXTENDED=(-E)
33+
fi
34+
35+
find charts -type f -exec sed "${SED_INPLACE[@]}" "${SED_EXTENDED[@]}" -e 's/((ersion)?: ?v?)?([1-2]\.)'${FROM_MAJOR}'\.([0-9][0-9a-zA-Z.-]*)/\1\3'${TO_MAJOR}'.'${TO_MINOR}'/g' "{}" \;

hack/bump-release.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,15 @@ TO_MINOR="${3:?TO_MINOR (3rd arg) not set or empty}"
2121
# example usage: hack/bump-release.sh 28 28 1
2222
# should replace 1.28.x with 1.28.1 / 2.28.x with 2.28.1
2323

24-
find docs manifests tests examples -type f -exec sed -i -re 's/((ersion)?: ?v?)?([1-2]\.)'${FROM_MAJOR}'\.([0-9][0-9a-zA-Z.-]*)/\1\3'${TO_MAJOR}'.'${TO_MINOR}'/g' "{}" \;
24+
# Use portable sed syntax that works on both Linux (GNU sed) and macOS (BSD sed)
25+
if sed --version >/dev/null 2>&1; then
26+
# GNU sed (Linux)
27+
SED_INPLACE=(-i)
28+
SED_EXTENDED=(-r)
29+
else
30+
# BSD sed (macOS)
31+
SED_INPLACE=(-i '')
32+
SED_EXTENDED=(-E)
33+
fi
34+
35+
find docs manifests tests examples -type f -exec sed "${SED_INPLACE[@]}" "${SED_EXTENDED[@]}" -e 's/((ersion)?: ?v?)?([1-2]\.)'${FROM_MAJOR}'\.([0-9][0-9a-zA-Z.-]*)/\1\3'${TO_MAJOR}'.'${TO_MINOR}'/g' "{}" \;

0 commit comments

Comments
 (0)