@@ -271,3 +271,108 @@ jobs:
271271 dist/SHA256SUMS.pem
272272 dist/provenance.intoto.jsonl
273273 dist/sbom.cdx.json
274+
275+ update-homebrew :
276+ name : Update Homebrew tap
277+ runs-on : ubuntu-latest
278+ needs : release
279+ permissions :
280+ contents : read
281+ steps :
282+ - uses : actions/checkout@v4
283+
284+ - name : Read version
285+ id : version
286+ run : |
287+ version=$(python3 - <<'PY'
288+ import tomllib
289+ from pathlib import Path
290+ data = tomllib.loads(Path('Cargo.toml').read_text())
291+ print(f"v{data['package']['version']}")
292+ PY
293+ )
294+ echo "version=$version" >> "$GITHUB_OUTPUT"
295+ echo "bare_version=${version#v}" >> "$GITHUB_OUTPUT"
296+
297+ - name : Download SHA256SUMS from release
298+ run : |
299+ curl -fsSL "https://github.com/cmdrvl/rvl/releases/download/${{ steps.version.outputs.version }}/SHA256SUMS" -o SHA256SUMS
300+
301+ - name : Generate formula
302+ run : |
303+ python3 - <<'PYEOF'
304+ import pathlib
305+
306+ version = "${{ steps.version.outputs.version }}"
307+ bare = "${{ steps.version.outputs.bare_version }}"
308+
309+ sums = {}
310+ for line in pathlib.Path("SHA256SUMS").read_text().strip().splitlines():
311+ digest, name = line.split(maxsplit=1)
312+ sums[name.strip()] = digest
313+
314+ targets = {
315+ "aarch64-apple-darwin": ("on_macos", "on_arm"),
316+ "x86_64-apple-darwin": ("on_macos", "on_intel"),
317+ "aarch64-unknown-linux-gnu": ("on_linux", "on_arm"),
318+ "x86_64-unknown-linux-gnu": ("on_linux", "on_intel"),
319+ }
320+
321+ blocks = []
322+ current_os = None
323+ for target, (os_block, arch_block) in targets.items():
324+ asset = f"rvl-{version}-{target}.tar.gz"
325+ sha = sums.get(asset, "MISSING")
326+ if os_block != current_os:
327+ if current_os is not None:
328+ blocks.append(" end")
329+ blocks.append(f"\n {os_block} do")
330+ current_os = os_block
331+ blocks.append(f" {arch_block} do")
332+ blocks.append(f' url "https://github.com/cmdrvl/rvl/releases/download/{version}/{asset}"')
333+ blocks.append(f' sha256 "{sha}"')
334+ blocks.append(f" end")
335+ blocks.append(" end")
336+
337+ formula = f'''# typed: false
338+ # frozen_string_literal: true
339+
340+ class Rvl < Formula
341+ desc "Reveal the smallest set of numeric changes that explain what actually changed"
342+ homepage "https://github.com/cmdrvl/rvl"
343+ version "{bare}"
344+ license "MIT"
345+ {"".join(chr(10) + l for l in blocks)}
346+
347+ def install
348+ bin.install "rvl"
349+ end
350+
351+ test do
352+ assert_match version.to_s, shell_output("#{{bin}}/rvl --version")
353+ end
354+ end
355+ '''
356+
357+ # Dedent (remove leading spaces from triple-quoted string)
358+ import textwrap
359+ formula = textwrap.dedent(formula).lstrip()
360+ pathlib.Path("rvl.rb").write_text(formula)
361+ PYEOF
362+
363+ - name : Push formula to tap
364+ env :
365+ GH_TOKEN : ${{ secrets.HOMEBREW_TAP_TOKEN }}
366+ run : |
367+ git clone "https://x-access-token:${GH_TOKEN}@github.com/cmdrvl/homebrew-tap.git" tap
368+ cp rvl.rb tap/Formula/rvl.rb
369+ cd tap
370+ git config user.name "github-actions[bot]"
371+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
372+ if git diff --quiet; then
373+ echo "No changes to formula"
374+ else
375+ git add Formula/rvl.rb
376+ git commit -m "rvl ${{ steps.version.outputs.version }}"
377+ git push
378+ fi
0 commit comments