Skip to content

Commit 9bae873

Browse files
Add Homebrew tap automation and bump to 0.3.1
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 99a4ac1 commit 9bae873

5 files changed

Lines changed: 120 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,21 @@ jobs:
323323

324324
- name: Publish package
325325
run: npm publish --access public
326+
327+
update-homebrew:
328+
name: Update Homebrew tap
329+
runs-on: ubuntu-latest
330+
needs: publish-release
331+
if: startsWith(github.ref, 'refs/tags/v')
332+
steps:
333+
- name: Checkout
334+
uses: actions/checkout@v4
335+
with:
336+
ref: ${{ github.ref_name }}
337+
338+
- name: Update tap formula
339+
env:
340+
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
341+
run: |
342+
VERSION="${GITHUB_REF_NAME#v}"
343+
./homebrew/update-tap.sh "$VERSION"

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "attn"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
edition = "2024"
55
description = "A beautiful markdown viewer that launches from the CLI"
66
license = "MIT"

homebrew/attn.rb.template

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
class Attn < Formula
2+
desc "A beautiful markdown viewer that launches from the CLI"
3+
homepage "https://github.com/lightsofapollo/attn"
4+
license "MIT"
5+
version "%%VERSION%%"
6+
7+
on_macos do
8+
on_arm do
9+
url "https://github.com/lightsofapollo/attn/releases/download/v#{version}/attn-v#{version}-darwin-arm64"
10+
sha256 "%%SHA256_DARWIN_ARM64%%"
11+
end
12+
end
13+
14+
on_linux do
15+
on_intel do
16+
url "https://github.com/lightsofapollo/attn/releases/download/v#{version}/attn-v#{version}-linux-x64"
17+
sha256 "%%SHA256_LINUX_X64%%"
18+
end
19+
end
20+
21+
def install
22+
downloaded = Dir["attn-v*"].first
23+
if downloaded
24+
mv downloaded, "attn"
25+
end
26+
chmod 0755, "attn"
27+
bin.install "attn"
28+
end
29+
30+
test do
31+
assert_match "markdown viewer", shell_output("#{bin}/attn --help")
32+
end
33+
end

homebrew/update-tap.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Updates the homebrew-attn tap formula with real SHA256 values from a release.
5+
#
6+
# Usage:
7+
# ./homebrew/update-tap.sh <version>
8+
#
9+
# Requires: curl, gh (for pushing to the tap repo)
10+
#
11+
# Called by CI after publish-release, or manually after cutting a release.
12+
13+
REPO="lightsofapollo/attn"
14+
TAP_REPO="lightsofapollo/homebrew-attn"
15+
16+
VERSION="${1:?Usage: update-tap.sh <version>}"
17+
TAG="v${VERSION}"
18+
19+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
20+
TEMPLATE="${SCRIPT_DIR}/attn.rb.template"
21+
22+
if [ ! -f "$TEMPLATE" ]; then
23+
echo "Template not found: ${TEMPLATE}" >&2
24+
exit 1
25+
fi
26+
27+
echo "Fetching SHA256 checksums for ${TAG}..."
28+
29+
SHA_DARWIN_ARM64="$(curl -sfL "https://github.com/${REPO}/releases/download/${TAG}/attn-${TAG}-darwin-arm64.sha256" | awk '{print $1}')"
30+
SHA_LINUX_X64="$(curl -sfL "https://github.com/${REPO}/releases/download/${TAG}/attn-${TAG}-linux-x64.sha256" | awk '{print $1}')"
31+
32+
if [ -z "$SHA_DARWIN_ARM64" ]; then
33+
echo "Failed to fetch darwin-arm64 SHA256" >&2
34+
exit 1
35+
fi
36+
if [ -z "$SHA_LINUX_X64" ]; then
37+
echo "Failed to fetch linux-x64 SHA256" >&2
38+
exit 1
39+
fi
40+
41+
echo " darwin-arm64: ${SHA_DARWIN_ARM64}"
42+
echo " linux-x64: ${SHA_LINUX_X64}"
43+
44+
# Generate formula from template
45+
FORMULA="$(sed \
46+
-e "s/%%VERSION%%/${VERSION}/g" \
47+
-e "s/%%SHA256_DARWIN_ARM64%%/${SHA_DARWIN_ARM64}/g" \
48+
-e "s/%%SHA256_LINUX_X64%%/${SHA_LINUX_X64}/g" \
49+
"$TEMPLATE")"
50+
51+
# Get the current file SHA from the tap repo (needed for the GitHub API update)
52+
CURRENT_SHA="$(gh api "repos/${TAP_REPO}/contents/Formula/attn.rb" --jq '.sha' 2>/dev/null || true)"
53+
54+
ARGS=(
55+
--method PUT
56+
--field "message=Update attn to ${VERSION}"
57+
--field "content=$(echo "$FORMULA" | base64)"
58+
--field "branch=main"
59+
)
60+
61+
if [ -n "$CURRENT_SHA" ]; then
62+
ARGS+=(--field "sha=${CURRENT_SHA}")
63+
fi
64+
65+
gh api "repos/${TAP_REPO}/contents/Formula/attn.rb" "${ARGS[@]}"
66+
67+
echo "Formula updated in ${TAP_REPO}"

0 commit comments

Comments
 (0)