Skip to content

Commit 5881c10

Browse files
authored
Merge pull request #155 from hookdeck/chore/update-goreleaser
feat: Implement Homebrew cask migration with dual distribution
2 parents cc63567 + c92b67b commit 5881c10

File tree

8 files changed

+717
-24
lines changed

8 files changed

+717
-24
lines changed

.github/workflows/acceptance-test.yml renamed to .github/workflows/test-acceptance.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
- name: Set up Go
1818
uses: actions/setup-go@v3
1919
with:
20-
go-version: '1.18'
20+
go-version: "1.18"
2121

2222
- name: Make script executable
23-
run: chmod +x scripts/acceptance-test.sh
23+
run: chmod +x test-scripts/test-acceptance.sh
2424

2525
- name: Run acceptance tests
26-
run: ./scripts/acceptance-test.sh
26+
run: ./test-scripts/test-acceptance.sh
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Homebrew Build and Installation Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
workflow_dispatch:
9+
inputs:
10+
run_install_tests:
11+
description: "Run installation tests"
12+
required: false
13+
default: "false"
14+
type: choice
15+
options:
16+
- "false"
17+
- "true"
18+
19+
jobs:
20+
test-homebrew-build:
21+
runs-on: macos-latest
22+
23+
steps:
24+
- name: Check out code
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Go
28+
uses: actions/setup-go@v5
29+
with:
30+
go-version-file: "go.mod"
31+
32+
- name: Verify Homebrew is installed
33+
run: |
34+
echo "Homebrew version:"
35+
brew --version
36+
37+
- name: Install GoReleaser
38+
run: brew install goreleaser
39+
40+
- name: Make test script executable
41+
run: chmod +x test-scripts/test-homebrew-build.sh
42+
43+
- name: Run build validation
44+
run: ./test-scripts/test-homebrew-build.sh
45+
46+
- name: Run installation tests
47+
run: ./test-scripts/test-homebrew-build.sh --install
48+
49+
# Upload generated Homebrew formula (cask distribution has been disabled)
50+
- name: Upload generated Homebrew files
51+
if: always()
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: homebrew-files
55+
path: |
56+
dist/homebrew/Formula/hookdeck.rb
57+
retention-days: 7

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
completions/
23
dist/
34
bin/
45
coverage.txt

.goreleaser/mac.yml

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ before:
55
hooks:
66
- go mod download
77
- go generate ./...
8+
- ./scripts/completions.sh
89
project_name: hookdeck
910
builds:
1011
- id: hookdeck-darwin
@@ -37,29 +38,64 @@ checksum:
3738
name_template: "{{ .ProjectName }}-checksums.txt"
3839
snapshot:
3940
name_template: "{{ .Tag }}-next"
40-
homebrew_casks:
41+
archives:
42+
- id: hookdeck
43+
files:
44+
- completions/*
45+
- LICENSE*
46+
- README*
47+
- CHANGELOG*
48+
brews:
4149
- name: hookdeck
50+
ids:
51+
- hookdeck
4252
repository:
4353
owner: hookdeck
4454
name: homebrew-hookdeck
45-
commit_author:
46-
name: hookdeck
47-
55+
directory: Formula
4856
homepage: https://hookdeck.com
49-
description: Hookdeck CLI utility
50-
caveats: "❤ Thanks for installing the Hookdeck CLI! If this is your first time using the CLI, be sure to run `hookdeck login` first."
51-
custom_block: |
52-
postflight do
53-
system "hookdeck", "completion", "--shell", "bash"
54-
system "hookdeck", "completion", "--shell", "zsh"
55-
bash_completion.install "hookdeck-completion.bash"
56-
zsh_completion.install "hookdeck-completion.zsh"
57-
(zsh_completion/"_hookdeck").write <<~EOS
58-
#compdef hookdeck
59-
_hookdeck () {
60-
local e
61-
e=$(dirname ${funcsourcetrace[1]%:*})/hookdeck-completion.zsh
62-
if [[ -f $e ]]; then source $e; fi
63-
}
64-
EOS
65-
end
57+
description: Receive events (e.g. webhooks) on your localhost with event history, replay, and team collaboration
58+
59+
install: |
60+
bin.install "hookdeck"
61+
62+
# Install completions from pre-generated files
63+
bash_completion.install "completions/hookdeck.bash" => "hookdeck"
64+
zsh_completion.install "completions/_hookdeck"
65+
66+
caveats: |
67+
❤ Thanks for installing the Hookdeck CLI!
68+
69+
If this is your first time using the CLI, run:
70+
hookdeck login
71+
72+
# TODO: Temporarily disabled until we implement code signing
73+
# Cask distribution causes Gatekeeper issues with unsigned binaries
74+
# Will re-enable once Apple Developer certificate is in place
75+
#
76+
# homebrew_casks:
77+
# - name: hookdeck
78+
# ids:
79+
# - hookdeck
80+
# repository:
81+
# owner: hookdeck
82+
# name: homebrew-hookdeck
83+
# homepage: https://hookdeck.com
84+
# description: Receive events (e.g. webhooks) on your localhost with event history, replay, and team collaboration
85+
# # Install shell completions automatically
86+
# completions:
87+
# bash: "completions/hookdeck.bash"
88+
# zsh: "completions/_hookdeck"
89+
#
90+
# caveats: |-
91+
# Thanks for installing the Hookdeck CLI!
92+
#
93+
# ⚠️ If you see an error about a binary already existing:
94+
# brew uninstall hookdeck
95+
# brew install --cask hookdeck/hookdeck/hookdeck
96+
#
97+
# Shell completions have been installed automatically.
98+
# You may need to restart your shell for them to take effect.
99+
#
100+
# First time using the CLI? Run:
101+
# hookdeck login

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,24 @@ There are also some hidden flags that are mainly used for development and debugg
430430
* `--console-base`: Sets the web console base URL.
431431
* `--ws-base`: Sets the Websocket base URL.
432432
433+
## Troubleshooting
434+
435+
### Homebrew: Binary Already Exists Error
436+
437+
If you previously installed Hookdeck via the Homebrew formula and are upgrading to the cask version, you may see:
438+
439+
```
440+
Warning: It seems there is already a Binary at '/opt/homebrew/bin/hookdeck'
441+
from formula hookdeck; skipping link.
442+
```
443+
444+
To resolve this, uninstall the old formula version first, then install the cask:
445+
446+
```sh
447+
brew uninstall hookdeck
448+
brew install --cask hookdeck/hookdeck/hookdeck
449+
```
450+
433451
434452
## Developing
435453

scripts/completions.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Generate shell completions for Hookdeck CLI
5+
# This script is run during the GoReleaser build process to pre-generate
6+
# completion files that will be included in the release archives.
7+
8+
rm -rf completions
9+
mkdir completions
10+
11+
# Use 'go run .' to compile and run the CLI to generate completions
12+
# This works on any platform that can build Go code
13+
# The completion command writes files to the current directory, so we cd into completions/
14+
echo "Generating bash completion..."
15+
(cd completions && go run .. completion --shell bash)
16+
17+
echo "Generating zsh completion..."
18+
(cd completions && go run .. completion --shell zsh)
19+
20+
# Rename the generated files to match GoReleaser expectations
21+
mv completions/hookdeck-completion.bash completions/hookdeck.bash
22+
mv completions/hookdeck-completion.zsh completions/_hookdeck
23+
24+
# Fish completion is not currently supported by the CLI
25+
# If it gets added in the future, uncomment this:
26+
# echo "Generating fish completion..."
27+
# go run . completion --shell fish > completions/hookdeck.fish
28+
29+
echo "✅ Completions generated successfully in completions/"
30+
ls -lh completions/
File renamed without changes.

0 commit comments

Comments
 (0)