cargo publish
should optionally skip unpublishable packages
#15006
Labels
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Command-publish
S-triage
Status: This issue is waiting on initial triage.
Z-package-workspace
Nightly: package-workspace
This is about the unstable
-Zpackage-workspace
feature. Discussion branched from #1169 (comment).Problem
In a large workspace, there might be many packages to publish, and many packages that should not be published (for development only, or applications that are distributed by means other than Cargo).
cargo publish -Zpackage-workspace
will attempt to publish the workspace’s default members, whether or not they are marked unpublishable withpackage.publish = false
, and error out if any of them are.This seems to me a missing feature; it should be possible to choose to use
package.publish
metadata to control whether a package is selected for publishing.Proposed Solution
Alternative 1: Add a new flag (with what name?) which selects packages, from members or default-members, as follows:
package.publish = false
, it is not selected.package.publish = true
, it is selected.This flag would be compatible with
--workspace
but incompatible with--package
.This version encourages workspace authors to explicitly think about whether each package should be published if they wish to use this feature, which seems to me the best outcome. However, it gives new semantics to
package.publish = true
, which was previously identical to the field being absent. I think this is a good thing (publishing should be more opt-in, since it is close to irrevocable), but it would be new.Alternative 2: Add a new flag
--exclude-unpublishable
.default-members
or due to--workspace
being passed, and it haspackage.publish = false
, then it is excluded from selection as if by--exclude
.--package
and it haspackage.publish = false
, this is still an error.Alternative 3: Automatically skip
publish = false
packages without any specific flag.This might be too “DWIM” but it is the behavior I was implicitly expecting when I tried out
-Zpackage-workspace
for the first time.Notes
In the status quo, it would be possible to use the workspace’s
default-members
to control which packages are published. I think this is not sufficient, becausedefault-members
should be a package selection which is appropriate for routine development, which will usually be much more common than publishing. In particular, a package whose job is entirely tests should not be published, but should be run by default withcargo test
.@rustbot label +Z-package-workspace
The text was updated successfully, but these errors were encountered: