码农札记

Rust项目GPG签名配置指南

2025-04-24T03:25:50.000Z
10 views
1 min read
default

Rust项目GPG签名配置指南

一、环境准备

powershell
# 安装Gpg4win(Windows) winget install -e --id GnuPG.Gpg4win

二、密钥生成与配置

powershell
# 生成RSA4096密钥 gpg --full-generate-key # 类型选RSA and RSA,长度4096,邮箱填z32664206862022@163.com # 查看密钥ID gpg --list-secret-keys --keyid-format LONG # 示例输出:sec rsa4096/076FC8A4D6CBBD0D 2025-04-24 [SC] # 配置Git全局签名 git config --global user.signingkey 076FC8A4D6CBBD0D git config --global commit.gpgsign true

三、GitHub集成

powershell
# 导出公钥(替换实际ID) gpg --armor --export 076FC8A4D6CBBD0D | clip
  1. 登录GitHub网页端
  2. 访问 https://github.com/settings/keys
  3. 点击"New GPG key"粘贴公钥

四、项目签名操作

powershell
# 创建签名标签 git tag -s v0.1.0 -m "首个稳定版" # 强制推送签名标签 git push origin v0.1.0 --force # 验证签名 git tag -v v0.1.0

五、常见问题解决

1. 密钥导出失败

powershell
# 手动导出到文件 gpg --armor --export 076FC8A4D6CBBD0D > public_key.asc

2. 多账号配置

powershell
# 项目级配置(在项目目录执行) git config user.name "text" git config user.email "xxxxx@163.com"

3. 路径问题修复

powershell
# 指定绝对路径 git config --global gpg.program "C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe"

六、Cargo.toml配置参考

rust
[package] name = "ll" version = "0.1.0" authors = ["xxxx"] license = "MIT" repository = "https://github.com/xxxx/xxx" [dependencies] clap = { version = "4.5.37", features = ["derive"] }

发表留言

全部留言 (0)

暂无留言,成为第一个留言的人吧!