Skip to content

Commit 1a20a97

Browse files
committed
Publish signed releases through Homebrew
1 parent 0f0d126 commit 1a20a97

3 files changed

Lines changed: 78 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,33 @@ jobs:
3636
env:
3737
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3838
run: gh release upload "${GITHUB_REF_NAME}" .build/LocalWrapMac-Signed/*.dmg .build/LocalWrapMac-Signed/*.sha256 --clobber
39+
- name: Check out Homebrew tap
40+
uses: actions/checkout@v6
41+
with:
42+
repository: tcballard/homebrew-tap
43+
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
44+
path: homebrew-tap
45+
- name: Update Homebrew Cask
46+
env:
47+
VERSION: ${{ github.ref_name }}
48+
run: |
49+
VERSION="${VERSION#v}"
50+
SHA256="$(cat ".build/LocalWrapMac-Signed/LocalWrap-${VERSION}-universal.dmg.sha256")"
51+
./script/render_homebrew_cask.sh homebrew-tap/Casks/localwrap.rb "$VERSION" "$SHA256"
52+
ruby -c homebrew-tap/Casks/localwrap.rb
53+
- name: Publish GitHub Release
54+
env:
55+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
run: gh release edit "${GITHUB_REF_NAME}" --draft=false
57+
- name: Publish Homebrew Cask
58+
working-directory: homebrew-tap
59+
run: |
60+
if git diff --quiet -- Casks/localwrap.rb; then
61+
echo "Cask is already current."
62+
exit 0
63+
fi
64+
git config user.name "github-actions[bot]"
65+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
66+
git add Casks/localwrap.rb
67+
git commit -m "Update LocalWrap to ${GITHUB_REF_NAME#v}"
68+
git push origin HEAD:main

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ The Release product is the universal `LocalWrap.app`, bundle ID
3737
copies compatible data from the former Electron LocalWrap store without editing
3838
the source file.
3939

40+
## Install with Homebrew
41+
42+
Signed releases are published through the `tcballard/homebrew-tap` Cask:
43+
44+
```bash
45+
brew tap tcballard/tap
46+
brew install --cask localwrap
47+
```
48+
49+
After notarization succeeds, the release workflow publishes the GitHub Release
50+
and updates the Cask with the exact DMG version and SHA-256. The repository
51+
secret `HOMEBREW_TAP_TOKEN` must have Contents read/write access to
52+
`tcballard/homebrew-tap`.
53+
4054
## Signed distribution
4155

4256
`./script/release_native_macos.sh` archives, Developer ID-signs, packages,

script/render_homebrew_cask.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
OUTPUT="${1:?usage: render_homebrew_cask.sh OUTPUT VERSION SHA256}"
5+
VERSION="${2:?usage: render_homebrew_cask.sh OUTPUT VERSION SHA256}"
6+
SHA256="${3:?usage: render_homebrew_cask.sh OUTPUT VERSION SHA256}"
7+
8+
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z]+)*$ ]] \
9+
|| { echo "error: invalid version: $VERSION" >&2; exit 2; }
10+
[[ "$SHA256" =~ ^[0-9a-f]{64}$ ]] \
11+
|| { echo "error: SHA-256 must be 64 lowercase hexadecimal characters" >&2; exit 2; }
12+
13+
mkdir -p "$(dirname "$OUTPUT")"
14+
sed -e "s/__VERSION__/$VERSION/g" -e "s/__SHA256__/$SHA256/g" >"$OUTPUT" <<'RUBY'
15+
cask "localwrap" do
16+
version "__VERSION__"
17+
sha256 "__SHA256__"
18+
19+
url "https://github.com/tcballard/LocalWrap/releases/download/v#{version}/LocalWrap-#{version}-universal.dmg"
20+
name "LocalWrap"
21+
desc "Cockpit for localhost development projects"
22+
homepage "https://github.com/tcballard/LocalWrap"
23+
24+
depends_on macos: :sequoia
25+
26+
app "LocalWrap.app"
27+
28+
zap trash: [
29+
"~/Library/Application Support/LocalWrapNative",
30+
"~/Library/Preferences/com.localwrap.app.plist",
31+
"~/Library/Saved Application State/com.localwrap.app.savedState",
32+
]
33+
end
34+
RUBY

0 commit comments

Comments
 (0)