Distributing your own scripts via Homebrew

(justin.searls.co)

64 points | by ingve 2 days ago

6 comments

  • darkamaul 12 hours ago
    Really informative read, I agree that Homebrew’s naming conventions can be frustrating at times, but overall it’s such a great tool.

    I hadn’t realized it was this simple to spin up your own tap for distributing tools. How does this compare to using language specific tools (like uv, for example)? Is it better because that’s easier for folks not within the ecosystem ?

    • searls 8 hours ago
      Thanks!

      To answer your question, other tools with package registries typically require accounts, increasingly 2FA, often encourage some sort of signing step. Having GitHub's ToS serve as the source of trust really simplifies things for the Homebrew team

    • thewisenerd 11 hours ago
      specifically for python packages,

      while it's lightweight, shipping the kitchen sink (uv) is a no-go

      so, it's a venv, with the pinned dependencies installed [0], a random example of how this looks like, here [1]

      (specifically for uv; i tried to get `brew update-python-resources` and `homebrew-pypi-poet` working for a "private" package, it didn't really work; so i went ahead and created uvbrew [2] instead to help with the resource generation)

      [0]: https://docs.brew.sh/Python-for-Formula-Authors [1]: https://github.com/hynek/homebrew-tap/blob/main/Formula/doc2... [2]: https://github.com/thewisenerd/uvbrew

      • thewisenerd 11 hours ago
        that said, it's _really_ easy to have executables against random sdist with `uv run --with`.

        here's something that i was writing just yesterday:

            #!/usr/bin/env bash
            PYSTABLE="3.13"
            SERVER="..."
            PACKAGE="xyz"
            VERSION="0.1.3"
            exec uv run --python "$PYSTABLE" --with "$SERVER/$PKG-$VERSION.tar.gz" "$PKG" "$@"
        • andrewaylett 8 hours ago
          Now stick the wrapper in a git repo, get Renovate to bump the version numbers, automagic release on new version, and have Brew install the wrapper.
  • wyattjoh 9 hours ago
    I wrote my own version of the homebrew tap bumping workflow for GitHub Actions: https://github.com/wyattjoh/homebrew-bump-revision I use it for some of my personal projects
    • searls 8 hours ago
      Nice! I was too lazy but looks good
  • jbreckmckye 9 hours ago
    A small tip for Go folk: the Goreleaser tool makes it very easy to manage your formulae, at least for distributing binaries (allowed in personal taps but a no-no in core)
    • latchkey 7 hours ago
      I didn't know this until recently, but it now supports multiple languages.

      "First-class support for Go, Rust, TypeScript, Python, and Zig projects."

  • PufPufPuf 5 hours ago
    Fun fact about packaging Python tools: It turns out that there are Python packages that aren't compatible with Homebrew due to cycles in build dependencies. While this is no problem for pip, as it just downloads binary releases, Homebrew builds ALL of the dependencies from scratch. And yeah, that also means that modestly sized Python projects may take over an hour to build the "bottle".
  • loozhengyuan 10 hours ago
    IMO it might be more ideal to do the updates from the tap side, similar to how upstream does it. This workflow[1] allows you handle updates even for formulae/casks you do not own. Using the `brew bump` command, you scan all formulae/casks and create PRs that update them. In these PRs[2], you can use the `brew test-bot` command to ensure the updates are tested working.

    [1]: https://github.com/loozhengyuan/homebrew-tap/blob/main/.gith...

    [2]: https://github.com/loozhengyuan/homebrew-tap/pull/11

    • searls 8 hours ago
      This is a good idea. I'm so used to being miserly about my action minute allotment that this didn't occur to me until I realized that OSS time is free still (I think?)
  • xyst 11 hours ago
    I switched to nix to manage my systems and haven’t looked back. The only thing lacking is a single dependency on shitty windows for multiplayer gaming.