Skip to content

Commit 1295900

Browse files
cgoldbergdiemol
andauthored
Update update-versions.sh to handle CDP versions (#2514)
* Update update-versions.sh to handle CDP versions * Fix usage * Exit 1 on version format error --------- Co-authored-by: Diego Molina <[email protected]>
1 parent cffccfd commit 1295900

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

scripts/update-versions.sh

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

3-
VERSION_STR="$1"
4-
NEW_VERSION=$(echo "$VERSION_STR" | cut -d. -f2)
5-
OLD_VERSION=$((NEW_VERSION - 1))
6-
NEXT_VERSION=$((NEW_VERSION + 1))
3+
if [[ -z "$1" || -z "$2" || -z "$3" || -z "$4" ]]; then
4+
echo -e "fatal: too few args\n"
5+
echo -e "usage:\n update-versions.sh <old_version> <new_version> <old_cdp_version> <new_cdp_version>"
6+
echo -e "example:\n ./update-versions.sh 4.35.0 4.38.0 137 142"
7+
exit 1
8+
fi
9+
10+
11+
if [[ "$1" != *.*.* || "$2" != *.*.* ]] ; then
12+
echo "fatal: use major.minor.patch version numbers (e.g.: 4.38.0)"
13+
exit 1
14+
fi
15+
16+
OLD_VERSION="$1"
17+
NEW_VERSION="$2"
18+
OLD_CDP_VERSION="$3"
19+
NEW_CDP_VERSION="$4"
720

821
FILES=(
922
"examples/java/build.gradle"
@@ -13,20 +26,28 @@ FILES=(
1326
"examples/java/pom.xml"
1427
"examples/javascript/package.json"
1528
"examples/ruby/Gemfile"
29+
"examples/ruby/spec/drivers/remote_webdriver_spec.rb"
1630
)
1731

32+
# replace Selenium version
1833
for FILE_PATH in "${FILES[@]}"; do
19-
if [[ "$FILE_PATH" == "examples/ruby/Gemfile" ]]; then
20-
sed -i '' -E "s/4\.$NEW_VERSION\.0/4.$NEXT_VERSION.0/g" "$FILE_PATH"
34+
echo $FILE_PATH
35+
if [[ ! -f ${FILE_PATH} ]]; then
36+
echo "can't find file for replacement!"
2137
fi
22-
23-
sed -i '' -E "s/4\.$OLD_VERSION\.[0-9]+/4.$NEW_VERSION.0/g" "$FILE_PATH"
38+
perl -i -pe "s/${OLD_VERSION}/${NEW_VERSION}/g" "${FILE_PATH}"
2439
done
2540

41+
42+
# replace CDP version
43+
find ./examples -type f \
44+
'(' -name "*.cs" -o -name "*.java" -o -name "*.js" -o -name "*.py" -o -name "*.rb" ')' \
45+
-exec perl -i -pe "s/v${OLD_CDP_VERSION}/v${NEW_CDP_VERSION}/g" {} \;
46+
2647
pushd examples/ruby
2748
bundle install
2849
popd
2950

3051
pushd examples/javascript
3152
npm install
32-
popd
53+
popd

0 commit comments

Comments
 (0)