fork/cargo

git clone https://git.julia.blue/fork/cargo

Weihang Lofeat(publish): Stabilize multi-package publishing (#15636)0322bdd37

0.91.0
13.1 KiB307 linesraw
1CARGO-PUBLISH(1)
2
3NAME
4       cargo-publish — Upload a package to the registry
5
6SYNOPSIS
7       cargo publish [options]
8
9DESCRIPTION
10       This command will create a distributable, compressed .crate file with
11       the source code of the package in the current directory and upload it to
12       a registry. The default registry is <https://crates.io>. This performs
13       the following steps:
14
15       1. Performs a few checks, including:
16          o  Checks the package.publish key in the manifest for restrictions on
17             which registries you are allowed to publish to.
18
19       2. Create a .crate file by following the steps in cargo-package(1).
20
21       3. Upload the crate to the registry. The server will perform additional
22          checks on the crate.
23
24       4. The client will poll waiting for the package to appear in the index,
25          and may timeout. In that case, you will need to check for completion
26          manually. This timeout does not affect the upload.
27
28       This command requires you to be authenticated with either the --token
29       option or using cargo-login(1).
30
31       See the reference
32       <https://doc.rust-lang.org/cargo/reference/publishing.html> for more
33       details about packaging and publishing.
34
35OPTIONS
36   Publish Options
37       --dry-run
38           Perform all checks without uploading.
39
40       --token token
41           API token to use when authenticating. This overrides the token
42           stored in the credentials file (which is created by cargo-login(1)).
43
44           Cargo config <https://doc.rust-lang.org/cargo/reference/config.html>
45           environment variables can be used to override the tokens stored in
46           the credentials file. The token for crates.io may be specified with
47           the CARGO_REGISTRY_TOKEN environment variable. Tokens for other
48           registries may be specified with environment variables of the form
49           CARGO_REGISTRIES_NAME_TOKEN where NAME is the name of the registry
50           in all capital letters.
51
52       --no-verify
53           Don’t verify the contents by building them.
54
55       --allow-dirty
56           Allow working directories with uncommitted VCS changes to be
57           packaged.
58
59       --index index
60           The URL of the registry index to use.
61
62       --registry registry
63           Name of the registry to publish to. Registry names are defined in
64           Cargo config files
65           <https://doc.rust-lang.org/cargo/reference/config.html>. If not
66           specified, and there is a package.publish
67           <https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field>
68           field in Cargo.toml with a single registry, then it will publish to
69           that registry. Otherwise it will use the default registry, which is
70           defined by the registry.default
71           <https://doc.rust-lang.org/cargo/reference/config.html#registrydefault>
72           config key which defaults to crates-io.
73
74   Package Selection
75       By default, when no package selection options are given, the packages
76       selected depend on the selected manifest file (based on the current
77       working directory if --manifest-path is not given). If the manifest is
78       the root of a workspace then the workspaces default members are
79       selected, otherwise only the package defined by the manifest will be
80       selected.
81
82       The default members of a workspace can be set explicitly with the
83       workspace.default-members key in the root manifest. If this is not set,
84       a virtual workspace will include all workspace members (equivalent to
85       passing --workspace), and a non-virtual workspace will include only the
86       root crate itself.
87
88       -p spec…, --package spec…
89           Publish only the specified packages. See cargo-pkgid(1) for the SPEC
90           format. This flag may be specified multiple times and supports
91           common Unix glob patterns like *, ? and []. However, to avoid your
92           shell accidentally expanding glob patterns before Cargo handles
93           them, you must use single quotes or double quotes around each
94           pattern.
95
96       --workspace
97           Publish all members in the workspace.
98
99       --all
100           Deprecated alias for --workspace.
101
102       --exclude SPEC…
103           Exclude the specified packages. Must be used in conjunction with the
104           --workspace flag. This flag may be specified multiple times and
105           supports common Unix glob patterns like *, ? and []. However, to
106           avoid your shell accidentally expanding glob patterns before Cargo
107           handles them, you must use single quotes or double quotes around
108           each pattern.
109
110   Compilation Options
111       --target triple
112           Publish for the given architecture. The default is the host
113           architecture. The general format of the triple is
114           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
115           a list of supported targets. This flag may be specified multiple
116           times.
117
118           This may also be specified with the build.target config value
119           <https://doc.rust-lang.org/cargo/reference/config.html>.
120
121           Note that specifying this flag makes Cargo run in a different mode
122           where the target artifacts are placed in a separate directory. See
123           the build cache
124           <https://doc.rust-lang.org/cargo/reference/build-cache.html>
125           documentation for more details.
126
127       --target-dir directory
128           Directory for all generated artifacts and intermediate files. May
129           also be specified with the CARGO_TARGET_DIR environment variable, or
130           the build.target-dir config value
131           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
132           target in the root of the workspace.
133
134   Feature Selection
135       The feature flags allow you to control which features are enabled. When
136       no feature options are given, the default feature is activated for every
137       selected package.
138
139       See the features documentation
140       <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
141       for more details.
142
143       -F features, --features features
144           Space or comma separated list of features to activate. Features of
145           workspace members may be enabled with package-name/feature-name
146           syntax. This flag may be specified multiple times, which enables all
147           specified features.
148
149       --all-features
150           Activate all available features of all selected packages.
151
152       --no-default-features
153           Do not activate the default feature of the selected packages.
154
155   Manifest Options
156       --manifest-path path
157           Path to the Cargo.toml file. By default, Cargo searches for the
158           Cargo.toml file in the current directory or any parent directory.
159
160       --locked
161           Asserts that the exact same dependencies and versions are used as
162           when the existing Cargo.lock file was originally generated. Cargo
163           will exit with an error when either of the following scenarios
164           arises:
165
166           o  The lock file is missing.
167
168           o  Cargo attempted to change the lock file due to a different
169              dependency resolution.
170
171           It may be used in environments where deterministic builds are
172           desired, such as in CI pipelines.
173
174       --offline
175           Prevents Cargo from accessing the network for any reason. Without
176           this flag, Cargo will stop with an error if it needs to access the
177           network and the network is not available. With this flag, Cargo will
178           attempt to proceed without the network if possible.
179
180           Beware that this may result in different dependency resolution than
181           online mode. Cargo will restrict itself to crates that are
182           downloaded locally, even if there might be a newer version as
183           indicated in the local copy of the index. See the cargo-fetch(1)
184           command to download dependencies before going offline.
185
186           May also be specified with the net.offline config value
187           <https://doc.rust-lang.org/cargo/reference/config.html>.
188
189       --frozen
190           Equivalent to specifying both --locked and --offline.
191
192       --lockfile-path PATH
193           Changes the path of the lockfile from the default
194           (<workspace_root>/Cargo.lock) to PATH. PATH must end with Cargo.lock
195           (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that
196           providing --lockfile-path will ignore existing lockfile at the
197           default path, and instead will either use the lockfile from PATH, or
198           write a new lockfile into the provided PATH if it doesn’t exist.
199           This flag can be used to run most commands in read-only directories,
200           writing lockfile into the provided PATH.
201
202           This option is only available on the nightly channel
203           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
204           requires the -Z unstable-options flag to enable (see #14421
205           <https://github.com/rust-lang/cargo/issues/14421>).
206
207   Miscellaneous Options
208       -j N, --jobs N
209           Number of parallel jobs to run. May also be specified with the
210           build.jobs config value
211           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
212           the number of logical CPUs. If negative, it sets the maximum number
213           of parallel jobs to the number of logical CPUs plus provided value.
214           If a string default is provided, it sets the value back to defaults.
215           Should not be 0.
216
217       --keep-going
218           Build as many crates in the dependency graph as possible, rather
219           than aborting the build on the first one that fails to build.
220
221           For example if the current package depends on dependencies fails and
222           works, one of which fails to build, cargo publish -j1 may or may not
223           build the one that succeeds (depending on which one of the two
224           builds Cargo picked to run first), whereas cargo publish -j1
225           --keep-going would definitely run both builds, even if the one run
226           first fails.
227
228   Display Options
229       -v, --verbose
230           Use verbose output. May be specified twice for “very verbose”
231           output which includes extra output such as dependency warnings and
232           build script output. May also be specified with the term.verbose
233           config value
234           <https://doc.rust-lang.org/cargo/reference/config.html>.
235
236       -q, --quiet
237           Do not print cargo log messages. May also be specified with the
238           term.quiet config value
239           <https://doc.rust-lang.org/cargo/reference/config.html>.
240
241       --color when
242           Control when colored output is used. Valid values:
243
244           o  auto (default): Automatically detect if color support is
245              available on the terminal.
246
247           o  always: Always display colors.
248
249           o  never: Never display colors.
250
251           May also be specified with the term.color config value
252           <https://doc.rust-lang.org/cargo/reference/config.html>.
253
254   Common Options
255       +toolchain
256           If Cargo has been installed with rustup, and the first argument to
257           cargo begins with +, it will be interpreted as a rustup toolchain
258           name (such as +stable or +nightly). See the rustup documentation
259           <https://rust-lang.github.io/rustup/overrides.html> for more
260           information about how toolchain overrides work.
261
262       --config KEY=VALUE or PATH
263           Overrides a Cargo configuration value. The argument should be in
264           TOML syntax of KEY=VALUE, or provided as a path to an extra
265           configuration file. This flag may be specified multiple times. See
266           the command-line overrides section
267           <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
268           for more information.
269
270       -C PATH
271           Changes the current working directory before executing any specified
272           operations. This affects things like where cargo looks by default
273           for the project manifest (Cargo.toml), as well as the directories
274           searched for discovering .cargo/config.toml, for example. This
275           option must appear before the command name, for example cargo -C
276           path/to/my-project build.
277
278           This option is only available on the nightly channel
279           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
280           requires the -Z unstable-options flag to enable (see #10098
281           <https://github.com/rust-lang/cargo/issues/10098>).
282
283       -h, --help
284           Prints help information.
285
286       -Z flag
287           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
288           details.
289
290ENVIRONMENT
291       See the reference
292       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
293       for details on environment variables that Cargo reads.
294
295EXIT STATUS
296       o  0: Cargo succeeded.
297
298       o  101: Cargo failed to complete.
299
300EXAMPLES
301       1. Publish the current package:
302
303              cargo publish
304
305SEE ALSO
306       cargo(1), cargo-package(1), cargo-login(1)
307