Skip to content

Commit

Permalink
script to automate version updates
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Nov 1, 2023
1 parent c9816fb commit 014ead4
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions scripts/update-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

VERSION="$1"
MAJOR_VERSION=$(echo "${VERSION}" | cut -d. -f1)
MINOR_VERSION=$(echo "${VERSION}" | cut -d. -f2)
PREVIOUS_MINOR_VERSION=$((MINOR_VERSION-1))
PREVIOUS_VERSION="${MAJOR_VERSION}.${PREVIOUS_MINOR_VERSION}"
NEXT_MINOR_VERSION=$((MINOR_VERSION+1))
NEXT_VERSION="${MAJOR_VERSION}.${NEXT_MINOR_VERSION}"
BUILD_TYPE="$2"

release_version() {
local FILE_PATH="$1"

if [[ "$FILE_PATH" == "java/version.bzl" ]] || [[ "$FILE_PATH" == "Rakefile" ]]; then
sed -i '' "s/\.0-SNAPSHOT/\.0/g" "${FILE_PATH}"
elif [[ "$FILE_PATH" == "rb/lib/selenium/webdriver/version.rb" ]]; then
sed -i '' "s/\.nightly//g" "${FILE_PATH}"
else
sed -i '' "s/${PREVIOUS_VERSION}\.[0-9]*/${VERSION}.0/g" "${FILE_PATH}"
fi
}

FILES_TO_UPDATE=(
"Rakefile"
"dotnet/selenium-dotnet-version.bzl"
"rb/lib/selenium/webdriver/version.rb"
"py/setup.py"
"py/BUILD.bazel"
"py/selenium/init.py"
"py/selenium/webdriver/init.py"
"py/docs/source/index.rst"
"py/docs/source/conf.py"
"java/version.bzl"
"javascript/node/selenium-webdriver/package.json"
"rust/Cargo.toml"
"rust/BUILD.bazel"
)

if [[ "$BUILD_TYPE" == "nightly" ]]; then
sed -i '' "s/#{release_version}.0/#{release_version}.0-SNAPSHOT/g" "Rakefile"
sed -i '' "s/${VERSION}/${NEXT_VERSION}/g" "Rakefile"
sed -i '' "s/${VERSION}.0/${NEXT_VERSION}.0-SNAPSHOT/g" "java/version.bzl"
sed -i '' "s/${VERSION}.0/${NEXT_VERSION}.0.nightly/g" "rb/lib/selenium/webdriver/version.rb"
else
for file in "${FILES_TO_UPDATE[@]}"; do
if [[ -f $file ]]; then
release_version "$file"
fi
done
fi


pushd rb
bundle install
popd

pushd javascript/node/selenium-webdriver
npm install
popd

0 comments on commit 014ead4

Please sign in to comment.