本文档记录了将 Hello CLI 发布到 Windows Package Manager (winget) 的完整流程。
如需了解从标签到 Release 的整体链路,请先阅读
docs/release-workflow.md 中的 GoReleaser 与版本注入说明。
- GitHub 账号
- Windows 10/11 环境(用于测试)
- 已发布的 GitHub Release
- 二进制文件的 SHA256 值
winget-manifests/
└── manifests/
└── d/
└── dongzhenye/
└── hello-cli/
└── 0.1.0/
├── dongzhenye.hello-cli.yaml # 版本文件
├── dongzhenye.hello-cli.installer.yaml # 安装程序信息
└── dongzhenye.hello-cli.locale.en-US.yaml # 默认语言包
- 版本文件: 定义包标识符、版本号和清单类型
- 安装程序文件: 包含下载 URL、架构、SHA256 等信息
- 语言文件: 包含描述、标签、发布说明等元数据
已创建 winget-manifests/update-sha256.sh 脚本,用于自动获取二进制文件的 SHA256 值。
# 在 macOS/Linux 上运行(需要先发布 Release)
cd winget-manifests
./update-sha256.sh- 访问 https://github.com/microsoft/winget-pkgs
- 点击右上角的 "Fork" 按钮
- 等待 Fork 完成
# 克隆你的 fork
git clone https://github.com/YOUR_USERNAME/winget-pkgs.git
cd winget-pkgs
# 创建新分支
git checkout -b add-hello-cli-0.1.0# 将生成的 manifest 文件复制到正确位置
cp -r path/to/hello-cli/winget-manifests/manifests/d/dongzhenye/hello-cli/0.1.0 \
manifests/d/dongzhenye/hello-cli/# 启用本地 manifest 文件
winget settings --enable LocalManifestFiles
# 验证 manifest
winget validate manifests\d\dongzhenye\hello-cli\0.1.0
# 测试安装
winget install --manifest manifests\d\dongzhenye\hello-cli\0.1.0# 添加文件
git add manifests/d/dongzhenye/hello-cli/0.1.0
# 提交
git commit -m "New package: dongzhenye.hello-cli version 0.1.0"
# 推送到你的 fork
git push origin add-hello-cli-0.1.0- 访问你的 fork:
https://github.com/YOUR_USERNAME/winget-pkgs - 点击 "Compare & pull request" 按钮
- 填写 PR 描述:
## New Package: dongzhenye.hello-cli - **Package**: dongzhenye.hello-cli - **Version**: 0.1.0 - **Description**: Say hello to your terminal — and it finally answers - **Publisher**: Zhenye Dong - **License**: MIT ### Testing - [ ] Tested installation on Windows 10/11 - [ ] Verified silent install works - [ ] Command `hello` works after installation
提交 PR 后,Microsoft Bot 会自动:
- 验证 YAML 格式
- 检查必填字段
- 测试下载链接
- 验证 SHA256
- 运行安装测试
如果有问题,Bot 会添加标签并留言。你有 7 天时间修复问题。
可以使用 WingetCreate 工具简化更新流程:
# 安装 WingetCreate
winget install Microsoft.WingetCreate
# 更新到新版本
wingetcreate update dongzhenye.hello-cli -v 0.2.0 -u https://github.com/dongzhenye/hello-cli/releases/download/v0.2.0/hello-cli_v0.2.0_windows_amd64.exe- 命名规范: PackageIdentifier 必须是
Publisher.Package格式 - 版本号: Git 标签使用带
v的语义化版本(如v0.1.1),在 manifest 的PackageVersion中去掉前缀 - 静默安装: portable 类型自动支持静默安装
- 测试: 务必在 Windows 环境测试安装
- 更新频率: 避免频繁更新,建议稳定版本再提交
A: 运行提供的 update-sha256.sh 脚本,或在 Windows 上使用:
CertUtil -hashfile hello.exe SHA256A: Hello CLI 是单个可执行文件,无需安装程序,portable 类型最合适。
A: 通常 1-3 天,取决于审核队列长度。