Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homebrew tap support #118

Closed
pat-s opened this issue Oct 18, 2024 · 10 comments
Closed

Homebrew tap support #118

pat-s opened this issue Oct 18, 2024 · 10 comments

Comments

@pat-s
Copy link
Contributor

pat-s commented Oct 18, 2024

https://docs.brew.sh/How-to-Create-and-Maintain-a-Tap - would make updating a bit more convenient than manually updating from the release assets.

@xoxys
Copy link
Member

xoxys commented Oct 20, 2024

In general, I'm not against it, but as I'm not a Mac user, its hard for me to maintain it. What concerns me the most is https://github.com/Homebrew/brew/blob/master/docs/Taps.md#repository-naming-conventions-and-assumptions as I really don't want to maintain a second repo to support it.

@pat-s
Copy link
Contributor Author

pat-s commented Oct 20, 2024

Yes, that's required. I think you can provide multiple formulas in one repo/tap.

Of course anyone could provide/create a tap and create a formula, but ideally (trust/security) the tap would be hosted within the same namespace that hosts the source as well (i.e. thegeeklab org).

Another possible formula would be ansible-doctor that could be provided there. HTH if needed...

@xoxys
Copy link
Member

xoxys commented Oct 20, 2024

For me that's out of scope as I can't maintain it. If you would like to take care, I could create a repo and invite you as maintainer.

@xoxys
Copy link
Member

xoxys commented Oct 20, 2024

Im also happy to link an external repo in the readme as community support to create some "trust".

@pat-s
Copy link
Contributor Author

pat-s commented Oct 21, 2024

Fully understand that you don't wanna maintain it.
I think a repo in your namespace makes most sense, even if maintained externally. Also because n > 1 and you might create even more CLI tools in the future ;)

Another reason to host in your org might be that you can auto-bump the formula upon new cli releases by issueing brew bump-formula-pr --strict --url=https://github.com/user/my-software/archive/refs/tags/${{ github.event.release.tag_name }}.tar.gz --tap=user/homebrew-tap during a release event. And you don't wanna do this so some external repo usually.

tl;dr: happy to configure it, ideally maintenance should be close to 0 once set up.

@xoxys
Copy link
Member

xoxys commented Oct 23, 2024

Cool, thanks! I have created the repo https://github.com/thegeeklab/homebrew-tap and invited you as maintainer. Please add a MIT license file, you can copy the one from this repo.

@pat-s
Copy link
Contributor Author

pat-s commented Oct 24, 2024

The tap is now functional.

❯ brew reinstall git-sv
==> Fetching thegeeklab/tap/git-sv
==> Downloading https://github.com/thegeeklab/git-sv/archive/refs/tags/v1.0.5.tar.gz
Already downloaded: /Users/pjs/Library/Caches/Homebrew/downloads/436c7ee2c9d859f19cb166c5ed404762c7aab38c199e6079cd39d0787f520f2f--git-sv-1.0.5.tar.gz
==> Reinstalling thegeeklab/tap/git-sv
==> go build -ldflags=-s -w -X main.BuildVersion=v1.0.5 -X main.BuildDate=2024-10-24T22:15:58Z ./cmd/git-sv
🍺  /opt/homebrew/Cellar/git-sv/1.0.5: 6 files, 6.9MB, built in 1 second
==> Running `brew cleanup git-sv`...

which git-sv
/opt/homebrew/bin/git-sv

git-sv --version
git-sv version=v1.0.5 date=2024-10-24T22:15:58Z

For updates: brew bump-formula-pr -v --no-browse --no-fork --strict --version <version> git-sv should create a PR in the repo. This however relies on the following assumptions:

  • the user executing it needs write permissions in the tap repo, so it can push to a branch
  • the user's git config must be configured
  • before running the update command, the formula must be installed so the URL/tap is know

So I'd envision it something along the lines of

  - name: bump-homebrew-tap
    image: docker.io/homebrew/brew:4.4.2
    secrets: [github_token]
    commands:
      - # configure git config for bot user -> git config [...]
      - brew tap thegeeklab/tap
      - brew install git-sv
      - brew bump-formula-pr -v --no-browse --no-fork --strict --version ${{ github.event.release.tag_name }} git-sv

I can test this on the next upcoming release and try to perform the linked actions in a container locally and see if this leads to a PR. Afterwards these actions could be executed in your release pipeline from the bot user (assuming the bot user gets added to the repo with w perms).
If you also want to skip the manual merge of the PR, automerge could be set up in the tap repo including a dummy check that tests whether the author is the bot user (just an idea).

@xoxys
Copy link
Member

xoxys commented Oct 25, 2024

Awesome, thanks a lot! Looks like renovate can take care of it https://docs.renovatebot.com/modules/manager/homebrew/ and I would prefer this way.

However, we would need to programmatically extract the version in the test part https://github.com/thegeeklab/homebrew-tap/blob/main/Formula/git-sv.rb#L29 from e.g. the url metadata.

@pat-s
Copy link
Contributor Author

pat-s commented Oct 25, 2024

Good idea, I wasn't aware that there is a manager even!

Seems like the manager doesn't need any custom config or rules: thegeeklab/homebrew-tap#2

@xoxys
Copy link
Member

xoxys commented Oct 25, 2024

Thanks again, I'm going to close this issue as completed.

@xoxys xoxys closed this as completed Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants