mirror of
https://github.com/bybrooklyn/openbitdo.git
synced 2026-03-19 04:12:56 -04:00
release: prepare v0.0.1-rc.4
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
class Openbitdo < Formula
|
||||
desc "Beginner-first clean-room 8BitDo TUI utility"
|
||||
homepage "https://github.com/bybrooklyn/openbitdo"
|
||||
license "BSD-3-Clause"
|
||||
version "0.0.1-rc.1"
|
||||
|
||||
on_macos do
|
||||
if Hardware::CPU.arm?
|
||||
url "https://github.com/bybrooklyn/openbitdo/releases/download/v0.0.1-rc.1/openbitdo-v0.0.1-rc.1-macos-arm64.tar.gz"
|
||||
sha256 "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
end
|
||||
end
|
||||
|
||||
on_linux do
|
||||
if Hardware::CPU.intel?
|
||||
url "https://github.com/bybrooklyn/openbitdo/releases/download/v0.0.1-rc.1/openbitdo-v0.0.1-rc.1-linux-x86_64.tar.gz"
|
||||
sha256 "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
elsif Hardware::CPU.arm?
|
||||
url "https://github.com/bybrooklyn/openbitdo/releases/download/v0.0.1-rc.1/openbitdo-v0.0.1-rc.1-linux-aarch64.tar.gz"
|
||||
sha256 "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
end
|
||||
end
|
||||
|
||||
# Release automation rewrites checksums in the tap with authoritative values
|
||||
# from published assets.
|
||||
def install
|
||||
bin.install "bin/openbitdo"
|
||||
end
|
||||
|
||||
test do
|
||||
assert_match "openbitdo", shell_output("#{bin}/openbitdo --help")
|
||||
end
|
||||
end
|
||||
@@ -1,14 +1,24 @@
|
||||
# Homebrew Packaging
|
||||
|
||||
Formula source lives in `Formula/openbitdo.rb`.
|
||||
Template source used for release rendering: `Formula/openbitdo.rb.tmpl`.
|
||||
Homebrew publishing uses the separate tap repo `bybrooklyn/homebrew-openbitdo`.
|
||||
|
||||
Planned tap:
|
||||
- `bybrooklyn/homebrew-openbitdo`
|
||||
## Source Of Truth
|
||||
|
||||
Current status:
|
||||
- release workflow computes checksum-pinned formula values from published assets
|
||||
- tap sync remains gated by `HOMEBREW_PUBLISH_ENABLED=1`
|
||||
- template: `packaging/homebrew/Formula/openbitdo.rb.tmpl`
|
||||
- renderer: `packaging/scripts/render_release_metadata.sh`
|
||||
- sync helper: `packaging/homebrew/sync_tap.sh`
|
||||
|
||||
Optional sync helper:
|
||||
- `sync_tap.sh` (disabled by default unless `HOMEBREW_PUBLISH_ENABLED=1`)
|
||||
The main repo does not keep a checked-in rendered formula. Release rendering produces the formula from published assets, and the tap repo is the canonical published destination.
|
||||
|
||||
## Publish Flow
|
||||
|
||||
1. Publish GitHub release assets for a `v*` tag.
|
||||
2. Render a checksum-pinned formula from those assets.
|
||||
3. Upload the rendered formula as a workflow artifact for audit.
|
||||
4. Sync the rendered formula to `bybrooklyn/homebrew-openbitdo`.
|
||||
|
||||
## Required Controls
|
||||
|
||||
- repo variable `HOMEBREW_PUBLISH_ENABLED=1`
|
||||
- repo variable `HOMEBREW_TAP_REPO=bybrooklyn/homebrew-openbitdo`
|
||||
- secret `HOMEBREW_TAP_TOKEN`
|
||||
|
||||
@@ -23,9 +23,22 @@ HOMEBREW_TAP_TOKEN="$(
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
TAP_REPO="${HOMEBREW_TAP_REPO:-bybrooklyn/homebrew-openbitdo}"
|
||||
FORMULA_SOURCE="${FORMULA_SOURCE:-$ROOT/packaging/homebrew/Formula/openbitdo.rb}"
|
||||
FORMULA_SOURCE="${FORMULA_SOURCE:-}"
|
||||
TMP="$(mktemp -d)"
|
||||
|
||||
decode_base64() {
|
||||
if base64 --help 2>/dev/null | grep -q -- "--decode"; then
|
||||
base64 --decode
|
||||
else
|
||||
base64 -D
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ -z "$FORMULA_SOURCE" ]]; then
|
||||
echo "FORMULA_SOURCE must point to a rendered formula; run render_release_metadata.sh first" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$FORMULA_SOURCE" ]]; then
|
||||
echo "formula source not found: $FORMULA_SOURCE" >&2
|
||||
exit 1
|
||||
@@ -69,7 +82,7 @@ remote_content_file="$TMP/remote_formula.rb"
|
||||
|
||||
if api_with_fallback "repos/${TAP_REPO}/contents/${formula_path}?ref=main" >"$TMP/remote.json" 2>/dev/null; then
|
||||
remote_sha="$(jq -r '.sha // ""' "$TMP/remote.json")"
|
||||
jq -r '.content // ""' "$TMP/remote.json" | tr -d '\n' | base64 --decode >"$remote_content_file"
|
||||
jq -r '.content // ""' "$TMP/remote.json" | tr -d '\n' | decode_base64 >"$remote_content_file"
|
||||
if cmp -s "$FORMULA_SOURCE" "$remote_content_file"; then
|
||||
echo "no formula changes to push"
|
||||
exit 0
|
||||
|
||||
98
packaging/homebrew/test_sync_tap.sh
Executable file
98
packaging/homebrew/test_sync_tap.sh
Executable file
@@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
MOCK_BIN="$TMP/bin"
|
||||
mkdir -p "$MOCK_BIN"
|
||||
|
||||
cat >"$MOCK_BIN/gh" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
STATE_DIR="${MOCK_GH_STATE_DIR:?}"
|
||||
|
||||
if [[ "${1:-}" != "api" ]]; then
|
||||
echo "mock gh only supports api" >&2
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
|
||||
method="GET"
|
||||
if [[ "${1:-}" == "--method" ]]; then
|
||||
method="$2"
|
||||
shift 2
|
||||
fi
|
||||
|
||||
endpoint="$1"
|
||||
shift
|
||||
|
||||
case "${method}:${endpoint}" in
|
||||
GET:repos/*/contents/Formula/openbitdo.rb\?ref=main)
|
||||
if [[ -f "$STATE_DIR/remote_formula.rb" ]]; then
|
||||
content="$(base64 < "$STATE_DIR/remote_formula.rb" | tr -d '\n')"
|
||||
printf '{"sha":"remote-sha","content":"%s"}\n' "$content"
|
||||
exit 0
|
||||
fi
|
||||
exit 1
|
||||
;;
|
||||
PUT:repos/*/contents/Formula/openbitdo.rb)
|
||||
content=""
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ "$1" == "-f" ]]; then
|
||||
case "$2" in
|
||||
content=*)
|
||||
content="${2#content=}"
|
||||
;;
|
||||
esac
|
||||
shift 2
|
||||
else
|
||||
shift
|
||||
fi
|
||||
done
|
||||
printf '%s' "$content" | base64 --decode >"$STATE_DIR/updated_formula.rb"
|
||||
echo "put" >>"$STATE_DIR/requests.log"
|
||||
printf '{"content":{"sha":"new-sha"}}\n'
|
||||
;;
|
||||
*)
|
||||
echo "unexpected mock gh call: ${method} ${endpoint}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
EOF
|
||||
chmod +x "$MOCK_BIN/gh"
|
||||
|
||||
FORMULA_SOURCE="$TMP/openbitdo.rb"
|
||||
cat >"$FORMULA_SOURCE" <<'EOF'
|
||||
class Openbitdo < Formula
|
||||
desc "OpenBitdo"
|
||||
end
|
||||
EOF
|
||||
|
||||
run_sync() {
|
||||
PATH="$MOCK_BIN:$PATH" \
|
||||
MOCK_GH_STATE_DIR="$TMP/mock-state" \
|
||||
GH_TOKEN="job-token" \
|
||||
HOMEBREW_TAP_TOKEN="tap-token" \
|
||||
HOMEBREW_TAP_REPO="bybrooklyn/homebrew-openbitdo" \
|
||||
HOMEBREW_PUBLISH_ENABLED="1" \
|
||||
FORMULA_SOURCE="$FORMULA_SOURCE" \
|
||||
bash "$ROOT/packaging/homebrew/sync_tap.sh"
|
||||
}
|
||||
|
||||
mkdir -p "$TMP/mock-state"
|
||||
cp "$FORMULA_SOURCE" "$TMP/mock-state/remote_formula.rb"
|
||||
run_sync >"$TMP/noop.out"
|
||||
grep -Fq "no formula changes to push" "$TMP/noop.out"
|
||||
test ! -f "$TMP/mock-state/updated_formula.rb"
|
||||
|
||||
cat >"$TMP/mock-state/remote_formula.rb" <<'EOF'
|
||||
class Openbitdo < Formula
|
||||
desc "Old formula"
|
||||
end
|
||||
EOF
|
||||
run_sync >"$TMP/update.out"
|
||||
grep -Fq "updated bybrooklyn/homebrew-openbitdo:Formula/openbitdo.rb" "$TMP/update.out"
|
||||
cmp -s "$FORMULA_SOURCE" "$TMP/mock-state/updated_formula.rb"
|
||||
Reference in New Issue
Block a user