Common practices in CI when generating releases


I have a question about how people handle projects with multiple sub-crates, specially their CI workflows.

My setup is like the following:

+ project/
|--- subcrate_1/
     +--- src/
     +--- Cargo.toml
|--- subcrate_2/
     +--- src/
     +--- Cargo.toml
|--- src/
|--- Cargo.toml
|--- Cargo.lock

The sub-crates contain independent logic that might get reused in some other projects, and the main crate has them as dependencies (they are both added as workspace members and as dependencies).

Right now, I have a custom script <TAG_NAME> which makes sure that there are no unstaged file changes, and via sed sets the same version to the main Cargo.toml and the Cargo.toml of the sub-crates.

However, before actually creating the tag, in order to keep the Cargo.lock in sync I need to run a cargo build in order for the Cargo.lock to update the sub-crates versions. I've tried to run some cargo check commands, but they always ended up upgrading transitive dependencies too (which has lead to breaking changes in the past).

I feel like there must be a simpler way to do it, but after checking in popular open source projects I see that most of them have a checklist for a manual process (such as RipGrep).

What I'm asking is: Is there a way to update the Cargo.lock dependencies, but only the local sub-crates without needing to build the project?


Regarding the release of multiple crates, you may be interested by cargo-release.

cargo update -p subcrate_1 -p subcrate_2

But be aware that if subcrate_1 or subcrate_2 update their own dependencies within their Cargo.toml files, those will be updated as well.

I'll try that approach, thanks!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.