Skip to content

Commit c1a272d

Browse files
committed
fix: use deploy key for homebrew-tap instead of PAT
1 parent 24237d9 commit c1a272d

File tree

2 files changed

+82
-19
lines changed

2 files changed

+82
-19
lines changed

.github/workflows/release.yml

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,83 @@ jobs:
2323
args: release --clean
2424
env:
2525
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26-
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
26+
27+
homebrew:
28+
runs-on: ubuntu-latest
29+
needs: goreleaser
30+
steps:
31+
- name: Set up SSH deploy key
32+
uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581d1d7c # v0.9.1
33+
with:
34+
ssh-private-key: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }}
35+
36+
- name: Update Homebrew formula
37+
env:
38+
TAG: ${{ github.ref_name }}
39+
run: |
40+
VERSION="${TAG#v}"
41+
BASE_URL="https://github.com/serpapi/serpapi-cli/releases/download/${TAG}"
42+
43+
# Fetch checksums
44+
CHECKSUMS=$(curl -fsSL "${BASE_URL}/serpapi_${VERSION}_checksums.txt")
45+
46+
get_sha() {
47+
echo "$CHECKSUMS" | grep "$1" | awk '{print $1}'
48+
}
49+
50+
SHA_DARWIN_AMD64=$(get_sha "serpapi_${VERSION}_darwin_amd64.tar.gz")
51+
SHA_DARWIN_ARM64=$(get_sha "serpapi_${VERSION}_darwin_arm64.tar.gz")
52+
SHA_LINUX_AMD64=$(get_sha "serpapi_${VERSION}_linux_amd64.tar.gz")
53+
SHA_LINUX_ARM64=$(get_sha "serpapi_${VERSION}_linux_arm64.tar.gz")
54+
55+
cat > /tmp/serpapi-cli.rb <<FORMULA
56+
class SerpapiCli < Formula
57+
desc "HTTP client for structured web search data via SerpApi"
58+
homepage "https://serpapi.com"
59+
version "${VERSION}"
60+
license "MIT"
61+
62+
on_macos do
63+
if Hardware::CPU.arm?
64+
url "${BASE_URL}/serpapi_${VERSION}_darwin_arm64.tar.gz"
65+
sha256 "${SHA_DARWIN_ARM64}"
66+
else
67+
url "${BASE_URL}/serpapi_${VERSION}_darwin_amd64.tar.gz"
68+
sha256 "${SHA_DARWIN_AMD64}"
69+
end
70+
end
71+
72+
on_linux do
73+
if Hardware::CPU.arm?
74+
url "${BASE_URL}/serpapi_${VERSION}_linux_arm64.tar.gz"
75+
sha256 "${SHA_LINUX_ARM64}"
76+
else
77+
url "${BASE_URL}/serpapi_${VERSION}_linux_amd64.tar.gz"
78+
sha256 "${SHA_LINUX_AMD64}"
79+
end
80+
end
81+
82+
def install
83+
bin.install "serpapi"
84+
end
85+
86+
test do
87+
assert_match version.to_s, shell_output("#{bin}/serpapi --version")
88+
assert_match "search", shell_output("#{bin}/serpapi --help")
89+
assert_match "No API key", shell_output("#{bin}/serpapi account 2>&1", 2)
90+
assert_match "No API key", shell_output("#{bin}/serpapi archive abc123 2>&1", 2)
91+
assert_match "Invalid archive ID", shell_output("#{bin}/serpapi --api-key x archive ../bad 2>&1", 2)
92+
end
93+
end
94+
FORMULA
95+
96+
# Clone, update formula, push
97+
git clone git@github.com:serpapi/homebrew-tap.git
98+
cp /tmp/serpapi-cli.rb homebrew-tap/Formula/serpapi-cli.rb
99+
cd homebrew-tap
100+
git config user.email "github-actions[bot]@users.noreply.github.com"
101+
git config user.name "github-actions[bot]"
102+
git add Formula/serpapi-cli.rb
103+
git commit -m "serpapi-cli ${VERSION}"
104+
git push
105+

.goreleaser.yml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,5 @@ changelog:
4444
- "^docs:"
4545
- "^test:"
4646

47-
brews:
48-
- name: serpapi-cli
49-
repository:
50-
owner: serpapi
51-
name: homebrew-tap
52-
token: "{{ .Env.HOMEBREW_TAP_TOKEN }}"
53-
directory: Formula
54-
homepage: https://serpapi.com
55-
description: "HTTP client for structured web search data via SerpApi"
56-
license: MIT
57-
install: |
58-
bin.install "serpapi"
59-
test: |
60-
assert_match version.to_s, shell_output("#{bin}/serpapi --version")
61-
assert_match "search", shell_output("#{bin}/serpapi --help")
62-
assert_match "No API key", shell_output("#{bin}/serpapi account 2>&1", 2)
63-
assert_match "No API key", shell_output("#{bin}/serpapi archive abc123 2>&1", 2)
64-
assert_match "Invalid archive ID", shell_output("#{bin}/serpapi --api-key x archive ../bad 2>&1", 2)
47+
announce:
48+
skip: true

0 commit comments

Comments
 (0)