Fix crates.io publish detection - #1781
Conversation
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes the crates.io “already published” detection used by the release workflow by moving the check into a dedicated script that validates HTTP status and the exact returned version number, preventing publishes from being skipped due to overly-broad JSON matching.
Changes:
- Added
scripts/crates-to-publish.shto decide per-crate publish flags using HTTP 200/404 and an exact.version.nummatch. - Updated the
CargoPublishGitHub Actions workflow to use the new script and writePUBLISH_*variables into$GITHUB_ENV. - Added
.gitattributesto enforce LF endings for.shfiles to keep scripts runnable across platforms.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| scripts/crates-to-publish.sh | New script that queries crates.io per crate/version and emits PUBLISH_* env lines. |
| .github/workflows/CargoPublish.yml | Replaces inline publish-detection logic with a call to the new script. |
| .gitattributes | Enforces LF line endings for shell scripts. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
jprendes
left a comment
There was a problem hiding this comment.
Tried the script locally and it works. I think crates.io now pays attention to the user agent, and that might have been breaking out check.
I still think that using cargo info would be a better approach, but this is fine.
* Fix crate publish existence check * Extract crate publish check script * Enforce LF endings for shell scripts * Simplify crate publish script * Move crate publish script to dev * Keep crate publish script executable --------- Signed-off-by: James Sturtevant <jsturtevant@gmail.com> Co-authored-by: James Sturtevant <jsturtevant@gmail.com>
The publish workflow treated any response containing
.versionas proof that the requested crate version existed, which caused release publish steps to be skipped. The check now skips only for HTTP 200 with an exact.version.nummatch, publishes only for HTTP 404, and fails on malformed or unexpected responses after bounded retries.The check is a standalone script for local use. Shell scripts use LF endings so Windows checkouts remain runnable.
Create a Release · hyperlight-dev/hyperlight@388ea8e failed to publish since it showed:
This is now runnable locally: