Skip to content

Commit 81d6d35

Browse files
Make update_version.sh work with BSD grep and sed
Read the version with sed instead of grep -P, use sed -i.bak so the in-place edit works with both GNU and BSD sed, and exit if the version cannot be read. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 690b913 commit 81d6d35

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎tools/update_version.sh‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
#!/usr/bin/env bash
22
new_version=$1
33

4-
current_version=`grep -oP "(?<=VERSION \= \")([0-9.]+)(?=\")" cloudinary-core/src/main/java/com/cloudinary/Cloudinary.java`
4+
current_version=`sed -n 's/.*VERSION = "\([0-9.]*\)".*/\1/p' cloudinary-core/src/main/java/com/cloudinary/Cloudinary.java`
5+
if [ -z "$current_version" ]; then
6+
echo "Could not read VERSION from cloudinary-core/src/main/java/com/cloudinary/Cloudinary.java"
7+
exit 1
8+
fi
59
current_version_re=${current_version//./\\.}
610
echo "Current version is $current_version"
711
if [ -n "$new_version" ]; then
812
echo "New version will be $new_version"
913
echo "Pattern used: $current_version_re"
10-
sed -e "s/${current_version_re}/${new_version}/g" -i "" cloudinary-core/src/main/java/com/cloudinary/Cloudinary.java
11-
sed -e "s/${current_version_re}/${new_version}/g" -i "" README.md
12-
sed -e "s/${current_version_re}/${new_version}/g" -i "" gradle.properties
14+
for file in cloudinary-core/src/main/java/com/cloudinary/Cloudinary.java README.md gradle.properties; do
15+
sed -i.bak -e "s/${current_version_re}/${new_version}/g" "$file" && rm "$file.bak"
16+
done
1317
git changelog -t $new_version
1418
else
1519
echo "Usage: $0 <new version>"

0 commit comments

Comments
 (0)