|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# usage: ./bin/utils/release_version_update.sh 3.0.1-SNAPSHOT 3.0.1 |
| 4 | +# |
| 5 | +# Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) |
| 6 | +# |
| 7 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +# you may not use this file except in compliance with the License. |
| 9 | +# You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +# See the License for the specific language governing permissions and |
| 17 | +# limitations under the License. |
| 18 | +# |
| 19 | + |
| 20 | +if [[ "$1" != "" ]]; then |
| 21 | + FROM="$1" |
| 22 | +else |
| 23 | + echo "Missing argument. Usage e.g.: ./bin/utils/release_version_update.sh 3.0.1-SNAPSHOT 3.0.1" |
| 24 | + exit 1; |
| 25 | +fi |
| 26 | + |
| 27 | +if [[ "$2" != "" ]]; then |
| 28 | + TO="$2" |
| 29 | +else |
| 30 | + echo "Missing argument. Usage e.g.: ./bin/utils/release_version_update.sh 3.0.1-SNAPSHOT 3.0.1" |
| 31 | + exit 1; |
| 32 | +fi |
| 33 | + |
| 34 | + |
| 35 | +echo "IMPORTANT: this script works on Mac only" |
| 36 | +echo "Release preparation: replacing $FROM with $TO in different files" |
| 37 | + |
| 38 | +declare -a files=("CI/pom.xml.bash" |
| 39 | + "CI/pom.xml.circleci" |
| 40 | + "CI/pom.xml.circleci.java7" |
| 41 | + "CI/pom.xml.ios" |
| 42 | + "CI/pom.xml.shippable" |
| 43 | + "modules/openapi-generator-cli/pom.xml" |
| 44 | + "modules/openapi-generator-gradle-plugin/README.adoc" |
| 45 | + "modules/openapi-generator-gradle-plugin/gradle.properties" |
| 46 | + "modules/openapi-generator-gradle-plugin/pom.xml" |
| 47 | + "modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle" |
| 48 | + "modules/openapi-generator-maven-plugin/pom.xml" |
| 49 | + "modules/openapi-generator-online/pom.xml" |
| 50 | + "modules/openapi-generator/pom.xml" |
| 51 | + "modules/openapi-generator-online/Dockerfile" |
| 52 | + "pom.xml" |
| 53 | + "README.md") |
| 54 | + |
| 55 | +for filename in "${files[@]}"; do |
| 56 | + # e.g. sed -i '' "s/3.0.1-SNAPSHOT/3.0.1/g" CI/pom.xml.bash |
| 57 | + #echo "Running command: sed -i '' "s/$FROM/$TO/g" $filename" |
| 58 | + if sed -i '' "s/$FROM/$TO/g" $filename; then |
| 59 | + echo "Updated $filename successfully!" |
| 60 | + else |
| 61 | + echo "ERROR: Failed to update $filename with the following command" |
| 62 | + echo "sed -i '' \"s/$FROM/$TO/g\" $filename" |
| 63 | + fi |
| 64 | +done |
0 commit comments