Open baggiponte opened 1 year ago
I don't have any experience with Homebrew, so it would be great if you're interested in working on that. As I mentioned in #7, I'm happy to add something to our CD if it's helpful.
I am busy until the end of the month (🥲) but after that I would gladly look into it!
Hi @max-niederman, I carved out some time to test out. Turns out, it is pretty straightforward, and I can install ttyper
now with my formula, though some tweaks are still needed.
Here's what I went through as macOS user:
brew developer on
. This will activate homebrew "developer mode", i.e. homebrew is just a GH repo: now when you run brew update
you will trigger a git pull in your local clone from the master branch.brew update
.cd (brew --repository homebrew/core)
to cd into the repo.brew create --set-name=ttyper --rust https://github.com/max-niederman/ttyper/archive/refs/tags/v1.2.2.tar.gz
The URL is the url of the latest version of ttyper that I got from ttyper tags page
Command 4.
creates a template of a short ruby file with a couple of info about your project filled in. See below what I put into the formula.
Also available online here.
class Ttyper < Formula
desc "Terminal-based typing test"
homepage "https://github.com/max-niederman/ttyper"
url "https://github.com/max-niederman/ttyper/archive/refs/tags/v1.2.2.tar.gz"
sha256 "de168b56dfe71ac24c91c012b2c6bbd30fa5102a15dae53a8566ec2930c6b10e"
license "MIT"
head "https://github.com/max-niederman/ttyper", branch: "main"
depends_on "rust" => :build
def install
system "cargo", "install", *std_cargo_args
end
test do
assert_equal "ttyper #{version}", shell_output(bin/"ttyper --version").chomp
end
end
A couple of notes:
class Ttyper
has to stay in this case, otherwise it won't work (I tried TTYper
to no avail).depends_on "rust" => :build
says that if you install ttyper
from source you also need to install rust. This is only necessary for the Homebrew bot to build the package, which the final user will download directly.Of course I never wrote a line of ruby before. Turns out, brew create
does a lot of the work for you and you can copy paste what other rust-based projects did. Since ttyper
is a TUI, I looked at what bottom did.
Once you have completions and stuff, I guess you can add them below the def install
block like bottom did.
bottle do
If you look at bottom
's formula, you will find a section like this:
bottle do
sha256 cellar: :any_skip_relocation, arm64_ventura: "1feb2cbc18e4aac7256532bd10df73165adc787711566d3ca409f13bc694c172"
sha256 cellar: :any_skip_relocation, arm64_monterey: "22f0aaa8f197085cd4f169fc972f59cc2128571bcea27fe021c7e931a06a5814"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "b5529193e79de83a601d0fb3713f0eb0ac9d2cfa536ce5ee4f51d865c0dc7fa0"
sha256 cellar: :any_skip_relocation, ventura: "3bd89bb468533c10feedce451259655f1a59befdba9f6ede0d02dc8762f939d0"
sha256 cellar: :any_skip_relocation, monterey: "9bf45d0c6f6b448049507143186a5b48f60362c8b66a45a768fa187159c935ff"
sha256 cellar: :any_skip_relocation, big_sur: "92879f8c249de5942690245f32120166b3b7525810391b985a9985af2251aa26"
sha256 cellar: :any_skip_relocation, x86_64_linux: "620d11518d266bcd8c77b23567e045953f3049ed0b40799fd00985f50d9c8c6b"
end
I had a look at the docs but I could not figure out what this does.
Brew says you only need to run brew bump-formula-pr [options] [formula] [url/sha/version]
to "to automatically update the url and sha256, remove any revision lines, and submit a pull request".
The point is: you as maintainer gotta have brew installed on your machine. I guess you could have a step in your CI/CD pipeline (e.g. GH actions) that does that for you, but I checked bottom, bat and zellij and found nothing, while ripgrep does a bit of a hack.
For the meantime, I can help with that but I guess it is not sustainable in the long run.
I would like to make a PR to homebrew/core with this formula, tagging you, and ask some clarification about the bottle do
bit and how to update it. We might ask around other rust-based formulae maintainers how they manage this step a bit more thoroughly than what I did.
(gotta say, took me longer to write this than doing the whole thing)
Technically we could also write a GH Action workflow to run brew bump-formula-pr
: homebrew has a lot of actions to use!
Hello! I don't have a lot of experience with that, but it would be great to distribute ttyper through homebrew as well. If you are interested, I can volunteer to help out.