Skip to content

Commit

Permalink
Merge pull request #245 from prometheus/superq/fixup_major
Browse files Browse the repository at this point in the history
Fix builder-bumper major version bump
  • Loading branch information
SuperQ authored Feb 14, 2024
2 parents f77765f + c51441d commit 6571a53
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions cmd/builder-bumper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ func shaReplacer(old, new *goVersion) func(string) (string, error) {
}
}

func majorVersionReplacer(old, new *goVersion) func(string) (string, error) {
func majorVersionReplacer(prefix string, old, new *goVersion) func(string) (string, error) {
return func(out string) (string, error) {
return strings.ReplaceAll(out, old.Major(), new.Major()), nil
return strings.ReplaceAll(out, prefix+old.Major(), prefix+new.Major()), nil
}
}

Expand Down Expand Up @@ -241,14 +241,15 @@ func replaceMajor(old, current, next *goVersion) error {
return replace(path,
[]func(string) (string, error){
golangVersionReplacer("GOLANG_VERSION ", old, next),
majorVersionReplacer("quay.io/prometheus/golang-builder:", old, next),
shaReplacer(old, next),
},
)
}
return replace(path,
[]func(string) (string, error){
golangVersionReplacer("", old, next),
majorVersionReplacer(old, next),
majorVersionReplacer("", old, next),
},
)
})
Expand All @@ -262,8 +263,8 @@ func replaceMajor(old, current, next *goVersion) error {
// Update CircleCI.
err = replace(".circleci/config.yml",
[]func(string) (string, error){
majorVersionReplacer(current, next),
majorVersionReplacer(old, current),
majorVersionReplacer("", current, next),
majorVersionReplacer("", old, current),
},
)
if err != nil {
Expand All @@ -273,8 +274,8 @@ func replaceMajor(old, current, next *goVersion) error {
// Update Makefile.
err = replace("Makefile",
[]func(string) (string, error){
majorVersionReplacer(current, next),
majorVersionReplacer(old, current),
majorVersionReplacer("", current, next),
majorVersionReplacer("", old, current),
},
)
if err != nil {
Expand All @@ -285,9 +286,9 @@ func replaceMajor(old, current, next *goVersion) error {
return replace("README.md",
[]func(string) (string, error){
fullVersionReplacer(current, next),
majorVersionReplacer(current, next),
majorVersionReplacer("", current, next),
fullVersionReplacer(old, current),
majorVersionReplacer(old, current),
majorVersionReplacer("", old, current),
},
)
}
Expand Down

0 comments on commit 6571a53

Please sign in to comment.