From b4c162d2811b3d1678f0762bc246c3e6b9796078 Mon Sep 17 00:00:00 2001 From: DevCats Date: Thu, 20 Nov 2025 09:07:34 -0500 Subject: [PATCH] fix: version-bump script fix (#546) ## Description This pull request improves the version bump script making it more robust for future registry changes. ## 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 https://github.com/coder/registry/issues/510 --- .github/scripts/version-bump.sh | 41 +++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/.github/scripts/version-bump.sh b/.github/scripts/version-bump.sh index 6af3eca2..f84a7f89 100755 --- a/.github/scripts/version-bump.sh +++ b/.github/scripts/version-bump.sh @@ -70,21 +70,38 @@ update_readme_version() { if grep -q "source.*${module_source}" "$readme_path"; then echo "Updating version references for $namespace/$module_name in $readme_path" awk -v module_source="$module_source" -v new_version="$new_version" ' - /source.*=.*/ { - if ($0 ~ module_source) { - in_target_module = 1 - } else { - in_target_module = 0 - } + /^[[:space:]]*module[[:space:]]/ { + in_module_block = 1 + module_content = $0 "\n" + module_has_target_source = 0 + next } - /^[[:space:]]*version[[:space:]]*=/ { - if (in_target_module) { - match($0, /^[[:space]]*/ - indent = substr($0, 1, RLENGTH) - print indent "version = \"" new_version "\"" - in_target_module = 0 + in_module_block { + module_content = module_content $0 "\n" + if ($0 ~ /source.*=/ && $0 ~ module_source) { + module_has_target_source = 1 + } + if ($0 ~ /^[[:space:]]*}[[:space:]]*$/) { + in_module_block = 0 + if (module_has_target_source) { + num_lines = split(module_content, lines, "\n") + for (i = 1; i <= num_lines; i++) { + line = lines[i] + if (line ~ /^[[:space:]]*version[[:space:]]*=/) { + match(line, /^[[:space:]]*/) + indent = substr(line, 1, RLENGTH) + printf "%sversion = \"%s\"\n", indent, new_version + } else { + print line + } + } + } else { + printf "%s", module_content + } + module_content = "" next } + next } { print } ' "$readme_path" > "${readme_path}.tmp" && mv "${readme_path}.tmp" "$readme_path"