From 925c71e6410d98a88e66e2924e2989257c90f732 Mon Sep 17 00:00:00 2001 From: DevCats Date: Fri, 31 Oct 2025 07:45:52 -0500 Subject: [PATCH] fix: improve version extraction logic to prevent false positives (#511) ## Description Makes the version extract and replace logic more specific so it wont replace any field that does is not specifically `field` under the detected modules. ## Type of Change - [ ] New module - [ ] New template - [X] Bug fix - [ ] Feature/enhancement - [ ] Documentation - [ ] Other ## Testing & Validation - [X] Tests pass (`bun test`) - [X] Code formatted (`bun fmt`) - [X] Changes tested locally ## Related Issues #510 --------- Co-authored-by: Atif Ali --- .github/scripts/version-bump.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/scripts/version-bump.sh b/.github/scripts/version-bump.sh index fc316619..6af3eca2 100755 --- a/.github/scripts/version-bump.sh +++ b/.github/scripts/version-bump.sh @@ -77,16 +77,19 @@ update_readme_version() { in_target_module = 0 } } - /version.*=.*"/ { + /^[[:space:]]*version[[:space:]]*=/ { if (in_target_module) { - gsub(/version[[:space:]]*=[[:space:]]*"[^"]*"/, "version = \"" new_version "\"") + match($0, /^[[:space]]*/ + indent = substr($0, 1, RLENGTH) + print indent "version = \"" new_version "\"" in_target_module = 0 + next } } { print } ' "$readme_path" > "${readme_path}.tmp" && mv "${readme_path}.tmp" "$readme_path" return 0 - elif grep -q 'version\s*=\s*"' "$readme_path"; then + elif grep -q '^[[:space:]]*version[[:space:]]*=' "$readme_path"; then echo "⚠️ Found version references but no module source match for $namespace/$module_name" return 1 fi @@ -148,9 +151,9 @@ main() { local current_version if [ -z "$latest_tag" ]; then - if [ -f "$readme_path" ] && grep -q 'version\s*=\s*"' "$readme_path"; then + if [ -f "$readme_path" ] && grep -q '^[[:space:]]*version[[:space:]]*=' "$readme_path"; then local readme_version - readme_version=$(grep 'version\s*=\s*"' "$readme_path" | head -1 | sed 's/.*version\s*=\s*"\([^"]*\)".*/\1/') + readme_version=$(awk '/^[[:space:]]*version[[:space:]]*=/ { match($0, /"[^"]*"/); print substr($0, RSTART+1, RLENGTH-2); exit }' "$readme_path") echo "No git tag found, but README shows version: $readme_version" if ! validate_version "$readme_version"; then