ci: gate crate publishing on unpublished versions#690
Conversation
Add an unprotected release preparation job that checks the configured crate versions before entering the protected release environment. Skip the publish job when every crate version is already on crates.io so ordinary main merges do not create deployment approval requests.
Greptile SummaryThis PR gates the protected
Confidence Score: 4/5Safe to merge — the core gating logic is correct and the publish job retains its own crates.io re-check as a safety net against race conditions between jobs. The two-job design works as intended: ordinary main merges skip the approval gate, and only genuine new versions trigger the release environment. The two findings are non-blocking: the check_crates_io function duplication is a maintenance concern, and the HTTP-200-without-.version edge case is an unlikely crates.io API quirk that would surface as a clear build failure rather than a silent mispublish. .github/workflows/release_crates.yaml — the check_crates_io function defined in both jobs should be kept in sync if retry or header logic changes. Important Files Changed
Sequence DiagramsequenceDiagram
participant GH as GitHub Actions
participant PR as prepare_release job
participant CIO as crates.io API
participant PUB as publish job (release env)
GH->>PR: trigger (push to main / workflow_dispatch)
PR->>PR: resolve crate list (input or default)
loop for each crate
PR->>CIO: "GET /api/v1/crates/{crate}/{version}"
CIO-->>PR: 200 (already published) or 404 (new version)
Note over PR: retries up to 3x on transient errors
end
PR->>PR: write should_publish and crates to GITHUB_OUTPUT
alt "should_publish == 'true'"
GH->>PUB: trigger (requires release environment approval)
loop for each crate
PUB->>CIO: "GET /api/v1/crates/{crate}/{version}"
CIO-->>PUB: 200 (skip) or 404 (publish)
PUB->>PUB: "cargo publish --package {crate}"
end
else "should_publish == 'false'"
Note over GH: publish job skipped — no approval request
end
Reviews (1): Last reviewed commit: "ci: gate crate publishing on unpublished..." | Re-trigger Greptile |
Add an unprotected release preparation job that checks the configured crate versions before entering the protected release environment. Skip the publish job when every crate version is already on crates.io so ordinary main merges do not create deployment approval requests.