add sandcastle go cli (vendor/sandcastle-cli) to my homebrew-tap repo so i can install…
- User
add sandcastle go cli (vendor/sandcastle-cli) to my homebrew-tap repo so i can install it using brew install thieso2/tap/sandcastle
Assistant
Let me explore the Go CLI structure and check for the existing homebrew-tap repo.
Assistant
The tap repo exists. Let me check its current contents and how the CLI releases are handled.
Assistant
Good, there are releases with assets. Let me check the latest release assets and the existing tap structure.
Assistant
Let me check one of the existing formulas for the pattern used in this tap, and get the checksums for the sandcastle release.
Assistant
Let me verify what's inside the tar.gz to confirm the binary name.
Assistant
The binary is named
sandcastleinside the archive. Now let me clone the tap repo and add the formula.Assistant
Let me verify the test command is correct by checking what the CLI's version command looks like.
Assistant
Good,
sandcastle versionis the correct command. Now let me commit and push this to the tap repo.Assistant
Pushed. Let me verify it works.
Assistant
The tap might have a stale cache. Let me force an update.
Assistant
Formula is recognized. Let me install it to verify end-to-end.
Assistant
All working. Here's what I did:
- Created
Formula/sandcastle.rbin yourthieso2/homebrew-taprepo - Covers all 4 platforms: macOS Intel/ARM + Linux amd64/arm64
- Pinned to v0.1.14 with sha256 checksums from the release
- Pushed to
mainon the tap repo
You can now install with:
codebrew install thieso2/tap/sandcastleWhen you publish a new CLI release, you'll need to update the formula with the new version and checksums. You could automate this with a GitHub Action in the Sandcastle repo that updates the tap on release — want me to set that up?
- Created
- User
add -v --version to the cli to print the version (currently v0.1.14 - should be auto-generated)
Assistant
Cobra has built-in
--version/-vsupport via theVersionfield on the root command.Assistant
Wait — Cobra's
Versionfield is evaluated at init time, butVersionis set via ldflags at build time, so the variable is already populated beforeExecute()runs. However, theVersionfield in the struct literal is set at package init, which uses the default"dev". The ldflags-Xsets the variable, but the struct literal captures the value at init. I need to set it inExecute()orinit()instead.Assistant
Actually, let me reconsider. Go package-level
vardeclarations with ldflags-Xwork fine — the linker patches the variable's value at link time, before any init or main runs. So the struct literal approach would have worked too since it references the variable (not a copy). But setting it ininit()is equally correct and clearer. Let me verify with a build.Assistant
All three work. The final file:
Assistant
Done. Added
rootCmd.Version = Versionininit(), which makes Cobra register the built-in--version/-vflag on the root command. The version is already injected at build time via ldflags (-X github.com/sandcastle/cli/cmd.Version=$(VERSION)), so no other changes needed.All three ways to check the version now work:
sandcastle version→sandcastle v0.1.14sandcastle --version→sandcastle version v0.1.14sandcastle -v→sandcastle version v0.1.14
- User
hwo is the version updated? my suggestion would be to create a mise task release or release:patch
Assistant
Let me check the current release process and mise setup.
Assistant
So releases are driven by pushing a git tag — GoReleaser handles CLI builds and the GitHub release. Let me also check if there's a
.goreleaser.yml.Assistant
Now I have the full picture. Current flow: manually push a git tag → GitHub Actions runs GoReleaser → creates release with CLI binaries. Let me also check if a goreleaser homebrew tap integration exists, and then create the mise tasks.
Assistant
Now I'll create the mise config. The flow should be:
mise run release/mise run release:patch— bump patch version, tag, push tag- GoReleaser in CI handles build + GitHub release
- After CI completes, update the homebrew formula automatically
Let me also add a GoReleaser
brewssection so it auto-updates the tap.Assistant
Now let me add the GoReleaser
brewssection so it automatically updates the homebrew tap on release.Assistant
The CI workflow needs a token with write access to the
homebrew-taprepo. The defaultGITHUB_TOKENis scoped to the current repo only. Let me check if there's already a PAT secret configured.Assistant
No PAT with cross-repo access. GoReleaser needs a token that can push to
thieso2/homebrew-tap. The standard approach is to use aHOMEBREW_TAP_GITHUB_TOKENsecret with a PAT that hasreposcope, or use thetokenfield in the brews config.Assistant
Now update the release workflow to pass that secret to GoReleaser.
Assistant
Let me verify everything looks right.
Assistant
All three tasks are registered. Let me do a quick dry-run to verify the version parsing works.
Assistant
Here's the summary of what's set up:
Mise tasks (
mise.toml):mise run release(aliased asrelease:patch) — bumps patch: v0.1.14 → v0.1.15mise run release:minor— bumps minor: v0.1.14 → v0.2.0mise run release:major— bumps major: v0.1.14 → v1.0.0
Each task shows current/new version, asks for confirmation, then tags and pushes.
Auto-updated homebrew tap (
.goreleaser.yaml):- Added
brewssection so GoReleaser automatically commits the updated formula tothieso2/homebrew-tapon each release.
One setup step needed: Create a GitHub PAT with
reposcope (to push tohomebrew-tap) and add it as a secret:codegh secret set HOMEBREW_TAP_GITHUB_TOKEN --repo thieso2/sandcastle- User
commit
Assistant
There are many unrelated changes in the working tree (PostgreSQL migration, Dockerfile, etc.). I'll only commit the files we touched in this session.
Assistant
Committed
e3c17eewith the 4 relevant files:vendor/sandcastle-cli/cmd/root.go—--version/-vflagvendor/sandcastle-cli/.goreleaser.yaml— homebrew tap auto-update via GoReleaser.github/workflows/release.yml—HOMEBREW_TAP_GITHUB_TOKENenv varmise.toml—release,release:minor,release:majortasks
Now let me update CLAUDE.md with the new release workflow info.
Assistant
Done. Added a Releasing section to CLAUDE.md documenting the
mise run releaseworkflow and how the CI pipeline builds, signs, and auto-updates the Homebrew tap.