Skip to content

Commit

Permalink
Make release script cross-compatible between Mac and Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
cbornet committed Aug 30, 2018
1 parent 5745f6d commit fd83b2d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions bin/utils/release_version_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions bin/utils/release_version_update_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit fd83b2d

Please sign in to comment.