Working with Cargo
Publish Cargo Package
-
Edit
$HOME/.cargo/config.tomlto add a registry like below:[registries.onedev]
index = "sparse+https://onedev.example.com/<project path>/~cargo/"
credential-provider = "cargo:token"Param Explanation <project path> path of a project with package management enabled -
Login to the registry:
$ cargo login --registry onedev <onedev_access_token>Param Explanation <onedev_access_token> OneDev access token with package write permission over the project -
Publish package to the registry:
$ cargo publish --registry onedev -
For CI/CD job, run below to add package registry via command step:
# Use job token to tell OneDev the build publishing the package
# Job secret 'access-token' should be defined in project build setting as an access token with package write permission
mkdir -p $HOME/.cargo
cat << EOF >> $HOME/.cargo/config.toml
[registries.onedev]
index = "sparse+https://onedev.example.com/<project path>/~cargo/"
credential-provider = "cargo:token"
EOF
cat << EOF >> $HOME/.cargo/credentials.toml
[registries.onedev]
token = "@job_token@:@secret:access-token@"
EOFParam Explanation <project path> same as above
Consume Published Cargo Package
The package detail page contains instructions on how to consume published package.