制作crate并发布到Crates.io

简介: 制作crate并发布到Crates.io

准备


发布 crate 时, 一旦发布无法修改,无法覆盖, 因此要注意邮箱等一些个人信息

访问crates.io 的 帐号设定页面,生成Token

并在命令行 执行 cargo login your token

此命令将告诉 Cargo 你的 API 令牌, 并将其存储在本地 ~/.cargo/credentials

微信截图_20230802072028.png

crates.iocrate的名字, 会采取先到先得的方式分配.




打包 & 发布


对于 Cargo.toml:

[package]
name = "dashen"
version = "0.1.1"
authors = ["xxxx <x@xxxxxx.tech>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
ferris-says = "0.2"

执行cargo publish:

微信截图_20230802072118.png

这是因为缺少一些关键信息:关于该 crate 用途的描述和用户可能在何种条款下使用该 cratelicense

想要修正这个错误, 需要在 Cargo.toml 中引入这些信息.

描述通常是一两句话, 它会出现在 crate 的搜索结果中和 crate 页面里.

对于 license 字段, 需要一个 license 标识符值(license identifier value)

Linux 基金会的 Software Package Data Exchange (SPDX) 列出了可以使用的标识符

例如指定 crate 使用 MIT License,可增加 MIT 标识符

[package]
name = "dashen"
version = "0.1.1"
authors = ["xxxx <xxx@xxxxx.tech>"]
edition = "2018"
description = "the first crate by xxxxx"
license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
ferris-says = "0.2"

再次执行 cargo publish:

微信截图_20230802072220.png

这是因为没有指定git仓库


新建一个仓库,指定为远程仓库,并提交代码

微信截图_20230802072237.png

微信截图_20230802072249.png

再次执行 cargo publish:

微信截图_20230802072343.png

此时也能在crates.io搜到刚刚发布的crate

微信截图_20230802072358.png

目录
相关文章
|
编译器 Linux vr&ar
基础IO+文件(三)
基础IO+文件
57 0
|
存储 Linux 块存储
基础IO+文件(二)
基础IO+文件
58 0
|
缓存 Linux C语言
基础IO+文件(一)
基础IO+文件
70 0
|
测试技术 Go
Golang:os/io标准库读取文件
Golang:os/io标准库读取文件
107 0
|
Linux
1.17~1.30 标准C库IO函数和Linux系统IO函数
1.17~1.30 标准C库IO函数和Linux系统IO函数
106 0
1.17~1.30 标准C库IO函数和Linux系统IO函数
|
自然语言处理 Linux 定位技术
Google IO ——饭后小菜
Google IO ——饭后小菜
167 0
Google IO ——饭后小菜
|
Java Apache
common-io的使用(十二)上
common-io的使用(十二)
417 0
common-io的使用(十二)上
|
XML JSON 移动开发
Qt-QML-C++交互实现文件IO系统-后继-具体文件IO的实现
在上一篇文章中,我大致将这个QML中的文件IO类搭出了大致的框架,那么,今天抽时间写了一点文件的读写,这里我使用的文件流来读写文件。
127 0
Qt-QML-C++交互实现文件IO系统-后继-具体文件IO的实现