diff --git a/bin/utils/release_version_update.sh b/bin/utils/release_version_update.sh index bdc155fd439a..72df433aa65b 100755 --- a/bin/utils/release_version_update.sh +++ b/bin/utils/release_version_update.sh @@ -31,8 +31,6 @@ else exit 1; fi - -echo "IMPORTANT: this script works on Mac only" echo "Release preparation: replacing $FROM with $TO in different files" declare -a files=("CI/pom.xml.bash" @@ -48,10 +46,15 @@ declare -a files=("CI/pom.xml.bash" "samples/meta-codegen/lib/pom.xml" "pom.xml") +sedi () { + # Cross-platform version of sed -i that works both on Mac and Linux + sed --version >/dev/null 2>&1 && sed -i -e "$@" || sed -i "" "$@" +} + for filename in "${files[@]}"; do # e.g. sed -i '' "s/3.0.1-SNAPSHOT/3.0.1/g" CI/pom.xml.bash #echo "Running command: sed -i '' "s/$FROM/$TO/g" $filename" - if sed -i '' "s/$FROM/$TO/g" $filename; then + if sedi "s/$FROM/$TO/g" $filename; then echo "Updated $filename successfully!" else echo "ERROR: Failed to update $filename with the following command" diff --git a/bin/utils/release_version_update_docs.sh b/bin/utils/release_version_update_docs.sh index 0209e837a624..b77ad27c4169 100755 --- a/bin/utils/release_version_update_docs.sh +++ b/bin/utils/release_version_update_docs.sh @@ -31,8 +31,6 @@ else exit 1; fi - -echo "IMPORTANT: this script works on Mac only" echo "Release preparation: replacing $FROM with $TO in different files" declare -a files=("modules/openapi-generator-maven-plugin/README.md" @@ -45,10 +43,15 @@ declare -a files=("modules/openapi-generator-maven-plugin/README.md" "modules/openapi-generator-gradle-plugin/samples/local-spec/README.md" "README.md") +sedi () { + # Cross-platform version of sed -i that works both on Mac and Linux + sed --version >/dev/null 2>&1 && sed -i -e "$@" || sed -i "" "$@" +} + for filename in "${files[@]}"; do # e.g. sed -i '' "s/3.0.1-SNAPSHOT/3.0.1/g" CI/pom.xml.bash #echo "Running command: sed -i '' "s/$FROM/$TO/g" $filename" - if sed -i '' "s/$FROM/$TO/g" $filename; then + if sedi "s/$FROM/$TO/g" $filename; then echo "Updated $filename successfully!" else echo "ERROR: Failed to update $filename with the following command"