flowchart TD
Tag[Push tag v0.0.1] --> Release[GitHub Actions release workflow]
Release --> Build[Cross-build wtk binaries]
Build --> Package[Create tar.gz assets + checksums.txt]
Package --> Upload[Upload assets to GitHub Release]
User[User runs install.sh] --> Detect[Detect OS/arch]
Detect --> Download[Download matching release asset + checksums]
Download --> Verify[Verify checksum and executable]
Verify --> Install[Install wtk into WTK_INSTALL_DIR]
Install --> Version[wtk --version prints 0.0.1]
id: 20260511-one-click-install-release-version
name: One Click Install Release Version
status: implemented
created: '2026-05-11'
Overview
Problem Statement
worktree-kit的 one-click install 当前依赖 Go。wtk当前需要具备版本号,初始版本为0.0.1。Goals
worktree-kit的 build 与 release 流程。wtk设置版本号0.0.1。wtk --version查看版本号。Success Criteria
wtk --version输出当前版本号0.0.1。Research
Existing System
sh脚本,使用set -eu和fail()进行 fail-fast 退出。Source:scripts/install.sh:1-10wtk、模块路径github.com/nettee/worktree-kit/cmd/wtk,并要求 Go1.25.0。Source:scripts/install.sh:4-6go、grep、head、cut、basename、dirname、mkdir,随后调用require_go_version。Source:scripts/install.sh:116-125GOBIN=$install_dir go install "$install_target"安装二进制,因此用户机器必须具备 Go 工具链。Source:scripts/install.sh:127-148${HOME}/.local/bin,支持WTK_INSTALL_DIR覆盖。Source:scripts/install.sh:53-55,127-134PATH,并输出 profile 更新建议和 shell completion 示例。Source:scripts/install.sh:152-167WTK_MODULE=./cmd/wtk和WTK_VERSION=""走本地go install路径,并断言安装后的wtk --help可执行。Source:scripts/test-install.sh:26-40go时安装失败并输出missing required command: go。Source:scripts/test-install.sh:42-491.25.x,运行 installer 测试和go test ./...,没有 release job 或 artifact 上传步骤。Source:.github/workflows/ci.yml:7-161.25或更新版本;同时保留go install安装方式。Source:README.md:12-26cmd/wtk/main.go只调用cli.Execute(context.Background(), os.Args[1:]),错误时打印 stderr 并退出 1。Source:cmd/wtk/main.go:11-15Use、Short、SilenceUsage、SilenceErrors,并注册业务命令和 completion 命令;代码中没有版本字段或版本命令配置。Source:internal/cli/root.go:23-34v1.10.2,适合通过 root command 处理--version一类 CLI 元信息。Source:go.mod:5-9Available Approaches
actions/setup-go,可扩展为 tag/release workflow,执行跨平台go build、打包、checksum 生成与 asset 上传。Source:.github/workflows/ci.yml:7-16;https://github.com/actions/setup-gorelease事件及published等 activity types,可用于 release 发布后构建或上传资产。Source:https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#releasegh release upload <tag> <files>...可向指定 tag 的 release 上传资产,支持--clobber覆盖同名资产。Source:https://cli.github.com/manual/gh_release_uploadupload_url上传 raw binary asset;同名资产会返回 422。Source:https://docs.github.com/en/rest/releases/assets#upload-a-release-assetgoreleaser/goreleaser-action支持在 tag workflow 中自动构建和发布多平台 Go CLI,需要GITHUB_TOKEN的contents: write权限。Source:https://goreleaser.com/customization/ci/actions/go install替换为平台检测、下载 release asset、校验、解压/安装、执行wtk --help或wtk --version验证。Source:scripts/install.sh:127-167internal/cli/root.go,可在这里接收或设置版本信息,让 Cobra root 响应wtk --version。Source:internal/cli/root.go:23-34Constraints & Dependencies
scripts/test-install.sh:42-49go.mod要求 Go1.25.0,构建流水线仍需要 Go 工具链,但该依赖应留在 CI/release 环境。Source:go.mod:1-3;.github/workflows/ci.yml:11-16scripts/install.sh:116-148scripts/install.sh:116-123go install作为开发者安装路径。Source:README.md:12-26wtk --version输出之间保持一致。Source:specs/change/20260511-one-click-install-release-version/spec.md:15-23Key References
scripts/install.sh:116-148- 当前 Go 依赖与go install安装路径。scripts/install.sh:152-167- 当前 PATH 提示、completion 提示、安装后指导可复用。scripts/test-install.sh:26-49- 当前 installer 行为测试覆盖本地安装、PATH、缺少 Go 失败。.github/workflows/ci.yml:7-16- 当前 CI workflow 基线。internal/cli/root.go:23-34- CLI root command 构造与版本能力接入点。README.md:12-26- 当前安装文档与 Go 依赖说明。Design
Architecture Overview
Change Scope
wtk --versionprint0.0.1. Source:internal/cli/root.go:23-34;go.mod:5-9;specs/change/20260511-one-click-install-release-version/spec.md:15-23.github/workflows/ci.yml:7-16;https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release;https://cli.github.com/manual/gh_release_uploadgo installpath with release asset download, checksum verification, install-dir placement, PATH guidance, and installed binary verification. Source:scripts/install.sh:116-167scripts/test-install.sh:26-49go installas a developer path. Source:README.md:12-26Design Decisions
v*, withcontents: writepermission andgh release uploadfor assets. Source:.github/workflows/ci.yml:7-16;https://cli.github.com/manual/gh_release_upload;https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#releasedarwinandlinuxonamd64andarm64; the shell installer mapsuname -sanduname -mto those asset names. Source:scripts/install.sh:116-148;scripts/install.sh:1-2wtk_${version}_${os}_${arch}.tar.gzpluschecksums.txt, where release tags usev0.0.1and asset version strings use0.0.1. Source:specs/change/20260511-one-click-install-release-version/spec.md:15-23;https://cli.github.com/manual/gh_release_uploadlatest/downloadby default anddownload/v${version}whenWTK_VERSIONis set. Source:README.md:17;scripts/install.sh:127-129WTK_INSTALL_DIR,WTK_VERSION,WTK_REPO, and addWTK_DOWNLOAD_BASE_URLfor local fixture tests. Source:scripts/install.sh:127-129;scripts/test-install.sh:32-40checksums.txtbefore installing; fail immediately on missing dependency, unsupported platform, download failure, checksum mismatch, missing binary, or failedwtk --version. Source:scripts/install.sh:8-10,145-148;https://docs.github.com/en/rest/releases/assets#upload-a-release-assetVersion: Versionon the Cobra root command and keepVersionas a package-level variable defaulting to0.0.1, sogo build -ldflags "-X ...Version=${version}"can override it during release. Source:internal/cli/root.go:23-34;go.mod:5-9wtk --versionand expect0.0.1, aligning installer success with the new user-visible version requirement. Source:scripts/install.sh:145-148;specs/change/20260511-one-click-install-release-version/spec.md:21-23Why this design
Test Strategy
wtk --versionoutput through the root command. Source:internal/cli/root.go:23-34;go.mod:5-9checksums.txt. Source:.github/workflows/ci.yml:7-16scripts/test-install.shto create local fixture tarballs andchecksums.txt, run installer withWTK_DOWNLOAD_BASE_URL, then assert installedwtk --versionprints0.0.1. Source:scripts/test-install.sh:26-40scripts/install.sh:8-10;scripts/test-install.sh:42-49README.md:12-26Pseudocode
Release workflow:
pushtags matchingv*.version=${GITHUB_REF_NAME#v}.GOOS/GOARCH, rungo build -trimpath -ldflags "-s -w -X github.com/nettee/worktree-kit/internal/cli.Version=${version}" -o dist/wtk ./cmd/wtk.wtk_${version}_${os}_${arch}.tar.gz.checksums.txtfor packaged assets.Installer:
curl,tar,mktemp,uname,chmod,mkdir,basename,dirname, and one checksum tool.WTK_INSTALL_DIRor$HOME/.local/bin.WTK_VERSIONorlatest.osandarch; fail on unsupported combinations.checksums.txtfrom GitHub orWTK_DOWNLOAD_BASE_URL.wtk, install executable to$install_dir/wtk.$install_dir/wtk --version; require expected version for pinned installs and non-empty output for latest.Interfaces / APIs
wtk --versionoutputswtk version 0.0.1or Cobra's equivalent version line.WTK_INSTALL_DIR: target directory, default$HOME/.local/bin.WTK_VERSION: version withoutv, default latest release.WTK_REPO: GitHub repo, defaultnettee/worktree-kit.WTK_DOWNLOAD_BASE_URL: test/development override for asset downloads.wtk_0.0.1_darwin_amd64.tar.gzwtk_0.0.1_darwin_arm64.tar.gzwtk_0.0.1_linux_amd64.tar.gzwtk_0.0.1_linux_arm64.tar.gzchecksums.txtEdge Cases
unsupported platformerror.HOMEwith noWTK_INSTALL_DIRexits before download.wtkis overwritten only after a verified asset is extracted.wtk --versionreturns output; pinned installs verify the requested version string.File Structure
internal/cli/root.go- add version metadata and Cobra version wiring.cmd/wtk/main.go- keep current CLI entrypoint unless version injection requires main-package relocation..github/workflows/release.yml- build, package, checksum, upload release assets.scripts/install.sh- download and install release assets.scripts/test-install.sh- fixture-based installer tests.README.md- install and version documentation.Plan
Version = "0.0.1"and wire it into Cobra root.wtk --version.v*tags.checksums.txt.gh release upload.go installwith platform detection, download, checksum, extraction, and install.WTK_REPO,WTK_VERSION, andWTK_DOWNLOAD_BASE_URLhandling.sh scripts/test-install.sh.go test ./....wtk --version.Notes
Implementation
internal/cli/root.go- added package-levelVersion = "0.0.1"and wired Cobra version output.internal/cli/root_test.go- added--versioncoverage..github/workflows/release.yml- added tag-triggered release workflow that cross-builds darwin/linux amd64/arm64 tarballs, generateschecksums.txt, and creates or updates the GitHub Release assets.scripts/install.sh- replaced Go install flow with release asset download, OS/arch detection, checksum verification, temp-binary version verification before install, install-dir placement, PATH guidance, and completion guidance.scripts/test-install.sh- added local release fixture install test plus missing dependency, unsupported OS, and checksum mismatch failure coverage.README.md- updated install docs for release assets, pinned version installs, developergo install, andwtk --version.Verification
sh scripts/test-install.sh- passed.go test ./...- passed.wtk --versionand printedwtk version 0.0.1.