#!/usr/bin/env bash # Puts a released version's Homebrew formula in the tap on Upstream # (git.coline.app/coline/homebrew-tap), so `brew install coline/tap/onset` # installs it. The release workflow publishes the formula next to the # downloads; this copies it into the tap with your git credentials for # git.coline.app (upstream auth setup-git). # Usage: install/tap.sh set -euo pipefail VERSION=$1 BASE=${ONSET_DOWNLOADS:-https://downloads.coline.dev/onset} TAP=${ONSET_TAP:-https://git.coline.app/coline/homebrew-tap.git} DIR=$(mktemp -d) trap 'rm -rf "$DIR"' EXIT curl -fsSL "$BASE/$VERSION/onset.rb" -o "$DIR/onset.rb" grep -q "version \"$VERSION\"" "$DIR/onset.rb" git clone -q "$TAP" "$DIR/tap" mkdir -p "$DIR/tap/Formula" cp "$DIR/onset.rb" "$DIR/tap/Formula/onset.rb" cat >"$DIR/tap/README.md" <<'EOF' # Coline's Homebrew tap ```sh brew tap coline/tap https://git.coline.app/coline/homebrew-tap.git brew install coline/tap/onset ``` `brew upgrade onset` picks up new releases. EOF cd "$DIR/tap" git add Formula/onset.rb README.md if git diff --cached --quiet; then echo "the tap already has onset $VERSION" exit 0 fi git -c user.name=Coline -c user.email=bot@coline.app commit -q -m "onset $VERSION" git push -q origin HEAD:main echo "the tap has onset $VERSION"