Skip to content

Commit

Permalink
chore: script updates for sdk version
Browse files Browse the repository at this point in the history
  • Loading branch information
mrehan27 committed Nov 12, 2024
1 parent a050e25 commit e7e96eb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"assets": [
"CHANGELOG.md",
"pubspec.yaml",
"lib/customer_io_plugin_version.dart"
"lib/customer_io_plugin_version.dart",
"android/src/main/res/values/customer_io_config.xml"
],
"message": "chore: prepare for ${nextRelease.version}\n\n${nextRelease.notes}"
}
Expand Down
20 changes: 0 additions & 20 deletions scripts/update-plugin.sh

This file was deleted.

38 changes: 32 additions & 6 deletions scripts/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,38 @@ set -e

NEW_VERSION="$1"

echo "Updating files to new version: $NEW_VERSION"
echo "Starting version update to: $NEW_VERSION"

echo "Updating pubspec.yaml"
sd 'version: (.*)' "version: $NEW_VERSION" pubspec.yaml
# Helper function to update version in a file and display the diff
update_version_in_file() {
# Parameters:
# $1: file_path: The path to the file to update
# $2: pattern: The regex pattern to match the line to update
# $3: replacement: The new version to replace the matched line with
local file_path=$1
local pattern=$2
local replacement=$3

echo "Check file, you should see version inside has been updated!"
echo -e "\nUpdating version in $file_path..."
sd "$pattern" "$replacement" "$file_path"

echo "Now, updating plugin...."
./scripts/update-plugin.sh "$NEW_VERSION"
echo "Done! Showing changes in $file_path:"
git diff "$file_path"
}

# Update version in pubspec.yaml
# Given line: `version: 1.3.5`
# Note: We are using ^ to match the start of the line to avoid matching other lines with version in them.
# e.g. `native_sdk_version: 3.5.7` should not be matched by this regex.
update_version_in_file "pubspec.yaml" "^(version: .*)" "version: $NEW_VERSION"

# Update version in customer_io_plugin_version.dart
# Given line: `const version = "1.3.5";`
update_version_in_file "./lib/customer_io_plugin_version.dart" "const version = \"(.*)\"" "const version = \"$NEW_VERSION\""

# Update version in customer_io_config.xml
SDK_CONFIG_CLIENT_VERSION_KEY="customer_io_wrapper_sdk_client_version"
# Given line: `<string name="customer_io_wrapper_sdk_client_version">1.3.5</string>`
update_version_in_file "android/src/main/res/values/customer_io_config.xml" "<string name=\"$SDK_CONFIG_CLIENT_VERSION_KEY\">.*</string>" "<string name=\"$SDK_CONFIG_CLIENT_VERSION_KEY\">$NEW_VERSION</string>"

echo -e "\nVersion update complete for targeted files."

0 comments on commit e7e96eb

Please sign in to comment.