Skip to content

Commit 3199bcd

Browse files
committed
Restore Sparkle, add Homebrew tap auto-update to release workflow
Sparkle remains for direct-download users. Release workflow now also updates Pribess/homebrew-tap cask formula with new version and SHA256. Requires HOMEBREW_TAP_TOKEN secret (PAT with repo scope).
1 parent 135e7f2 commit 3199bcd

File tree

1 file changed

+28
-45
lines changed

1 file changed

+28
-45
lines changed

.github/workflows/release.yml

Lines changed: 28 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
runs-on: macos-15
1414
permissions:
1515
contents: write
16+
pages: write
17+
id-token: write
1618
env:
1719
REPOSITORY_NAME: ${{ github.event.repository.name }}
1820
steps:
@@ -21,15 +23,15 @@ jobs:
2123
- name: Configure GitHub Pages
2224
uses: actions/configure-pages@v5
2325

24-
- name: Build release app bundle
26+
- name: Build
2527
run: |
2628
version="${GITHUB_REF_NAME#v}"
2729
owner="$(printf '%s' "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')"
2830
export APP_VERSION="$version"
2931
export SU_FEED_URL="https://${owner}.github.io/${REPOSITORY_NAME}/appcast.xml"
3032
bash macos/scripts/build.sh
3133
32-
- name: Package and verify release artifacts
34+
- name: Package
3335
env:
3436
EXPECT_FEED_URL: '1'
3537
run: |
@@ -47,36 +49,6 @@ jobs:
4749
-f tag_name="${GITHUB_REF_NAME}" \
4850
--jq '.body' > dist/release-notes.md
4951
50-
python3 - <<'PY'
51-
import json
52-
import os
53-
import urllib.request
54-
55-
with open("dist/release-notes.md", "r", encoding="utf-8") as fh:
56-
markdown = fh.read()
57-
58-
request = urllib.request.Request(
59-
"https://api.github.com/markdown",
60-
data=json.dumps({
61-
"text": markdown,
62-
"mode": "gfm",
63-
"context": os.environ["GITHUB_REPOSITORY"],
64-
}).encode("utf-8"),
65-
headers={
66-
"Authorization": f"Bearer {os.environ['GH_TOKEN']}",
67-
"Accept": "application/vnd.github+json",
68-
"X-GitHub-Api-Version": "2022-11-28",
69-
},
70-
method="POST",
71-
)
72-
73-
with urllib.request.urlopen(request) as response:
74-
html = response.read().decode("utf-8")
75-
76-
with open("dist/archives/UsageKit.html", "w", encoding="utf-8") as fh:
77-
fh.write(html)
78-
PY
79-
8052
- name: Create release
8153
uses: softprops/action-gh-release@v2
8254
with:
@@ -90,8 +62,8 @@ jobs:
9062
SPARKLE_PRIVATE_KEY: ${{ secrets.SPARKLE_PRIVATE_KEY }}
9163
run: |
9264
if [[ -z "${SPARKLE_PRIVATE_KEY:-}" ]]; then
93-
echo "::error::Missing SPARKLE_PRIVATE_KEY repository secret."
94-
exit 1
65+
echo "::warning::Missing SPARKLE_PRIVATE_KEY, skipping appcast generation"
66+
exit 0
9567
fi
9668
9769
cp macos/UsageKit.zip dist/archives/UsageKit.zip
@@ -105,20 +77,31 @@ jobs:
10577
-o dist/site/appcast.xml
10678
10779
- name: Upload appcast for GitHub Pages
80+
if: hashFiles('dist/site/appcast.xml') != ''
10881
uses: actions/upload-pages-artifact@v4
10982
with:
11083
path: dist/site
11184

112-
deploy_appcast:
113-
needs: release
114-
runs-on: ubuntu-latest
115-
permissions:
116-
pages: write
117-
id-token: write
118-
environment:
119-
name: github-pages
120-
url: ${{ steps.deployment.outputs.page_url }}
121-
steps:
12285
- name: Deploy appcast
123-
id: deployment
86+
if: hashFiles('dist/site/appcast.xml') != ''
12487
uses: actions/deploy-pages@v4
88+
89+
- name: Update Homebrew tap
90+
env:
91+
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
92+
run: |
93+
if [[ -z "${GH_TOKEN:-}" ]]; then
94+
echo "::warning::Missing HOMEBREW_TAP_TOKEN, skipping tap update"
95+
exit 0
96+
fi
97+
98+
version="${GITHUB_REF_NAME#v}"
99+
sha=$(shasum -a 256 macos/UsageKit.dmg | awk '{print $1}')
100+
101+
gh repo clone Pribess/homebrew-tap /tmp/homebrew-tap
102+
printf 'cask "usagekit" do\n version "%s"\n sha256 "%s"\n\n url "https://github.com/Pribess/UsageKit/releases/download/v#{version}/UsageKit.dmg"\n name "UsageKit"\n desc "Menu bar app that tracks Claude and Codex usage"\n homepage "https://github.com/Pribess/UsageKit"\n\n depends_on macos: ">= :sonoma"\n\n app "UsageKit.app"\n\n zap trash: [\n "~/.config/usagekit",\n ]\nend\n' "$version" "$sha" > /tmp/homebrew-tap/Casks/usagekit.rb
103+
104+
cd /tmp/homebrew-tap
105+
git add Casks/usagekit.rb
106+
git commit -m "Update UsageKit to $version"
107+
git push

0 commit comments

Comments
 (0)