Publish Rust Packages
note
Requires Rust 1.74 or later with nightly toolchain.
Suppose you want to publish a crate package to the newly created sparse registry using:
Configure connection to the Cargo registry. The instructions are different for a local Cargo registry and for a mirror of a remote registry (the most common case is mirroring crates.io):
Local registrycrates.io mirrorIn your Rust project, add the
config.toml
file to the.cargo
directory.Add the registry data to the
config.toml
file. For example:[registries.space-registry] index = "sparse+https://cargo.registry.jetbrains.space/mycompany/p/projectkey/myCrates" credential-provider="cargo:token"
If you are not sure about the URL, you can copy the URL of a particular container registry on the Packages page.
tip
See Registry Authentication for more secure ways of authentication.
Log in to the registry:
cargo login --registry=space-registry
Here
space-registry
is the registry name you specified inconfig.toml
.When asked for credentials, specify either your Space username and password (we recommend that you use a personal token instead) or a client ID and a client secret of a service account.
tip
You can quickly generate a personal token on the registry's getting started page.
In your Rust project, add the
config.toml
file to the.cargo
directory.Add the registry data to the
config.toml
file. For example:[registries.space-registry-mirror] index = "sparse+https://cargo.registry.jetbrains.space/mycompany/p/projectkey/myCrates-mirror" credential-provider="cargo:token"
If you are not sure about the URL, you can copy the URL of a particular container registry on the Packages page.
tip
See Registry Authentication for more secure ways of authentication.
Log in to the registry:
cargo login --registry=space-registry-mirror
Here
space-registry-mirror
is the registry name you specified inconfig.toml
.When asked for credentials, specify either your Space username and password (we recommend that you use a personal token instead) or a client ID and a client secret of a service account.
tip
You can quickly generate a personal token on the registry's getting started page.
Open the
config.toml
and configure registry replacing by adding the lines:[source] space-registry-mirror = { registry = "sparse+https://cargo.registry.jetbrains.space/mycompany/p/projectkey/myCrates-mirror" } crates-io = { replace-with = "space-registry-mirror" }
Publish the package to the registry:
cargo publish --registry=space-registry
For the instructions on how to publish Rust packages from Space Automation, refer to Space Automation examples.
Thanks for your feedback!