@@ -52,8 +52,14 @@ read_current_version() {
5252 if [[ " $VERSION_STYLE " == " python" ]]; then
5353 CURRENT_VERSION=$( grep -o -E " (0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-dev[0-9]*)?" " $VERSION_FILE " | head -1)
5454 elif [[ " $VERSION_STYLE " == " pyproject" ]]; then
55- # Extract version from pyproject.toml (handles both quoted styles)
56- CURRENT_VERSION=$( grep -E " ^version\s*=" " $VERSION_FILE " | head -1 | sed -E ' s/version\s*=\s*["\x27]?([^"\x27]+)["\x27]?/\1/' | tr -d ' ' )
55+ # Extract version from pyproject.toml (detect quote style for portability)
56+ if grep -qE " ^version\s*=\s*\" " " $VERSION_FILE " ; then
57+ # Double quotes - match and discard trailing content (comments, etc)
58+ CURRENT_VERSION=$( grep -E " ^version\s*=" " $VERSION_FILE " | head -1 | sed -E ' s/version\s*=\s*"([^"]+)".*/\1/' | tr -d ' ' )
59+ else
60+ # Single quotes (portable - avoid \x27 which breaks on BSD sed)
61+ CURRENT_VERSION=$( grep -E " ^version\s*=" " $VERSION_FILE " | head -1 | sed -E " s/version\s*=\s*'([^']+)'.*/\1/" | tr -d ' ' )
62+ fi
5763 fi
5864 echo " Current version: $CURRENT_VERSION "
5965}
@@ -182,11 +188,22 @@ detect_changed_packages() {
182188 if [ " $PACKAGE_COUNT " -gt 5 ]; then
183189 echo " ... and $(( PACKAGE_COUNT - 5 )) more"
184190 fi
191+
192+ # Build specific changelog entry with package names
193+ if [ " $PACKAGE_COUNT " -eq 1 ]; then
194+ PACKAGE_NAME=$( echo " $CHANGED_PACKAGES " | head -1 | cut -d' =' -f1)
195+ CHANGELOG_ENTRY=" - **Security update**: Updated \` ${PACKAGE_NAME} \` to address security vulnerability"
196+ elif [ " $PACKAGE_COUNT " -le 3 ]; then
197+ PACKAGE_NAMES=$( echo " $CHANGED_PACKAGES " | cut -d' =' -f1 | paste -sd, - | sed ' s/,/, /g' | sed ' s/\([^,]*\)/`\1`/g' )
198+ CHANGELOG_ENTRY=" - **Security update**: Updated ${PACKAGE_NAMES} to address security vulnerabilities"
199+ else
200+ CHANGELOG_ENTRY=" - **Security update**: Updated ${PACKAGE_COUNT} dependencies to address security vulnerabilities"
201+ fi
185202 else
186203 echo " Could not auto-detect packages, using generic entry"
204+ CHANGELOG_ENTRY=" - **Security update**: Bumped dependencies to address security vulnerabilities"
187205 fi
188206
189- CHANGELOG_ENTRY=" - **Security update**: Bumped dependencies to address security vulnerabilities"
190207 echo " Changelog entry: $CHANGELOG_ENTRY "
191208}
192209
@@ -202,8 +219,10 @@ update_changelog() {
202219
203220 # Only look for -dev version to rename if CURRENT_VERSION had -dev suffix
204221 if [[ -n " ${DEV_SUFFIX:- } " ]]; then
205- # Look for -dev version header in CHANGELOG that matches our version
206- DEV_VERSION_HEADER=$( grep -m 1 -F " ## $CURRENT_VERSION " " $CHANGELOG_FILE " || true)
222+ # Look for -dev version header in CHANGELOG that matches our version exactly (not substring)
223+ # Escape dots for regex, then match with end-of-line or whitespace anchor
224+ ESCAPED_VERSION=" ${CURRENT_VERSION// ./ \\ .} "
225+ DEV_VERSION_HEADER=$( grep -m 1 -E " ^## ${ESCAPED_VERSION} (\s*$)" " $CHANGELOG_FILE " || true)
207226
208227 if [[ -n " $DEV_VERSION_HEADER " ]]; then
209228 echo " Found dev version in CHANGELOG: $DEV_VERSION_HEADER "
0 commit comments