Skip to content

goreleaser: bundle shell completions in release archives - #479

Merged
michael-webster merged 2 commits into
mainfrom
goreleaser-completions
Aug 7, 2026
Merged

goreleaser: bundle shell completions in release archives#479
michael-webster merged 2 commits into
mainfrom
goreleaser-completions

Conversation

@michael-webster

@michael-webster michael-webster commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds goreleaser before hooks to generate bash and zsh completion scripts at release time
  • Bundles them in release archives at the standard UNIX paths (share/bash-completion/completions/chunk, share/zsh/site-functions/_chunk)
  • The Homebrew formula installs these to the standard completion directories automatically — no subprocess spawned on shell startup
  • Adds --output/-o flag to chunk completion bash and chunk completion zsh so the hooks don't need shell redirection or mkdir -p wrappers (mirrors circleci-cli)
  • Adds share/ to .gitignore (generated artifact)
  • completion install is unchanged and continues to work as a fallback for manual curl installs

Motivation

chunk completion install was writing source <(chunk completion zsh) to .zshrc, which spawns a chunk subprocess on every new shell session. This was generating ~400 telemetry events per day from shell startups rather than intentional user invocations.

For Homebrew users (the majority), completions now land in the right system directories during installation with no runtime cost. The completion install fallback is preserved for users who install via curl.

Reproduction steps

# 1. Build the binary and verify --output creates the file and any missing parent directories
task build
./dist/chunk completion bash --output /tmp/chunk-completion-test/chunk
./dist/chunk completion zsh --output /tmp/chunk-completion-test/_chunk
head -3 /tmp/chunk-completion-test/chunk   # → bash completion header
head -3 /tmp/chunk-completion-test/_chunk  # → #compdef chunk

# 2. Run goreleaser hooks and verify share/ is populated
goreleaser build --snapshot --clean
ls -la share/bash-completion/completions/chunk share/zsh/site-functions/_chunk

# 3. Verify the files land in the release archive
goreleaser release --snapshot --clean --skip=publish,announce,validate
tar tzf dist/chunk-cli_Darwin_arm64.tar.gz | grep share
# share/bash-completion/completions/chunk
# share/zsh/site-functions/_chunk

Test plan

  • Steps above pass locally
  • CI passes
  • After next Homebrew release: brew install chunk-cli && chunk <TAB> completes without spawning a subprocess

🤖 Generated with Claude Code

webster and others added 2 commits August 6, 2026 13:36
Writes the completion script to a file instead of stdout, creating any
missing parent directories. Mirrors the pattern from circleci-cli.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add before hooks to generate bash and zsh completion scripts into
share/ during the release build using the new --output flag. Archives
include the scripts at the standard UNIX paths:
  share/bash-completion/completions/chunk
  share/zsh/site-functions/_chunk

The Homebrew formula installs these to the standard completion
directories so completions work out of the box for Homebrew users
without any runtime subprocess on shell startup. share/ is gitignored
as a generated artifact.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@michael-webster
michael-webster force-pushed the goreleaser-completions branch from 89106f2 to 57f22da Compare August 6, 2026 17:36
@michael-webster
michael-webster marked this pull request as ready for review August 6, 2026 17:41
@michael-webster
michael-webster merged commit 6cee137 into main Aug 7, 2026
6 checks passed
@michael-webster
michael-webster deleted the goreleaser-completions branch August 7, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants