Skip to content

Homebrew Release

Homebrew Release #4

name: Homebrew Release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
inputs:
version:
description: "Version to release (e.g. 1.2.3)"
required: true
type: string
jobs:
compile:
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
target:
- bun-darwin-arm64
- bun-darwin-x64
- bun-linux-x64
- bun-linux-arm64
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.version || github.ref_name }}
- uses: oven-sh/setup-bun@v2
- uses: actions/cache@v5
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}
restore-keys: ${{ runner.os }}-bun-
- run: bun install --frozen-lockfile
- name: Build compiled binary
run: bun run build:compile -- --target ${{ matrix.target }}
- name: Package binary
run: |
cd dist
cp klovi-${{ matrix.target }} klovi
tar -czf klovi-${{ matrix.target }}.tar.gz klovi
rm klovi
- name: Upload release asset
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "${{ inputs.version || github.ref_name }}" dist/klovi-${{ matrix.target }}.tar.gz --clobber
update-tap:
runs-on: ubuntu-latest
needs: compile
environment: homebrew
steps:
- name: Download release assets and update tap
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
VERSION: ${{ inputs.version || github.ref_name }}
REPO: ${{ github.repository }}
run: |
set -e
# Download all archives and compute checksums
for target in bun-darwin-arm64 bun-darwin-x64 bun-linux-x64 bun-linux-arm64; do
curl -L -o "klovi-${target}.tar.gz" \
"https://github.com/${REPO}/releases/download/${VERSION}/klovi-${target}.tar.gz"
done
SHA_DARWIN_ARM64=$(sha256sum klovi-bun-darwin-arm64.tar.gz | cut -d' ' -f1)
SHA_DARWIN_X64=$(sha256sum klovi-bun-darwin-x64.tar.gz | cut -d' ' -f1)
SHA_LINUX_X64=$(sha256sum klovi-bun-linux-x64.tar.gz | cut -d' ' -f1)
SHA_LINUX_ARM64=$(sha256sum klovi-bun-linux-arm64.tar.gz | cut -d' ' -f1)
BASE_URL="https://github.com/${REPO}/releases/download/${VERSION}"
# Clone the tap repo
git clone "https://x-access-token:${GH_TOKEN}@github.com/cookielab/homebrew-tap.git"
cd homebrew-tap
mkdir -p Formula
cat > Formula/klovi.rb << FORMULA
class Klovi < Formula
desc "A local web viewer for Claude Code session history"
homepage "https://github.com/${REPO}"
version "${VERSION}"
license "MIT"
on_macos do
on_arm do
url "${BASE_URL}/klovi-bun-darwin-arm64.tar.gz"
sha256 "${SHA_DARWIN_ARM64}"
end
on_intel do
url "${BASE_URL}/klovi-bun-darwin-x64.tar.gz"
sha256 "${SHA_DARWIN_X64}"
end
end
on_linux do
on_arm do
url "${BASE_URL}/klovi-bun-linux-arm64.tar.gz"
sha256 "${SHA_LINUX_ARM64}"
end
on_intel do
url "${BASE_URL}/klovi-bun-linux-x64.tar.gz"
sha256 "${SHA_LINUX_X64}"
end
end
def install
bin.install "klovi"
end
test do
assert_match "Klovi", shell_output("#{bin}/klovi --help")
end
end
FORMULA
# Remove leading whitespace from heredoc indentation
sed -i 's/^ //' Formula/klovi.rb
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/klovi.rb
git commit -m "Update klovi to ${VERSION}"
git push