Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 31 additions & 10 deletions scripts/update-versions.sh
Original file line number Diff line number Diff line change
@@ -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 <old_version> <new_version> <old_cdp_version> <new_cdp_version>"
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"
Expand All @@ -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
popd