Skip to content

Latest commit

 

History

History
151 lines (120 loc) · 3.76 KB

File metadata and controls

151 lines (120 loc) · 3.76 KB

Hello CLI Release Workflow

Consolidates sections 5–8 of the original docs/prompt.md, aligning them with the current GoReleaser setup, winget checklist, and post-release validation.

1. GoReleaser Automation & GitHub Releases

1.1 快速回顾当前配置

.goreleaser.yaml (片段):

project_name: hello
builds:
  - id: win
    main: .
    goos: [windows]
    goarch: [amd64, arm64]
    env: [CGO_ENABLED=0]
    ldflags:
      - "-s -w"
      - "-X main.version=v{{ .Version }}"
archives:
  - id: windows-exe
    ids: [win]
    format: binary
    name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"

1.2 初始化与本地发布

goreleaser init                # 首次项目设置时执行
goreleaser release --snapshot  # 本地 Dry Run,产物放在 dist/

对于正式发布:

git fetch --tags
git tag -a v0.1.1 -m "v0.1.1"
goreleaser release --clean

产物包含:

hello-cli_v0.1.1_macos_amd64
hello-cli_v0.1.1_macos_arm64
hello-cli_v0.1.1_linux_amd64
hello-cli_v0.1.1_linux_arm64
hello-cli_v0.1.1_windows_amd64.exe
hello-cli_v0.1.1_windows_arm64.exe
checksums.txt

1.3 GitHub Actions(可选自动化)

.github/workflows/release.yml

name: release
on:
  push:
    tags: ["v*.*.*"]
permissions:
  contents: write
jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-go@v5
        with:
          go-version: "1.22"
      - name: Run unit tests
        run: go test ./...
      - uses: goreleaser/goreleaser-action@v5
        with:
          args: release --clean
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

提醒:fetch-depth: 0 确保 GoReleaser 能读取历史标签生成变更日志;单元测试步骤 可阻止带缺陷的提交进入发布流程。

2. Winget Manifest Pipeline

完整细节请参考 docs/winget-publishing-guide.md

2.1 CLI 路线(Windows)

wingetcreate new `
  --url https://github.com/dongzhenye/hello-cli/releases/download/v0.1.1/hello-cli_v0.1.1_windows_amd64.exe `
  --publisher "Zhenye Dong" `
  --name "Hello CLI" `
  --version 0.1.1 `
  --interactive false
winget validate .\manifests\d\dongzhenye\hello-cli\0.1.1

随后手动到 microsoft/winget-pkgs 提交 PR。

2.2 GUI 路线(待官方 GUI 支持稳定后启用)

  1. 打开 WingetCreate GUI → “New manifest from URL”
  2. 粘贴 Windows 安装包下载地址(AMD64 + ARM64)
  3. 关键字段:
    • Publisher: Zhenye Dong
    • Package Identifier: dongzhenye.hello-cli
    • Package Name: Hello CLI
    • Version: 0.1.1
    • Moniker: hello
  4. 保存并提交 PR

3. 发布后验收

winget search hello        # 应显示 Moniker=hello
winget install hello-cli
hello                      # => Hello, world!
winget upgrade hello-cli   # 用于后续升级验证

同时确认:

  • GitHub Release 产物下载正常
  • hello --version 输出与标签一致(例:v0.1.1
  • README 安装示例同步更新
  • curl -fsSL .../install-latest.sh | sh -- --dry-run (或在容器中实际安装)通过

4. 后续版本路线图

版本 功能 依赖
v1.1.0 彩色 & Emoji 输出 github.com/fatih/color
v1.2.0 hello --name Alice 标准库 flag
v2.0.0 自更新子命令 go-update
v2.1.0 Scoop / Chocolatey 自动发布 GoReleaser 扩展

路线图保留原文,反映项目的长期规划。发布时请更新 docs/package-registry-status.md 追踪各平台进度。


结合 docs/developer-onboarding.mddocs/versioning-policy.mddocs/winget-publishing-guide.md,此文档构成从开发到发布的全链路手册。