Skip to content

Commit 01ddfc4

Browse files
authored
Merge pull request #8 from Priyans-hu/chore/homebrew-support
Add Homebrew cask support
2 parents 74cb7b9 + bf8b924 commit 01ddfc4

File tree

2 files changed

+66
-8
lines changed

2 files changed

+66
-8
lines changed

.github/workflows/release.yml

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ jobs:
1515

1616
- name: Extract version
1717
id: version
18-
run: echo "version=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
18+
run: |
19+
TAG="${GITHUB_REF_NAME}"
20+
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
21+
echo "number=${TAG#v}" >> "$GITHUB_OUTPUT"
1922
2023
- name: Build release binary
2124
run: |
@@ -36,8 +39,7 @@ jobs:
3639
fi
3740
3841
# Generate Info.plist
39-
VERSION="${{ steps.version.outputs.version }}"
40-
VERSION="${VERSION#v}"
42+
VERSION="${{ steps.version.outputs.number }}"
4143
cat > "${APP}/Contents/Info.plist" << PLIST
4244
<?xml version="1.0" encoding="UTF-8"?>
4345
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -76,11 +78,63 @@ jobs:
7678
codesign -dv --verbose=4 TokenMeter.app
7779
7880
- name: Create zip
81+
env:
82+
ZIP_NAME: TokenMeter-${{ steps.version.outputs.tag }}-macos-aarch64.zip
7983
run: |
80-
ditto -c -k --keepParent TokenMeter.app TokenMeter-${{ steps.version.outputs.version }}-macos.zip
84+
ditto -c -k --keepParent TokenMeter.app "$ZIP_NAME"
85+
shasum -a 256 "$ZIP_NAME" | awk '{print $1}' > sha256.txt
86+
echo "SHA256: $(cat sha256.txt)"
8187
8288
- name: Create GitHub Release
8389
uses: softprops/action-gh-release@v2
8490
with:
85-
files: TokenMeter-${{ steps.version.outputs.version }}-macos.zip
91+
files: TokenMeter-${{ steps.version.outputs.tag }}-macos-aarch64.zip
8692
generate_release_notes: true
93+
94+
- name: Update Homebrew cask
95+
env:
96+
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
97+
run: |
98+
VERSION="${{ steps.version.outputs.number }}"
99+
SHA256=$(cat sha256.txt)
100+
TAG="${{ steps.version.outputs.tag }}"
101+
102+
CASK_CONTENT=$(cat <<RUBY
103+
cask "tokenmeter" do
104+
version "${VERSION}"
105+
sha256 "${SHA256}"
106+
107+
url "https://github.com/Priyans-hu/tokenmeter/releases/download/${TAG}/TokenMeter-${TAG}-macos-aarch64.zip"
108+
name "TokenMeter"
109+
desc "macOS menu bar app for tracking Claude Code usage, rate limits, and costs"
110+
homepage "https://github.com/Priyans-hu/tokenmeter"
111+
112+
depends_on macos: ">= :sonoma"
113+
114+
app "TokenMeter.app"
115+
116+
postflight do
117+
system_command "/usr/bin/xattr",
118+
args: ["-cr", "#{appdir}/TokenMeter.app"],
119+
sudo: false
120+
end
121+
122+
zap trash: [
123+
"~/Library/Application Support/com.priyanshugarg.tokenmeter",
124+
]
125+
end
126+
RUBY
127+
)
128+
129+
# Get current file SHA from homebrew-tap repo
130+
FILE_SHA=$(gh api repos/Priyans-hu/homebrew-tap/contents/Casks/tokenmeter.rb --jq '.sha')
131+
132+
# Update the cask file
133+
echo "$CASK_CONTENT" | gh api repos/Priyans-hu/homebrew-tap/contents/Casks/tokenmeter.rb \
134+
-X PUT \
135+
-f message="Update tokenmeter to ${TAG}" \
136+
-f content="$(echo "$CASK_CONTENT" | base64)" \
137+
-f sha="$FILE_SHA" \
138+
--silent
139+
140+
echo "Homebrew cask updated to ${TAG}"

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ Reads Claude Code's OAuth token from Keychain for real rate limit data, and pars
2222

2323
## Installation
2424

25-
### Quick Install (recommended)
25+
### Homebrew (recommended)
2626

2727
```bash
28-
curl -fsSL https://raw.githubusercontent.com/Priyans-hu/tokenmeter/main/install.sh | bash
28+
brew install Priyans-hu/tap/tokenmeter
2929
```
3030

31-
Downloads the latest release, extracts to `/Applications`, and removes quarantine.
31+
### Quick Install
32+
33+
```bash
34+
curl -fsSL https://raw.githubusercontent.com/Priyans-hu/tokenmeter/main/install.sh | bash
35+
```
3236

3337
### Manual Download
3438

0 commit comments

Comments
 (0)