Skip to content

Commit b4c162d

Browse files
fix: version-bump script fix (#546)
## Description This pull request improves the version bump script making it more robust for future registry changes. <!-- Briefly describe what this PR does and why --> ## 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 <!-- Link related issues or write "None" if not applicable --> #510
1 parent e58fd5d commit b4c162d

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

.github/scripts/version-bump.sh

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,38 @@ update_readme_version() {
7070
if grep -q "source.*${module_source}" "$readme_path"; then
7171
echo "Updating version references for $namespace/$module_name in $readme_path"
7272
awk -v module_source="$module_source" -v new_version="$new_version" '
73-
/source.*=.*/ {
74-
if ($0 ~ module_source) {
75-
in_target_module = 1
76-
} else {
77-
in_target_module = 0
78-
}
73+
/^[[:space:]]*module[[:space:]]/ {
74+
in_module_block = 1
75+
module_content = $0 "\n"
76+
module_has_target_source = 0
77+
next
7978
}
80-
/^[[:space:]]*version[[:space:]]*=/ {
81-
if (in_target_module) {
82-
match($0, /^[[:space]]*/
83-
indent = substr($0, 1, RLENGTH)
84-
print indent "version = \"" new_version "\""
85-
in_target_module = 0
79+
in_module_block {
80+
module_content = module_content $0 "\n"
81+
if ($0 ~ /source.*=/ && $0 ~ module_source) {
82+
module_has_target_source = 1
83+
}
84+
if ($0 ~ /^[[:space:]]*}[[:space:]]*$/) {
85+
in_module_block = 0
86+
if (module_has_target_source) {
87+
num_lines = split(module_content, lines, "\n")
88+
for (i = 1; i <= num_lines; i++) {
89+
line = lines[i]
90+
if (line ~ /^[[:space:]]*version[[:space:]]*=/) {
91+
match(line, /^[[:space:]]*/)
92+
indent = substr(line, 1, RLENGTH)
93+
printf "%sversion = \"%s\"\n", indent, new_version
94+
} else {
95+
print line
96+
}
97+
}
98+
} else {
99+
printf "%s", module_content
100+
}
101+
module_content = ""
86102
next
87103
}
104+
next
88105
}
89106
{ print }
90107
' "$readme_path" > "${readme_path}.tmp" && mv "${readme_path}.tmp" "$readme_path"

0 commit comments

Comments
 (0)