-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo publish multiple packages at once #1169
Comments
This would be awesome ;) |
I suspect we may want to have a story with #883 if/when we implement this: I could easily imagine unintentionally publishing crates by not realising that I'm depending on them. |
Is there any progress on this? I think this would a very good thing to have. One of the nice things about crates is that they are modular, thus reduce the compile time of larger projects. However, if you are developing a large library compile times can get pretty slow (when it hits >2min I start to compile after 50% of the fixing, so it can compile while I'm fixing the other 50% of the issues). In this case you can split the library into sub-crates, where each sub-crate is in some sense standalone, or a build-up over "core" structure. However, each one of them would not make any sense on its own. Publishing each individually does not make any sense also and not packaging it together. If we can have this kind of publish --all this would give as an option to reduce compile times without any drawback from the user and publishing side of the library. |
Any updates whether this will be implemented and when? |
@matthiasbeyer I think this fell through the cracks when we did workspaces. This issue was supposed to track wrapping @alexcrichton what's the status? |
@wycats AFAIK this has always been in the 'nice to have' category and hasn't progressed to the 'someone has put time into designing this' category. |
One thing I just thought about: When doing a workspace release, cargo should build everything and after everything is fine, publish all crates at once... if that is even possible. Not like "build & publish the first crate and continue for each crate" but rather "build everything, then publish everything". |
It seems that in a |
I created a simple PR to deal with this annoying issue; it permits to execute
Unluckily I did not find a way to implement this logic because cargo requires that all the dependencies of a package are in the repository or the package phase (when the tarball is created) fails; consequently, before publishing a package with a "path" dependency, that dependency must be in the repository. |
Something else I would want that I don’t think that can handle is only publishing updated packages, if one of the packages already exists at its current version number it should be downloaded and verified that the new package is identical. |
being new to workspaces but not to cargo this feels very much like a paper cut. My finger just got nipped when I tried to publish a new workspace project by following the docs ...then realized that order matters. The validation of packages will fail of one of the workspace packages depends on another in the same release but which may not have been published first. In my case it's a very simple ordering but for those new to cargo, something like |
It would definitively help me with imag where I publish over 50 crates in one release! |
https://github.com/Byron/google-apis-rs and https://github.com/rusoto/rusoto would also like benefit greatly from this |
This sounds useful, but I'm wondering what the exact behaviour should be. What if you have a |
@torkleyy interesting point. It probably should not modify the Cargo.toml at all, but it would be worth considering whether or not cargo should allow for E.g. If building Simplified StepsI'm imagining
It would be worth considerinng if step 4 should be a special "atomic step" recognised by crates.io so that if for some reason the net drops out or there's a crash the user doesn't end up with only half of their packages published. |
@mitchmindtree I would like to also see an extra step between 3 and 4 doing full workspace package validation to replace the current pre-publish validation. This does the normal per-package validation steps with 2 changes:
|
I started working on this here: https://gitlab.com/torkleyy/cargo-publish-all |
Publish workspace Adds support for simultaneously publishing multiple (possibly inter-dependent) packages in a workspace, gated by the `-Zpackage-workspace` flag. Questions to be worked out through stabilization: - Are we ok stabilizing this and #10948 at the same time? Currently, they are behind the same flag - What is the desired behavior for the publish timeout? This PR uploads the crates in batches (depending on the dependency graph), and we only timeout if nothing in the batch is available within the timeout, deferring the rest to the next wait-for-publish. So for example, if you have packages `a`, `b`, `c` then we'll wait up to 60 seconds and if only `a` and `b` were ready in that time, we'll then wait another 60 seconds for `c`. - What is the desired behavior when some packages in a workspace have `publish = false`? This PR raises an error whenever any of the selected packages has `publish = false`, so it will error on `cargo publish --workspace` in a workspace with an unpublishable package. An alternative interface would implicitly exclude unpublishable packages in this case, but still error out if you explicitly select an unpublishable package with `-p package-name` (see #14356). This PR's behavior is the most conservative one as it can change from an error to implicit excludes later. This is part of #1169
Was hoping to do a call for testing but ran into #14721 which breaks some ways of testing this feature. |
Are there ways of testing which can already help? I would absolutely love to have this feature built in. |
Feel free to give it a try in nightly. You don't need more formalized testing instructions to give it a try. |
Tried to test it again and ran into another issues, see #14789 |
UPDATE Original postI ran into a related issue: my workspace has 3 packages that are chain-dependent (varnish -> macros -> sys). The version is the same for all of them, and gets updated at the same time. All 3 packages' [workspace.package]
version = "0.2.2"
[workspace.dependencies]
varnish = { path = "./varnish", version = "0.2.2" }
varnish-macros = { path = "./varnish-macros", version = "0.2.2" }
varnish-sys = { path = "./varnish-sys", version = "0.2.2" }
|
Call for testing
Basic steps:Requirements:
Try Support in third-party release tools:
In particular, consider
Note:
Please leave feedback on this issue |
hey @epage ! Just tried it to release freya v0.3.0-rc.0 and it seems to have worked perfectly!
Here is the command I ran (with and without cargo +nightly publish --features skia-engine --workspace -Z package-workspace --exclude "examples" --exclude "freya-installer-example" Love this, I hope it gets stabilized soon! ✨ 🦀 |
I just tried out the feature with
|
IMO this is a bug. You cannot even publish a single crate with
#13397 might be related
This is likely because Caarg were building a lockfile for each package. I am aware of it, and think it should be fixed. Currently specifying |
I was surprised as well that it didn't skip those crates with |
|
Might be good to open an issue for this. |
This comes about from an implementation detail. We are effectively stringing together separate commands ( We could fake it by overriding the config to be in offline mode but we don't have an easy way to layer that on top of the existing config, so we'd be mutating the config and, ideally, trying to roll back without being able to use RAII because we'd need to have a I thought we had an issue about checking the registry less often in general but I can't find it (if lockfile didn't change and everything is cached locally, why check?). |
True. Sorry I didn't think that hard. Also need to consider consistency between |
I just ran into a failure doing a dry-run publish that I'm still trying to characterize. This is on https://github.com/crate-ci/typos $ cargo +nightly publish --workspace --dry-run --exclude codespell-dict --exclude wikipedia-dict -Zpackage-workspace
...
Verifying typos-dict v0.12.1 (/home/epage/src/personal/typos/crates/typos-dict)
error: failed to verify package tarball
Caused by:
checksum for `varcon v1.0.1` changed between lock files
this could be indicative of a few possible errors:
* the lock file is corrupt
* a replacement source in use (e.g., a mirror) returned a different checksum
* the source itself may be corrupt in one way or another
unable to verify that `varcon v1.0.1` is the same as when the lockfile was generated This reproduces when I drop down to $ cargo +nightly package --workspace -Zpackage-workspace I thought it was because I had a local edit but that isn't true. I just checked and If I do these dry-runs on other repos, like UPDATE the packaged [[package]]
name = "varcon"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9146d8774c298fff5715399e91d8495fe262198d3532b529cb73787b284b89d"
dependencies = [
"varcon-core",
] Creating a lockfile independent of any of this, I get [[package]]
name = "varcon"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9146d8774c298fff5715399e91d8495fe262198d3532b529cb73787b284b89d"
dependencies = [
"varcon-core",
] UPDATE I looked closer at
UPDATE I'm thinking that the My guess as to what is happening is that we are using the committed |
Done: #15005
I don't think it has be automatic, and to minimize the chance of proceeding with a user error, it shouldn’t be. Instead — actually, this is a nontrivial design space and so I filed a separate issue for it, #15006. |
hey @epage ! I tried it on my usbredir binding crates, and it fails to resolve a member/ffi dependency. You should be able to reproduce with https://gitlab.freedesktop.org/elmarco/usbredir-rs.git (I used |
It would be nice to have a flag to
cargo publish
which publishes all local packages in a DAG fashion.Non-atomic publish was added in #14433, stabilization is being tracked in #10948
Testing instructions: #1169 (comment)
Notes (edit ehuss):
--dry-run
should work correctly (will need to pretend that the previous crates have been published, maybe viapatch
?) See also Add a dry-run publish API crates.io#1515.Blocking issues
Non-blocking issues
cargo package
(and hencecargo publish
) verify step is slow from doing a full build #14941The text was updated successfully, but these errors were encountered: