From 8bf94b06d2fd75932c1783a3f1d15629ce84d31f Mon Sep 17 00:00:00 2001 From: Dominik Przybysz Date: Fri, 20 Dec 2024 07:48:08 +0100 Subject: [PATCH] SNOW-1853396: Prepare new version script --- README.rst | 13 ++++++++----- prepareNewVersion.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 5 deletions(-) create mode 100755 prepareNewVersion.sh diff --git a/README.rst b/README.rst index e742ce5d1..1abf17dee 100644 --- a/README.rst +++ b/README.rst @@ -195,17 +195,20 @@ Run the maven ``verify`` goal. where ``category`` is the class name under the package ``net.snowflake.client.category``. -Set new version +Prepare new version --------------- -1. Run maven command with passing specific version: +Run script passing desired version: .. code-block:: bash - mvn -f parent-pom.xml versions:set -DnewVersion=... -DgenerateBackupPoms=false + ./prepareNewVersion.sh 3.100.42 -2. Set manually the same version in field ``implementVersion`` in ``src/main/java/net/snowflake/client/jdbc/SnowflakeDriver.java`` when it's version for release or without ``-SNAPSHOT`` suffix between releases -3. Add entry in ``CHANGELOG.rst`` for release versions +Add SNAPSHOT suffix when necessary: + +.. code-block:: bash + + ./prepareNewVersion.sh 3.100.42-SNAPSHOT Test Class Naming Convention ---------------------------- diff --git a/prepareNewVersion.sh b/prepareNewVersion.sh new file mode 100755 index 000000000..2c2c871ac --- /dev/null +++ b/prepareNewVersion.sh @@ -0,0 +1,30 @@ +#!/bin/bash -e + +if [[ -z "$1" ]]; then + echo First argument must be new version to set + exit 1 +fi + +version=$1 + +# prepare release with maven +./mvnw -f parent-pom.xml versions:set -DnewVersion=$version -DgenerateBackupPoms=false + +# update version in Driver code +version_without_snapshot=${version%-*} +file_with_version=src/main/java/net/snowflake/client/jdbc/SnowflakeDriver.java +tmp_file_with_version=${file_with_version}.tmp +sed -E "s/( implementVersion = )(.+)(;)/\1\"${version_without_snapshot}\"\3/" src/main/java/net/snowflake/client/jdbc/SnowflakeDriver.java > $tmp_file_with_version +mv $tmp_file_with_version $file_with_version + +# add changelog entry but only when releasing version without snapshot +if [[ "$version" == "$version_without_snapshot" ]]; then + changelog_file=CHANGELOG.rst + tmp_changelog_file=${changelog_file}.bck + echo "**JDBC Driver ${version}**" > $tmp_changelog_file + echo "" >> $tmp_changelog_file + echo "- \||Please Refer to Release Notes at https://docs.snowflake.com/en/release-notes/clients-drivers/jdbc" >> $tmp_changelog_file + echo "" >> $tmp_changelog_file + cat $changelog_file >> $tmp_changelog_file + mv $tmp_changelog_file $changelog_file +fi