Merge pull request #939 from cbornet/linux_release_scripts

Make release script cross-compatible between Mac and Linux
This commit is contained in:
Christophe Bornet 2018-08-31 09:18:07 +02:00 committed by GitHub
commit aceec7a5a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -31,8 +31,6 @@ else
exit 1; exit 1;
fi fi
echo "IMPORTANT: this script works on Mac only"
echo "Release preparation: replacing $FROM with $TO in different files" echo "Release preparation: replacing $FROM with $TO in different files"
declare -a files=("CI/pom.xml.bash" declare -a files=("CI/pom.xml.bash"
@ -48,10 +46,15 @@ declare -a files=("CI/pom.xml.bash"
"samples/meta-codegen/lib/pom.xml" "samples/meta-codegen/lib/pom.xml"
"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 for filename in "${files[@]}"; do
# e.g. sed -i '' "s/3.0.1-SNAPSHOT/3.0.1/g" CI/pom.xml.bash # 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" #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!" echo "Updated $filename successfully!"
else else
echo "ERROR: Failed to update $filename with the following command" echo "ERROR: Failed to update $filename with the following command"

View File

@ -31,8 +31,6 @@ else
exit 1; exit 1;
fi fi
echo "IMPORTANT: this script works on Mac only"
echo "Release preparation: replacing $FROM with $TO in different files" echo "Release preparation: replacing $FROM with $TO in different files"
declare -a files=("modules/openapi-generator-maven-plugin/README.md" 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" "modules/openapi-generator-gradle-plugin/samples/local-spec/README.md"
"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 for filename in "${files[@]}"; do
# e.g. sed -i '' "s/3.0.1-SNAPSHOT/3.0.1/g" CI/pom.xml.bash # 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" #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!" echo "Updated $filename successfully!"
else else
echo "ERROR: Failed to update $filename with the following command" echo "ERROR: Failed to update $filename with the following command"