Skip to content

Commit d122026

Browse files
committed
Add Homebrew documentation for versioning
- Introduced a new document, HOMEBREW.md, detailing how to set the version for the Homebrew formula. - Included instructions for injecting version information at build time to ensure the binary reports the correct version instead of 'dev'.
1 parent 79d6742 commit d122026

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

docs/HOMEBREW.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Homebrew tap — version ldflag
2+
3+
The binary shows its version with `cowardly version` or `cowardly -v`. To avoid showing `dev`, the **Homebrew formula must inject the version** at build time.
4+
5+
In the tap repo [miguelmartens/homebrew-cowardly](https://github.com/miguelmartens/homebrew-cowardly), ensure the formula passes the version in ldflags:
6+
7+
```ruby
8+
def install
9+
ldflags = "-s -w -X main.Version=v#{version}"
10+
system "go", "build", *std_go_args(ldflags: ldflags), "./cmd/cowardly"
11+
end
12+
```
13+
14+
So the built binary reports e.g. `Cowardly version: v0.2.5` instead of `Cowardly version: dev`. Homebrew’s `version` is taken from the tag in the tarball URL (e.g. `v0.2.5``version` is `0.2.5`), hence `v#{version}`.

0 commit comments

Comments
 (0)