feat: add rainix-rs-autopublish reusable workflow#178
Conversation
Generic autopublish-on-push-to-main for pure-Rust crates. Parametrized by the crate name. Consumers call it with a thin wrapper that passes inputs.crate and secrets: inherit. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Warning Review limit reached
Your plan currently allows 1 review/hour. Refill in 33 minutes and 39 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA new GitHub Actions reusable workflow for Rust crates automatically publishes to crates.io when packaged content changes. It validates with ChangesRust Crate Auto-Publishing Workflow
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/rainix-rs-autopublish.yaml:
- Around line 69-71: The tag naming currently uses only env.CARGO_VERSION which
will collide across crates; update the tagging to include a crate identifier
(e.g., use an existing env like CARGO_CRATE or CRATE_NAME or derive from Cargo
metadata) so the tag becomes crateName-${{ env.CARGO_VERSION }} and update the
corresponding release/push steps to use that same combined tag variable (ensure
the git tag, git push origin HEAD and git push origin --tags / release creation
all reference the new composite tag variable).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3ecf95aa-8b54-4e8f-a0fc-1ab24f341c02
📒 Files selected for processing (1)
.github/workflows/rainix-rs-autopublish.yaml
| NEW=$(nix develop github:rainlanguage/rainix#rust-shell -c cargo package -p ${{ inputs.crate }} --allow-dirty --quiet --list | LC_ALL=C sort | sha256sum | cut -d' ' -f1) | ||
| OLD_VERSION=$(curl -fsSL "https://crates.io/api/v1/crates/${{ inputs.crate }}" | python3 -c "import sys, json; print(json.load(sys.stdin)['crate']['max_version'])" 2>/dev/null || echo "none") | ||
| if [ "$OLD_VERSION" = "none" ]; then | ||
| OLD="none" | ||
| else | ||
| curl -fsSL "https://crates.io/api/v1/crates/${{ inputs.crate }}/$OLD_VERSION/download" -o /tmp/old.crate | ||
| OLD=$(tar -tzf /tmp/old.crate 2>/dev/null | LC_ALL=C sort | sha256sum | cut -d' ' -f1) |
There was a problem hiding this comment.
Hash comparison will always show changes due to path format mismatch.
cargo package --list outputs relative paths like Cargo.toml, src/lib.rs, while tar -tzf outputs prefixed paths like crate-name-0.1.0/Cargo.toml. These will never match, causing changed to always be true and triggering a publish on every run.
Additionally, this compares only file lists, not file contents—content-only changes won't be detected once the path issue is fixed.
🐛 Proposed fix: strip the prefix from tar output
if [ "$OLD_VERSION" = "none" ]; then
OLD="none"
else
curl -fsSL "https://crates.io/api/v1/crates/${{ inputs.crate }}/$OLD_VERSION/download" -o /tmp/old.crate
- OLD=$(tar -tzf /tmp/old.crate 2>/dev/null | LC_ALL=C sort | sha256sum | cut -d' ' -f1)
+ OLD=$(tar -tzf /tmp/old.crate 2>/dev/null | sed 's|^[^/]*/||' | LC_ALL=C sort | sha256sum | cut -d' ' -f1)
fiTo also detect content changes, consider hashing the tarball content itself or extracting and hashing file contents rather than just the file list.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| NEW=$(nix develop github:rainlanguage/rainix#rust-shell -c cargo package -p ${{ inputs.crate }} --allow-dirty --quiet --list | LC_ALL=C sort | sha256sum | cut -d' ' -f1) | |
| OLD_VERSION=$(curl -fsSL "https://crates.io/api/v1/crates/${{ inputs.crate }}" | python3 -c "import sys, json; print(json.load(sys.stdin)['crate']['max_version'])" 2>/dev/null || echo "none") | |
| if [ "$OLD_VERSION" = "none" ]; then | |
| OLD="none" | |
| else | |
| curl -fsSL "https://crates.io/api/v1/crates/${{ inputs.crate }}/$OLD_VERSION/download" -o /tmp/old.crate | |
| OLD=$(tar -tzf /tmp/old.crate 2>/dev/null | LC_ALL=C sort | sha256sum | cut -d' ' -f1) | |
| if [ "$OLD_VERSION" = "none" ]; then | |
| OLD="none" | |
| else | |
| curl -fsSL "https://crates.io/api/v1/crates/${{ inputs.crate }}/$OLD_VERSION/download" -o /tmp/old.crate | |
| OLD=$(tar -tzf /tmp/old.crate 2>/dev/null | sed 's|^[^/]*/||' | LC_ALL=C sort | sha256sum | cut -d' ' -f1) |
|
@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment: S/M/L PR Classification Guidelines:This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed. Small (S)Characteristics:
Review Effort: Would have taken 5-10 minutes Examples:
Medium (M)Characteristics:
Review Effort: Would have taken 15-30 minutes Examples:
Large (L)Characteristics:
Review Effort: Would have taken 45+ minutes Examples:
Additional Factors to ConsiderWhen deciding between sizes, also consider:
Notes:
|
|
Tip For best results, initiate chat on the files or code changes. SIZE=M |
Generic autopublish-on-push-to-main for pure-Rust crates. Parametrized only by crate name (inputs.crate). Consumers wire it in via a thin caller with secrets: inherit.
First consumer: rain.erc. rain.math.float keeps its own due to the NPM half.
Summary by CodeRabbit