ci(release): publish library crate to crates.io via Trusted Publishing#53
Conversation
…shing The short name `csp` is already taken on crates.io, so the library crate is published as `code-search-please` while keeping the library name `csp` (`[lib] name = "csp"`) — downstream code still writes `use csp::...`, matching the README and the @pleaseai/csp npm package. The csp-cli dependency keeps the `csp` key via `package = "code-search-please"`. - crates/csp: rename package -> code-search-please, add [lib] name = csp, add crates.io metadata (keywords, categories, homepage, docs, readme) + a crate README. - release-please.yml: new publish-crate job using rust-lang/crates-io-auth-action (OIDC, no token), gated on the CRATES_IO_PUBLISH repo variable so it stays dormant until the one-time bootstrap (claim name + configure trusted publisher) is done. - Verified: cargo fmt/clippy/test --workspace all green; cargo publish --dry-run packages and verifies the crate. The CLI crate (code-search-please-cli) is a follow-up: it needs intra-workspace dependency-version management before it can publish.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe Changescrates.io Publish Setup
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
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)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Code Review
This pull request renames the core library crate from 'csp' to 'code-search-please' to resolve a naming conflict on crates.io, while maintaining the library name as 'csp' for backward compatibility. It also adds package metadata and a new README file. The review feedback points out that the Rust usage example in the README will fail doc tests because the '?' operator is used outside of a function returning 'Result', and suggests wrapping the example in a hidden 'main' function.
| use std::path::Path; | ||
| use csp::indexing::index::{CspIndex, LoadOptions, QueryOptions}; | ||
|
|
||
| // Index a local directory and search it | ||
| let index = CspIndex::from_path(Path::new("./my-project"), &LoadOptions::default())?; | ||
| let results = index.search("save model to disk", &QueryOptions { top_k: Some(3), ..Default::default() }); | ||
|
|
||
| for r in &results { | ||
| println!("{}:{}-{}", r.chunk.file_path, r.chunk.start_line, r.chunk.end_line); | ||
| } | ||
| # Ok::<(), String>(()) |
There was a problem hiding this comment.
[MEDIUM] README의 사용 예제가 컴파일되지 않습니다.
문제점: ? 연산자는 Result를 반환하는 함수 내에서만 사용할 수 있습니다. 현재 코드 조각은 함수로 감싸여 있지 않아 cargo test --doc 실행 시 컴파일 오류가 발생합니다.
근거: Rust 문서 테스트는 유효하고 컴파일 가능한 코드 예제를 제공해야 합니다. 이는 라이브러리 사용자가 예제를 복사하여 붙여넣고 바로 사용할 수 있도록 보장합니다.
제안: rustdoc이 테스트할 수 있도록 예제 코드를 숨겨진 main 함수로 감싸는 것을 제안합니다. 이렇게 하면 문서의 가독성을 해치지 않으면서 코드의 정확성을 보장할 수 있습니다. 또한, 예제를 실행하기 위해 필요한 설정(예: 디렉토리 생성)에 대한 주석을 추가하는 것이 좋습니다.
| use std::path::Path; | |
| use csp::indexing::index::{CspIndex, LoadOptions, QueryOptions}; | |
| // Index a local directory and search it | |
| let index = CspIndex::from_path(Path::new("./my-project"), &LoadOptions::default())?; | |
| let results = index.search("save model to disk", &QueryOptions { top_k: Some(3), ..Default::default() }); | |
| for r in &results { | |
| println!("{}:{}-{}", r.chunk.file_path, r.chunk.start_line, r.chunk.end_line); | |
| } | |
| # Ok::<(), String>(()) | |
| # fn main() -> Result<(), String> { | |
| use std::path::Path; | |
| use csp::indexing::index::{CspIndex, LoadOptions, QueryOptions}; | |
| // Index a local directory and search it | |
| // To make this example runnable, create a dummy directory first: `mkdir my-project` | |
| let index = CspIndex::from_path(Path::new("./my-project"), &LoadOptions::default())?; | |
| let results = index.search("save model to disk", &QueryOptions { top_k: Some(3), ..Default::default() }); | |
| for r in &results { | |
| println!("{}:{}-{}", r.chunk.file_path, r.chunk.start_line, r.chunk.end_line); | |
| } | |
| # Ok(()) | |
| # } |
What
Adds crates.io publishing for the library crate via Trusted Publishing (OIDC, no token), mirroring the npm setup.
The short name
cspis already taken on crates.io (an unrelated crate at 3.0.0), so the library is published ascode-search-pleasewhile keeping the library namecsp:cargo add code-search-please→use csp::.... The README example and@pleaseai/cspnpm package are unaffected.Changes
crates/csp/Cargo.toml: rename package →code-search-please, add[lib] name = "csp", add crates.io metadata (keywords,categories,homepage,documentation,readme).crates/csp/README.md: new crate-level README for the crates.io listing.Cargo.toml(root):cspworkspace dep gainspackage = "code-search-please"socsp-clikeepsuse csp.Cargo.lock: regenerated (csp→code-search-please).release-please.yml: newpublish-cratejob usingrust-lang/crates-io-auth-action@v1.0.5(SHA-pinned),id-token: write,cargo publish -p code-search-please --locked. Gated on theCRATES_IO_PUBLISHrepo variable.One-time bootstrap (required before CI can publish)
crates.io Trusted Publishing can't be configured on a crate that doesn't exist yet, so:
code-search-please@0.1.4(first version of the new crate name; crates.io is independent of our GH/npm releases).pleaseai, repocode-search, workflowrelease-please.yml.CRATES_IO_PUBLISH=true.After that, every release auto-publishes the new version via OIDC.
Verification
cargo fmt --all --check,cargo clippy --all-targets --all-features -D warnings,cargo test --workspace(257 + 8 pass) all greencargo publish -p code-search-please --dry-run --lockedpackages + verifies (27 files)csp-clistill builds viause csp(package rename transparent)Follow-up
The CLI crate (
code-search-please-cli, binarycsp) needs intra-workspace dependency-version management (thecsp-cli → cspdep must carry a synced version for publish) — a separate PR, ideally via release-please's cargo strategy.Summary by cubic
Set up crates.io publishing for the Rust library via Trusted Publishing (OIDC). Publishes as
code-search-pleasewhile keeping the Rust lib namecsp, souse csp::...stays the same.New Features
publish-cratejob torelease-please.ymlusingrust-lang/crates-io-auth-action@v1.0.5withid-token: write; runscargo publish -p code-search-please --lockedwhen a release is created andCRATES_IO_PUBLISH=true.crates/csp/Cargo.tomltocode-search-please; set[lib] name = "csp". Added crates.io metadata and a crate README.csptopackage = "code-search-please"to keep imports unchanged. RegeneratedCargo.lock.Migration
cargo publish -p code-search-please --locked.pleaseai/code-search, workflowrelease-please.yml.CRATES_IO_PUBLISH=true.Written for commit ceefff1. Summary will update on new commits.
Summary by CodeRabbit
New Features
code-search-please, enabling integration into Rust projects.Documentation
Chores