fj/scripts/render-homebrew-formula.sh
Stephen Way 71e536ffd8
Some checks are pending
ci / check (push) Waiting to run
release / build (darwin-aarch64, macos, aarch64-apple-darwin) (push) Waiting to run
release / build (darwin-x86_64, macos, x86_64-apple-darwin) (push) Waiting to run
release / build (rust:1.95-bookworm, linux-x86_64, docker, x86_64-unknown-linux-gnu) (push) Waiting to run
release / publish (push) Blocked by required conditions
open-source readiness: release workflow, homebrew template, templates, compat doc
Release infrastructure:
* .forgejo/workflows/release.yml: on v* tags, builds darwin-aarch64,
  darwin-x86_64, linux-x86_64 tarballs, computes SHA256SUMS, uploads to
  the Forgejo release, and writes a ready-to-commit fj.rb formula.
* dist/homebrew/fj.rb.tmpl + scripts/render-homebrew-formula.sh for
  local rendering. Publishes into rasterandstate/homebrew-tap.

Issue + PR templates:
* .forgejo/issue_template/{bug,feature,api-gap}.md so triage isn't
  guessing at the user's environment.
* .forgejo/pull_request_template.md with a fmt/clippy/test checklist
  and a "what to update" surface-changes section.

README demo scaffolding:
* scripts/record-demo.sh drives asciinema through a representative
  ~30s session covering --version, repo view (auto-detect), issue/pr
  list, api, --json-fields, browse.
* README has a commented-out asciicast embed waiting for the v0.1.0
  recording.

Compatibility:
* docs/compatibility.md: tested Forgejo versions, caveats for older
  Gitea (≤1.19), Forgejo-only endpoints we expose.
* `fj auth login` now probes /api/v1/version once and warns to stderr
  when the server reports a pre-7.x version. Parser is pure-fn tested
  (modern, old, unparseable cases).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 15:09:18 -07:00

54 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# Render dist/homebrew/fj.rb from the template + a release's SHA256SUMS.
#
# Usage:
# ./scripts/render-homebrew-formula.sh <version>
#
# Reads SHA256SUMS from the Forgejo release for the given version and writes
# a ready-to-commit fj.rb. Then paste that into rasterandstate/homebrew-tap.
#
# Requires: curl, awk, jq.
set -euo pipefail
VERSION="${1:?version required, e.g. 0.1.0}"
TAG="v${VERSION#v}"
VERSION="${VERSION#v}"
REPO="rasterstate/fj"
HOST="https://rasterhub.com"
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
SUMS_URL="$HOST/$REPO/releases/download/$TAG/SHA256SUMS"
echo "fetching $SUMS_URL"
curl -fsSL "$SUMS_URL" -o "$TMP/SHA256SUMS"
extract() {
awk -v pat="$1" '$2 ~ pat {print $1; exit}' "$TMP/SHA256SUMS"
}
SHA_ARM=$(extract "darwin-aarch64\\.tar\\.gz$")
SHA_X64=$(extract "darwin-x86_64\\.tar\\.gz$")
SHA_LIN=$(extract "linux-x86_64\\.tar\\.gz$")
for s in "$SHA_ARM" "$SHA_X64" "$SHA_LIN"; do
[ -n "$s" ] || { echo "missing SHA in SHA256SUMS"; cat "$TMP/SHA256SUMS"; exit 1; }
done
OUT="dist/homebrew/fj.rb"
sed \
-e "s/@@VERSION@@/$VERSION/g" \
-e "s/@@SHA_DARWIN_AARCH64@@/$SHA_ARM/g" \
-e "s/@@SHA_DARWIN_X86_64@@/$SHA_X64/g" \
-e "s/@@SHA_LINUX_X86_64@@/$SHA_LIN/g" \
dist/homebrew/fj.rb.tmpl > "$OUT"
echo "wrote $OUT"
echo ""
echo "next:"
echo " cp $OUT ~/path/to/homebrew-tap/Formula/fj.rb"
echo " cd ~/path/to/homebrew-tap"
echo " git commit -am 'fj $VERSION'"
echo " git push"