Repository navigation
Conversation
Client: rs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@santiagomed Any comments from your side? |
santiagomed
left a comment
There was a problem hiding this comment.
@Jens-G thanks for doing this. Launched an agent review above with 1 suggestion and 2 nits. Overall though seems GTM so will leave it up to you if you want to address the suggestion.
| publish: | ||
| runs-on: ubuntu-latest | ||
| if: false # currently broken and no maintainers around -> see THRIFT-5917 | ||
| environment: release |
There was a problem hiding this comment.
[suggestion] The single publish job carries environment: release (line 35) and id-token: write (line 38) but still runs under the pull_request trigger and workflow_dispatch. The sibling release workflows in this repo (pypi.yml, release_ruby.yml) deliberately trigger their publish jobs only on release and have no pull_request trigger. Because this is pull_request (not pull_request_target), fork PRs get a read-only token and the auth/publish steps are additionally gated by github.event_name == 'release', so this is not directly exploitable. However, it means every PR that modifies this workflow file enters the protected release environment (potentially queuing a deployment / required-reviewer approval as noise) and is granted id-token: write for a context where it is never needed.
Suggestion: Split the PR/dispatch validation (cargo publish --dry-run) into its own job with no environment and minimal permissions: { contents: read }, and keep a separate publish job that is the only one carrying environment: release + id-token: write and is scoped to the release event (e.g. if: github.event_name == 'release' at the job level, mirroring pypi.yml/release_ruby.yml).
| # required by transitive dependencies (getrandom >= 0.4). | ||
| run: cargo publish --dry-run | ||
| env: | ||
| RUSTUP_TOOLCHAIN: stable |
There was a problem hiding this comment.
[nit] RUSTUP_TOOLCHAIN: stable (lines 50 and 64) floats the toolchain to whatever "stable" resolves to at run time. This makes both the dry-run validation and the actual published build non-reproducible, and means the artifact pushed to crates.io may be built against a different compiler than the rest of the repo's CI (which pins 1.83, per the added comment). A floating channel can silently change behavior between a passing dry-run and a later publish.
Suggestion: Consider pinning a specific stable version (e.g. RUSTUP_TOOLCHAIN: 1.XX.0) so the dry-run and publish use an identical, reproducible toolchain, and bump it intentionally.
|
|
||
| - name: Publish | ||
| # Only publish on a non-prerelease GitHub Release event | ||
| if: ${{ github.event_name == 'release' && !github.event.release.prerelease }} |
There was a problem hiding this comment.
[nit] The publish path (gated on github.event_name == 'release' && !github.event.release.prerelease) does not verify that the released tag/ref corresponds to the version declared in lib/rs/Cargo.toml. The prerelease guard is correct and draft releases are implicitly handled (a published release is never a draft). But if a maintainer publishes a Release whose tag does not match the Cargo.toml version, cargo publish will either republish/fail on an existing version or publish an unexpected version. Low risk (cargo rejects duplicate versions) but there is no early, explicit consistency check.
Suggestion: Optionally add a guard step that asserts the Cargo.toml version matches github.event.release.tag_name (stripping any leading v) before authenticating/publishing, failing fast on mismatch.
Client: rs - Split single job into dry-run (no env/OIDC) + publish (release only) - Pin RUSTUP_TOOLCHAIN to 1.85 instead of floating stable - Add version consistency check between Cargo.toml and release tag Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for the review @santiagomed! Addressed all three points in the latest commit:
|
Client: rs Pass release tag name via env var instead of direct template expansion in the run block to prevent shell injection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Fixed the zizmor finding: moved |
Summary
Fixes the
release_rust.ymlworkflow so the Rust crate is automatically published to crates.io whenever a GitHub Release is published. Also supersedes #3587.Changes:
if: falsegate that disabled the entire job (added in lieu of THRIFT-5917)push: tags:torelease: types: [published]— consistent withpypi.ymlandrelease_ruby.yml, and prevents publishing before the PMC vote passesenvironment: release— required for OIDC trusted publishing (same as pypi/ruby)RUSTUP_TOOLCHAIN: stableon cargo steps — the repo-pinnedrust-toolchain(1.83) predatesedition2024support required by transitive dependencies (getrandom >= 0.4); stable Rust is pre-installed on ubuntu-latest runnersgithub.event_name == 'release' && !github.event.release.prerelease— dry-run runs on every trigger, actual publish only on non-prerelease GitHub ReleasesCargo.tomlwildcard dev-dependencyuuid = "*"→uuid = "1"— crates.io rejects wildcard version constraints (this blocked the 0.23.0 publish; fixed separately in Fix wildcard dev-dependency version for uuid in Rust crate #3587 which this supersedes)Prerequisites (one-time manual step — cannot be done in CI)
Trusted publishing on crates.io must be configured before the publish step can authenticate:
apachethriftrelease_rust.ymlreleaseThis is the same OIDC mechanism already used for the existing workflow structure.
Limitations
The OIDC publish path cannot be end-to-end tested without merging and cutting a real release. The
--dry-runstep validates packaging; auth and upload can only be confirmed on first use.Test plan
🤖 Generated with Claude Code