|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Render the Homebrew cask and check what a release would publish. |
| 3 | +# |
| 4 | +# Only a release writes the cask, into a tap with no CI, so a fault reaches |
| 5 | +# users as their next `brew install` -- how the deprecated `postflight` stanza |
| 6 | +# shipped (localstack/lstk#501, localstack/homebrew-tap#7). |
| 7 | +# |
| 8 | +# Homebrew's own linters need Homebrew, absent on the Linux runners, so they run |
| 9 | +# against this output on macOS -- scripts/lint-cask.sh. |
| 10 | +# |
| 11 | +# Wipes dist/ and stubs bundled/; both paths come from the config. |
| 12 | + |
| 13 | +set -euo pipefail |
| 14 | + |
| 15 | +cd "$(dirname "$0")/.." |
| 16 | + |
| 17 | +CASK=dist/homebrew/Casks/lstk.rb |
| 18 | + |
| 19 | +if ! command -v goreleaser >/dev/null 2>&1; then |
| 20 | + echo "goreleaser required on PATH: https://goreleaser.com/install/" >&2 |
| 21 | + exit 1 |
| 22 | +fi |
| 23 | + |
| 24 | +# A different GoReleaser can render a different cask, so the pin is part of the |
| 25 | +# artifact's definition. |
| 26 | +EXPECTED=$(awk '/^goreleaser/ {print $2}' .tool-versions) |
| 27 | +INSTALLED=$(goreleaser --version 2>/dev/null | awk '/GitVersion:/ {print $2}' | sed 's/^v//') |
| 28 | +if [ "$INSTALLED" != "$EXPECTED" ]; then |
| 29 | + echo "goreleaser $EXPECTED required (found: ${INSTALLED:-none})" >&2 |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | + |
| 33 | +# archives.files globs `bundled/`, so an empty tree fails the build. The cask |
| 34 | +# ignores the bundle, and the real fetch needs a private-repo token. |
| 35 | +scripts/bundled-extensions/fetch-bundled-extensions.sh --stub |
| 36 | + |
| 37 | +goreleaser release --snapshot --clean |
| 38 | + |
| 39 | +[ -f "$CASK" ] || { echo "no cask generated at $CASK" >&2; exit 1; } |
| 40 | + |
| 41 | +fail() { echo "FAIL: $1" >&2; echo "--- $CASK ---" >&2; cat "$CASK" >&2; exit 1; } |
| 42 | + |
| 43 | +# Homebrew warns on every `brew` operation that loads a raw-Ruby flight block. |
| 44 | +# Only deprecated spellings match -- `_steps` leaves no trailing ` do` -- and |
| 45 | +# indentation is ignored, so a reindent upstream cannot empty the check. |
| 46 | +grep -Eq '^[[:space:]]*(uninstall_)?(pre|post)flight do$' "$CASK" && |
| 47 | + fail "cask uses a deprecated raw-Ruby flight stanza; use the *_steps form" |
| 48 | + |
| 49 | +# Our darwin binaries are unsigned, so Gatekeeper kills them unless quarantine |
| 50 | +# is cleared. Deleting the hook would satisfy the check above, so assert the |
| 51 | +# step survives. |
| 52 | +grep -q 'postflight_steps do' "$CASK" || |
| 53 | + fail "cask has no postflight_steps stanza" |
| 54 | +grep -q 'com.apple.quarantine' "$CASK" || |
| 55 | + fail "cask no longer clears com.apple.quarantine" |
| 56 | + |
| 57 | +# Homebrew's tokens share GoReleaser's delimiters. An unescaped |
| 58 | +# `{{staged_path}}` fails the release; a broken escape emits a literal pointing |
| 59 | +# somewhere else. |
| 60 | +grep -q '"{{staged_path}}"' "$CASK" || |
| 61 | + fail "quarantine step does not target the whole staged dir" |
| 62 | + |
| 63 | +echo "OK: $CASK" |
0 commit comments