Files
yellowjacket/.gitea/workflows/homebrew-formula.yml
T
logan 2c576fa1e8 ci(release): attach the Linux, Arch and Android builds to the release
A release page with nothing to download is one nobody can use. The
Arch package and the APK are already built and merely go unattached;
the plain Linux binary is new, and is what answers 'get the latest
version' without a package manager.

scripts/release-asset.sh waits for the release to exist first.
semantic-release pushes the tag in prepare and creates the release in
publish, so the tag push that starts these workflows happens before
there is an id to upload to -- and a capacity-1 runner serialises that
into working by accident, which is the worst kind of bug.

macOS is absent because it cannot be built here: GOOS=darwin
CGO_ENABLED=0 fails at wails/v3/pkg/mac, the darwin backend being
Objective-C behind cgo. Homebrew builds from source on the user's Mac
and stays the macOS channel. Windows cross-compiles cleanly and is
still withheld: no build of it has ever been run.

All three skip v0.0.0, which is semantic-release's version floor rather
than a shipment.
2026-08-17 18:39:06 -04:00

113 lines
4.0 KiB
YAML

name: Sync Homebrew formula
# On every version tag, recompute the release tarball checksum and push an
# updated Formula/yellowjacket.rb into the Homebrew tap repo. Keeping the tap
# in a separate repo (github.com/Shadow-Puppet/homebrew-yellowjacket) is what
# lets users install with a single command:
#
# brew install shadow-puppet/yellowjacket/yellowjacket
#
# (`shadow-puppet/yellowjacket` is shorthand for the homebrew-yellowjacket repo;
# brew auto-taps it, so no separate `brew tap` step is needed.)
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Version to sync (default: the pushed tag)"
required: false
concurrency:
group: homebrew-${{ github.ref }}
cancel-in-progress: true
jobs:
sync-formula:
runs-on: ubuntu-latest
env:
# GitHub PAT (or fine-grained token) with write access to the tap repo.
TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
# Gitea source that serves the release tarball referenced by the formula.
SOURCE_TARBALL_BASE: https://git.ljones.me/yonlu/yellowjacket/archive
# separate GitHub tap repo the formula is published to.
TAP_REPO: Shadow-Puppet/homebrew-yellowjacket
steps:
- name: Check out source (for the canonical formula)
uses: actions/checkout@v4
- name: Compute version and tarball checksum
id: version
run: |
set -euo pipefail
TAG="${{ inputs.version }}"
[ -n "$TAG" ] || TAG="${GITHUB_REF_NAME}" # e.g. v0.0.1
case "$TAG" in v*) ;; *) TAG="v$TAG" ;; esac
VERSION="${TAG#v}" # e.g. 0.0.1
# v0.0.0 is semantic-release's version floor, not a shipment —
# see the bootstrap step in release.yml. Skipped cleanly rather
# than failing: this one would otherwise push a formula for a
# version that does not exist into a *public* tap.
if [ "$VERSION" = "0.0.0" ]; then
echo "v0.0.0 is the version floor, not a release; nothing to sync"
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "skip=false" >> "$GITHUB_OUTPUT"
TARBALL="${SOURCE_TARBALL_BASE}/${TAG}.tar.gz"
echo "Fetching ${TARBALL}"
# Retry briefly: the tag archive can lag a few seconds behind the push.
for attempt in 1 2 3 4 5; do
if curl -fSsL "$TARBALL" -o release.tar.gz; then
break
fi
echo "attempt ${attempt} failed, retrying..."
sleep 5
done
SHA256="$(sha256sum release.tar.gz | cut -d' ' -f1)"
echo "version=${VERSION} sha256=${SHA256}"
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
echo "SHA256=${SHA256}" >> "$GITHUB_ENV"
- name: Render the formula with the new version and checksum
if: steps.version.outputs.skip == 'false'
run: |
set -euo pipefail
src="packaging/homebrew/Formula/yellowjacket.rb"
# Rewrite only the two managed lines; the interpolated url picks up the
# new version automatically.
sed -E \
-e "s|^ version \".*\"| version \"${VERSION}\"|" \
-e "s|^ sha256 \".*\"| sha256 \"${SHA256}\"|" \
"$src" > yellowjacket.rb
echo "----- rendered formula -----"
cat yellowjacket.rb
- name: Push to the Homebrew tap repo
if: steps.version.outputs.skip == 'false'
run: |
set -euo pipefail
git clone "https://x-access-token:${TAP_TOKEN}@github.com/${TAP_REPO}.git" tap
mkdir -p tap/Formula
cp yellowjacket.rb tap/Formula/yellowjacket.rb
cd tap
git config user.name "yellowjacket-ci"
git config user.email "yj@yellowjacket.app"
if git diff --quiet; then
echo "Formula already up to date; nothing to push."
exit 0
fi
git add Formula/yellowjacket.rb
git commit -m "yellowjacket ${VERSION}"
git push origin HEAD:main