Skip to content

Replace bump-version.sh with pure-Go go:generate tool#3272

Merged
masih merged 9 commits into
mainfrom
masih/bump-version-with-less-thorns-and-more-gravy
May 4, 2026
Merged

Replace bump-version.sh with pure-Go go:generate tool#3272
masih merged 9 commits into
mainfrom
masih/bump-version-with-less-thorns-and-more-gravy

Conversation

@masih

@masih masih commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator

Introduce scripts/bump_version, a combined archival + code-generation tool that replaces the three shell scripts (bump-version.sh, generate-precompile-setup.sh, generate-all-precompiles-setup.sh).

New developer workflow:

  1. Commit precompile code changes
  2. Append a new upgrade name (vMajor.Minor) to app/tags
  3. Run go generate ./...

What the tool does on each run:

  • Validates the latest entry in app/tags (must be vMajor.Minor; patch is dropped with a warning; duplicate or regressed versions are errors)
  • Validates each module's versions file (valid semver, no duplicates)
  • Uses go-git (pure Go, no os/exec) to find the commit that introduced the previous upgrade version, then diffs per-module tree hashes against HEAD to determine which precompile modules actually changed
  • Archives changed modules into precompiles//legacy// with package/import rewrites; archives common/ when it changed (triggers all)
  • Fails hard on git errors (matching old bump-version.sh set -e behavior) rather than silently falling back to archiving everything
  • Regenerates precompiles//setup.go from a text/template (.go.tmpl) for every module with a versions file, formatted via go/format
  • Is idempotent: skips archival if precompiles/common/legacy// exists

Naming conventions enforced:
app/tags / versions keys: vMajor.Minor (e.g. v7.0) legacy folder / package: vMajorMinor (e.g. v70) -- Idropped the zero at the end given v6.5 was generated with that pattern before I could land this PR.

All generated .go files carry a "Code generated by scripts/bump_version; DO NOT EDIT." header. Added go-git/v5 as the sole new dependency.

Introduce scripts/bump_version, a combined archival + code-generation tool
that replaces the three shell scripts (bump-version.sh,
generate-precompile-setup.sh, generate-all-precompiles-setup.sh).

New developer workflow:
  1. Commit precompile code changes
  2. Append a new upgrade name (vMajor.Minor) to app/tags
  3. Run go generate ./...

What the tool does on each run:
- Validates the latest entry in app/tags (must be vMajor.Minor; patch is
  dropped with a warning; duplicate or regressed versions are errors)
- Validates each module's versions file (valid semver, no duplicates)
- Uses go-git (pure Go, no os/exec) to find the commit that introduced the
  previous upgrade version, then diffs per-module tree hashes against HEAD to
  determine which precompile modules actually changed
- Archives changed modules into precompiles/<module>/legacy/<folder>/ with
  package/import rewrites; archives common/ when it changed (triggers all)
- Fails hard on git errors (matching old bump-version.sh set -e behavior)
  rather than silently falling back to archiving everything
- Regenerates precompiles/<module>/setup.go from a text/template (.go.tmpl)
  for every module with a versions file, formatted via go/format
- Is idempotent: skips archival if precompiles/common/legacy/<folder>/ exists

Naming conventions enforced:
  app/tags / versions keys: vMajor.Minor  (e.g. v7.0)
  legacy folder / package:  vMajorMinor0  (e.g. v700)

All generated .go files carry a "Code generated by scripts/bump_version;
DO NOT EDIT." header. Added go-git/v5 as the sole new dependency.
@github-actions

github-actions Bot commented Apr 20, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMay 4, 2026, 6:06 AM

@codecov

codecov Bot commented Apr 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 323 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.15%. Comparing base (b0712df) to head (f3955b8).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
scripts/bump_version/main.go 0.00% 323 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3272      +/-   ##
==========================================
- Coverage   59.17%   59.15%   -0.03%     
==========================================
  Files        2097     2072      -25     
  Lines      172645   169873    -2772     
==========================================
- Hits       102170   100488    -1682     
+ Misses      61613    60622     -991     
+ Partials     8862     8763      -99     
Flag Coverage Δ
sei-chain-pr 62.95% <0.00%> (?)
sei-db 70.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
precompiles/addr/setup.go 90.47% <ø> (ø)
precompiles/bank/setup.go 90.47% <ø> (ø)
precompiles/distribution/setup.go 88.88% <ø> (ø)
precompiles/gov/setup.go 88.88% <ø> (ø)
precompiles/ibc/setup.go 90.00% <ø> (ø)
precompiles/json/setup.go 88.88% <ø> (ø)
precompiles/oracle/setup.go 90.00% <ø> (ø)
precompiles/p256/setup.go 83.33% <ø> (ø)
precompiles/pointer/setup.go 90.00% <ø> (ø)
precompiles/pointerview/setup.go 88.23% <ø> (ø)
... and 4 more

... and 151 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@masih masih marked this pull request as ready for review May 1, 2026 14:18
@masih masih requested review from arajasek and philipsu522 May 1, 2026 14:18

@philipsu522 philipsu522 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

awesome, so much cleaner. a minor follow up question: does it make sense to run this in ci somehow? i.e. all we need to do is echo "v7.0" >> app/tags and the artifacts are autogenerated?

@masih

masih commented May 1, 2026

Copy link
Copy Markdown
Collaborator Author

does it make sense to run this in ci somehow? i.e. all we need to do is echo "v7.0" >> app/tags and the artifacts are autogenerated?

As in doing the pre-complie generation itself, right? Totally; We can have a workflow like this:

  • When it is "Release Time", open a PR and add the new upgrade name line to tags
  • There would then be a CI job that gets triggered by changes to tags file, does the go generate ./... and pushes the changes to your PR for you. @seidroid can be the agent.

Will Captured an issue for this; would make a nice cherry on top. 🍰

@masih masih enabled auto-merge May 4, 2026 06:05
@masih masih added this pull request to the merge queue May 4, 2026
Merged via the queue into main with commit fd5d9f6 May 4, 2026
38 checks passed
@masih masih deleted the masih/bump-version-with-less-thorns-and-more-gravy branch May 4, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants