Skip to content

fix(tools): respect manual major version bumps in go.mod#1217

Open
Iam-Karan-Suresh wants to merge 1 commit into
fluxcd:mainfrom
Iam-Karan-Suresh:fix/module-bump-semver-check
Open

fix(tools): respect manual major version bumps in go.mod#1217
Iam-Karan-Suresh wants to merge 1 commit into
fluxcd:mainfrom
Iam-Karan-Suresh:fix/module-bump-semver-check

Conversation

@Iam-Karan-Suresh
Copy link
Copy Markdown
Contributor

fix(tools): respect manual major version bumps in go.mod

Previously, the release tool computed module version bumps and blindly
replaced existing versions in go.mod files using regex. This caused
manual major version bumps (e.g., v1.0.0) to be incorrectly downgraded
to computed minor bumps (e.g., v0.18.0), resulting in false-positive
modifications that blocked the release process.

This commit updates the apply function in module_bump.go to:

  • Extract the existing version string from the target go.mod file.
  • Parse both the existing and computed versions using semver.
  • Dynamically adopt the existing version if it is mathematically
    greater than the internally computed version.

Fixes #1172

@Iam-Karan-Suresh Iam-Karan-Suresh requested a review from a team as a code owner May 25, 2026 02:32
@Iam-Karan-Suresh Iam-Karan-Suresh force-pushed the fix/module-bump-semver-check branch 2 times, most recently from 53376ca to 4cdc4c3 Compare May 25, 2026 02:46
Comment thread cmd/internal/module_bump.go Outdated
return false, nil
}
// Extract current version from the go.mod line and compare with the computed new version.
matches := m.regex.FindStringSubmatch(oldContent)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why match twice? This call could replace the one right above, and if len(matches) == 0 we return false, nil

Signed-off-by: iam-karan-suresh <karansuresh.info@gmail.com>
@Iam-Karan-Suresh Iam-Karan-Suresh force-pushed the fix/module-bump-semver-check branch from 4cdc4c3 to 7e60c80 Compare May 25, 2026 08:07
if len(matches) == 0 {
return false, nil
}
if len(matches) > 1 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can len(matches) == 1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve make release to support major version bumps

2 participants