Skip to content

Update README compatibility table when new release branch is created #412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 1, 2025
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
45 changes: 45 additions & 0 deletions scripts/bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,48 @@ PLUGIN_GRADLE_FILEPATH="sentry-kotlin-multiplatform-gradle-plugin/gradle.propert
VERSION_NAME_PATTERN="versionName"
perl -pi -e "s/$VERSION_NAME_PATTERN=.*$/$VERSION_NAME_PATTERN=$NEW_VERSION/g" $GRADLE_FILEPATH
perl -pi -e "s/$VERSION_NAME_PATTERN=.*$/$VERSION_NAME_PATTERN=$NEW_VERSION/g" $PLUGIN_GRADLE_FILEPATH

PODSPEC_FILEPATH='sentry-kotlin-multiplatform/sentry_kotlin_multiplatform.podspec'
PODSPEC_CONTENT=$(cat $PODSPEC_FILEPATH)

PODSPEC_REGEX="('Sentry', *)'([0-9\.]+)'"

if ! [[ $PODSPEC_CONTENT =~ $PODSPEC_REGEX ]]; then
echo "Failed to find the Cocoa version in $PODSPEC_FILEPATH"
exit 1
fi

PODSPEC_WHOLE_MATCH=${BASH_REMATCH[0]}
PODSPEC_VAR_NAME=${BASH_REMATCH[1]}
PODSPEC_VERSION=${BASH_REMATCH[2]}

# create a new table entry in readme with NEW_VERSION and PODSPEC_VERSION in the compatibility table
# Find the line number of the last entry in the compatibility table and insert the new entry after it
README_FILE="README.md"

# Check if an entry with the same KMP version and Cocoa version already exists
EXISTING_ENTRY=$(grep "| $NEW_VERSION" $README_FILE 2>/dev/null | grep "$PODSPEC_VERSION" 2>/dev/null || true)

if [ -n "$EXISTING_ENTRY" ]; then
echo "Found same KMP and Cocoaversion in the compatibility table. Skipping addition to avoid duplicate."
exit 0
fi

# We'll look for the last line that matches the table entry pattern (starts with | and contains version numbers)
LAST_TABLE_LINE=$(grep -n "^| [0-9]" $README_FILE | tail -1 | cut -d: -f1)

if [ -z "$LAST_TABLE_LINE" ]; then
echo "Could not find the last entry in the compatibility table"
exit 1
fi

TEMP_FILE=$(mktemp)

head -n $LAST_TABLE_LINE $README_FILE > $TEMP_FILE
echo "| $NEW_VERSION | $PODSPEC_VERSION |" >> $TEMP_FILE
tail -n +$((LAST_TABLE_LINE + 1)) $README_FILE >> $TEMP_FILE

# Replace the original file with the modified content
mv $TEMP_FILE $README_FILE

echo "Added new compatibility table entry: | $NEW_VERSION | $PODSPEC_VERSION |"
Loading