diff --git a/scripts/update-versions.sh b/scripts/update-versions.sh index 735d053c2252..57555b927388 100755 --- a/scripts/update-versions.sh +++ b/scripts/update-versions.sh @@ -1,9 +1,22 @@ -#!/bin/bash +#!/usr/bin/env bash -VERSION_STR="$1" -NEW_VERSION=$(echo "$VERSION_STR" | cut -d. -f2) -OLD_VERSION=$((NEW_VERSION - 1)) -NEXT_VERSION=$((NEW_VERSION + 1)) +if [[ -z "$1" || -z "$2" || -z "$3" || -z "$4" ]]; then + echo -e "fatal: too few args\n" + echo -e "usage:\n update-versions.sh " + echo -e "example:\n ./update-versions.sh 4.35.0 4.38.0 137 142" + exit 1 +fi + + +if [[ "$1" != *.*.* || "$2" != *.*.* ]] ; then + echo "fatal: use major.minor.patch version numbers (e.g.: 4.38.0)" + exit 1 +fi + +OLD_VERSION="$1" +NEW_VERSION="$2" +OLD_CDP_VERSION="$3" +NEW_CDP_VERSION="$4" FILES=( "examples/java/build.gradle" @@ -13,20 +26,28 @@ FILES=( "examples/java/pom.xml" "examples/javascript/package.json" "examples/ruby/Gemfile" + "examples/ruby/spec/drivers/remote_webdriver_spec.rb" ) +# replace Selenium version for FILE_PATH in "${FILES[@]}"; do - if [[ "$FILE_PATH" == "examples/ruby/Gemfile" ]]; then - sed -i '' -E "s/4\.$NEW_VERSION\.0/4.$NEXT_VERSION.0/g" "$FILE_PATH" + echo $FILE_PATH + if [[ ! -f ${FILE_PATH} ]]; then + echo "can't find file for replacement!" fi - - sed -i '' -E "s/4\.$OLD_VERSION\.[0-9]+/4.$NEW_VERSION.0/g" "$FILE_PATH" + perl -i -pe "s/${OLD_VERSION}/${NEW_VERSION}/g" "${FILE_PATH}" done + +# replace CDP version +find ./examples -type f \ + '(' -name "*.cs" -o -name "*.java" -o -name "*.js" -o -name "*.py" -o -name "*.rb" ')' \ + -exec perl -i -pe "s/v${OLD_CDP_VERSION}/v${NEW_CDP_VERSION}/g" {} \; + pushd examples/ruby bundle install popd pushd examples/javascript npm install -popd \ No newline at end of file +popd