mirror of
https://github.com/coder/registry.git
synced 2026-06-02 20:48:14 +00:00
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 --> https://github.com/coder/registry/issues/510
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user