fix: sync Cargo.toml version with changesets#7
Conversation
🦋 Changeset detectedLatest commit: 8f9d855 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue in the release workflow where Highlights
Changelog
Ignored Files
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to synchronize the version between package.json and Cargo.toml, which is a great improvement for the release process. I've added a couple of suggestions to make the new scripts more robust and the CI logs clearer. One suggestion is to simplify the Cargo.lock generation command in version-sync.sh to improve error handling. The other is to refine the error message in the tag-release script in package.json to avoid confusion during CI failures.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a robust solution for synchronizing versions between package.json and Cargo.toml within a Changesets-based release workflow. The addition of version-sync.sh and tag-release.sh scripts is a great improvement for automating the release process and ensuring consistency. My review includes a couple of suggestions to further improve the robustness of these new scripts. Specifically, I recommend using annotated git tags for better release tracking and making the version-parsing logic in the sync script more flexible.
| fi | ||
|
|
||
| echo "Creating tag $TAG" | ||
| git tag "$TAG" |
There was a problem hiding this comment.
| awk -v ver="$VERSION" ' | ||
| /^\[package\]/ { in_pkg=1 } | ||
| /^\[/ && !/^\[package\]/ { in_pkg=0 } | ||
| in_pkg && /^version = / { $0 = "version = \"" ver "\"" } |
There was a problem hiding this comment.
The awk pattern to find the version line is a bit strict as it assumes a single space around the = character. To make the script more robust against potential formatting changes in Cargo.toml, it's better to allow for any amount of whitespace around the equals sign.
| in_pkg && /^version = / { $0 = "version = \"" ver "\"" } | |
| in_pkg && /^version[ \t]*=[ \t]*/ { $0 = "version = \"" ver "\"" } |
Problem
Changesets bumps
package.jsonbut notCargo.toml. When the tag is created, cargo-dist fails because the version inCargo.tomldoesn't match the tag.Additionally,
changeset tagsilently skipsprivate: truepackages, so no git tag was ever created.Fix
scripts/version-sync.sh— Custom version command that runschangeset version, then syncs the resulting version intoCargo.toml(viaawk) and regeneratesCargo.lockrelease-changesets.yml— Usesversion: pnpm run version-syncso the changeset version PR includesCargo.toml+Cargo.lockchanges. Adds Rust toolchain for lockfile generation.tag-releasescript — Replaceschangeset tagwith a custom script that creates and pushes av{version}git tag. Now idempotent (won't fail if tag already exists).Cargo.tomlfrom0.1.0→0.1.1to match currentpackage.json.Flow after this PR