@@ -22,7 +22,7 @@ echo "=== Renovate Security Version Bump ==="
2222detect_version_style () {
2323 if [[ " $VERSION_FILE " == " auto" ]]; then
2424 # Check for pyproject.toml with version field first (modern style)
25- if [[ -f " $REPO_ROOT /pyproject.toml" ]] && grep -q " ^version\s*=" " $REPO_ROOT /pyproject.toml" ; then
25+ if [[ -f " $REPO_ROOT /pyproject.toml" ]] && grep -qE " ^version\s*=" " $REPO_ROOT /pyproject.toml" ; then
2626 VERSION_FILE=" $REPO_ROOT /pyproject.toml"
2727 VERSION_STYLE=" pyproject"
2828 echo " Auto-detected: pyproject.toml versioning"
@@ -50,7 +50,7 @@ detect_version_style() {
5050# Read current version based on style
5151read_current_version () {
5252 if [[ " $VERSION_STYLE " == " python" ]]; then
53- 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 " )
53+ 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
5555 # Extract version from pyproject.toml (handles both quoted styles)
5656 CURRENT_VERSION=$( grep -E " ^version\s*=" " $VERSION_FILE " | head -1 | sed -E ' s/version\s*=\s*["\x27]?([^"\x27]+)["\x27]?/\1/' | tr -d ' ' )
@@ -60,7 +60,7 @@ read_current_version() {
6060
6161# Calculate new release version
6262calculate_release_version () {
63- if [[ " $CURRENT_VERSION " =~ ^([0-9]+)\. ([0-9]+)\. ([0-9]+)(-dev. * )? $ ]]; then
63+ if [[ " $CURRENT_VERSION " =~ ^([0-9]+)\. ([0-9]+)\. ([0-9]+)(-dev[0-9] * )? $ ]]; then
6464 MAJOR=" ${BASH_REMATCH[1]} "
6565 MINOR=" ${BASH_REMATCH[2]} "
6666 PATCH=" ${BASH_REMATCH[3]} "
@@ -119,7 +119,7 @@ update_pyproject_version() {
119119 sed -i.bak -E " s/^(version\s*=\s*)\" [^\" ]+\" /\1\" $RELEASE_VERSION \" /" " $VERSION_FILE "
120120 else
121121 # Single quotes
122- sed -i.bak -E " s/^(version\s*=\s*)'[^']+'$ /\1'$RELEASE_VERSION '/" " $VERSION_FILE "
122+ sed -i.bak -E " s/^(version\s*=\s*)'[^']+'/\1'$RELEASE_VERSION '/" " $VERSION_FILE "
123123 fi
124124
125125 # Verify the update succeeded
@@ -223,7 +223,7 @@ update_changelog() {
223223 }
224224
225225 /^## / {
226- if ($0 ~ "^ ## " dev_version) {
226+ if (index($0, " ## " dev_version) == 1 ) {
227227 print "## " release_version
228228 in_target_version = 1
229229 next
@@ -273,17 +273,20 @@ update_changelog() {
273273create_new_changelog_entry () {
274274 echo " Creating new CHANGELOG entry for $RELEASE_VERSION "
275275
276- cat > /tmp/new_changelog_section.tmp << EOF
276+ local tmp_file
277+ tmp_file=$( mktemp)
278+
279+ cat > " $tmp_file " << EOF
277280## $RELEASE_VERSION
278281
279282### Fixes
280283$CHANGELOG_ENTRY
281284
282285EOF
283286
284- cat /tmp/new_changelog_section.tmp " $CHANGELOG_FILE " > " $CHANGELOG_FILE .tmp"
287+ cat " $tmp_file " " $CHANGELOG_FILE " > " $CHANGELOG_FILE .tmp"
285288 mv " $CHANGELOG_FILE .tmp" " $CHANGELOG_FILE "
286- rm -f /tmp/new_changelog_section.tmp
289+ rm -f " $tmp_file "
287290}
288291
289292# Main execution
0 commit comments