Open Raikerian opened 2 years ago
@Raikerian Hi, sorry for late response. Yes. I want to add this tool in brew formula. However, I have never added tools in brew formula, so I need to investigate how to do. Any supports are welcome :)
@narugit I was looking to see what requirements exist to create a brew formula and there are some good documents that exist for it.
I'd be happy to contribute a github workflow that does the versioning and release asset creation for you (I've done this before for some personal/work projects). Once that is in place, we could run the brew create
command, along with some others, to create the contribution to the homebrew formula json.
(It might also be possible to create a github action to also do this homebrew formula update in an automatic way, so that any time a new version is created a new release/asset is created as well as a PR into the homebrew/core repository 🤔).
Reference: https://docs.brew.sh/Formula-Cookbook
@mikemimik Thank you for helpful infomation and strong support! Is following step is correct to publish as homebrew official package?
I am curious about your workflow. Could you create a pull request in this repository to add workflow?
What @mikemimik means is that he can help you with setting up a workflow to create versioned releases of your code, thus checking off the "has a stable, tagged version" bullet in the requirements.
@jvhaarst Thank you for pointing out my misunderstanding. Finally I have found out that the workflow is for versioning to meat "has a stable, tagged version" requirement. I will check that what I need to do before versioning. If you know about it, I would appreciate it if you could tell me about it.
On the main page of your repo you will find a "Releases" section, click on "Create a new release", and then you can tag the current state or a previous commit as a version.
@jvhaarst Sorry for late response. I will ready to get started.
Ref.: https://docs.brew.sh/Formula-Cookbook
- [x] isn’t already in Homebrew (check brew search
)
$ brew search smctemp
Error: No formulae or casks found for "smctemp".
- [x] isn’t already waiting to be merged (check the issue tracker)
Yes. This is the first time.
- [x] is still supported by upstream (i.e. doesn’t require extensive patching)
Yes
Hi, do you need help with this ? The main thing (without that nobody would be able to test locally), is to create a release. You could just create a release of only the latest, or go back through the commits, and decide how big a change it was, and whether it was a change big enough to make it a new version. Some ideas are here : https://nehckl0.medium.com/semver-and-calver-2-popular-software-versioning-schemes-96be80efe36 In the end it is your project, and you can decide how to version it. But brew apparently needs and wants a version, so you will have to create a release, and add a version to it.
@jvhaarst Thank you for kind support! May I ask a question? Actually I am trying to write GitHub Actions workflow in .github/workflows/release.yml to create a release, but I have no idea to build each binary for x86_64 and arm64 with GitHub Actions. Do I need to build by two binaries by myself and upload to release manually?
I just had a look, and I couldn't find a way to compile arm64 from github actions, using the macos-latest runner (more info at https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners)
I did succeed in getting brew to create a functioning smctemp locally:
brew create [URL of release tar.gz]
, and change the recipe (see below)HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source --verbose --debug smctemp
brew audit --strict --online smctemp
After that you will have to follow the cookbook on how to add it to te brew recipe repo. (in the below code I have changed the test to use version as a variable, so make sure the version you publish is the same as referenced in the code) smtemp.rb:
class Smctemp < Formula
desc "Check Temperature by using Apple System Management Control (Smc) tool"
homepage "https://github.com/narugit/smctemp"
url "https://github.com/narugit/smctemp/archive/refs/tags/v0.1.tar.gz"
sha256 "986b2c1e8d6452a9f57342bf440e7bdbecf07983ce62dacfbe3fdcad0345f313"
license "GPL-2.0-only"
depends_on :macos
def install
system "make"
bin.install "smctemp"
end
test do
assert_match "#{version}", shell_output("#{bin}/smctemp -v")
end
end
The test is better written like this, otherwise you will get a warning :
test do
assert_match version.to_s, shell_output("#{bin}/smctemp -v")
end
And a HEAD section would also be nice.
@jvhaarst Thank you!! I have just created the release 0.1.0. Now I'm trying to execute step 2.
By the way, do I need to support x86_64 Linux
to publish in https://github.com/Homebrew/homebrew-core?
https://docs.brew.sh/Acceptable-Formulae#supported-platforms
The formula needs to build and pass tests on the latest 3 supported macOS versions (x86_64 and Apple Silicon/ARM) and on x86_64 Linux.
You can try to limit it to only arm64, see https://docs.brew.sh/Cask-Cookbook#depends_on-arch And then just see what happens.
@jvhaarst Your link is for "Cask", so do you mean that I should upload to homebrew-cask not homebrew-core?
I suppose that smctemp is buildable from source code, so I want to upload to homebrew-core. However I suppose that I have to support Linux to upload to homebrew-core from https://docs.brew.sh/Acceptable-Formulae#supported-platforms, but smctemp is only for macOS, so is it not available to upload to homebrew-core?
The formula needs to build and pass tests on the latest 3 supported macOS versions (x86_64 and Apple Silicon/ARM) and on x86_64 Linux.
In my recipe above, I have depends_on :macos
, so that would mean it won't be available for Linux.
I would just try to release it with that limit, and see whether or not the maintainer lets it pass.
This recipe also only allows macos and arm64, so I don't think it will be a problem.
@jvhaarst Thank you for information!
This recipe also only allows macos and arm64, so I don't think it will be a problem.
Great! Thanks to your link, I think so too.
By the way, I will be off this week, so I will back next week.
I'm now starting to create pull request to homebrew-core. ref.
I've created workflow to create release: https://github.com/narugit/smctemp/blob/main/.github/workflows/release.yml
brew create --set-name=smctemp https://github.com/narugit/smctemp/archive/refs/tags/[tag name].tar.gz
@jvhaarst Finally I've created pull request on https://github.com/Homebrew/homebrew-core/pull/138800. Thank you for your full support!
However, I've failed below, so this repository seems to become more popular...
$ brew audit --new smctemp
smctemp
* GitHub repository not notable enough (<30 forks, <30 watchers and <75 stars)
Error: 1 problem in 1 formula detected.
However, I've failed below, so this repository seems to become more popular...
https://github.com/Homebrew/homebrew-core/pull/138800#issuecomment-1666814639
It looks like you're having trouble with a CI failure. See our contribution guide for help. You may be most interested in the section on dealing with CI failures. You can find the CI logs in the Checks tab of your pull request.
In homebrew-core CI, same failure has occurred( https://github.com/Homebrew/homebrew-core/actions/runs/5776153126/job/15655000769
==> brew audit smctemp --online --new-formula
==> FAILED
Full audit smctemp --online --new-formula output
smctemp
* GitHub repository not notable enough (<30 forks, <30 watchers and <75 stars)
Error: 1 problem in 1 formula detected.
Hi @Raikerian @jvhaarst @joshuataylor @kaskavalci @yllekz @mikemimik
Thanks for the interest in my repo! I'd love to have it on Homebrew, but currently, the project needs more notability (Forks, Stars, Watches) to meet the Homebrew criteria.
If you could help by spreading the word to your network or anyone who might find it useful, that would be amazing! Your support could make a big difference.
Thanks again for considering it!
Would it be worth setting this up as a Cask / https://docs.brew.sh/Adding-Software-to-Homebrew?
A few apps I use does this (macfuse, wezterm, filezilla, imageoptim, vorta from a quick peek at my shell history :)).
@joshuataylor Thank you for the information.
From https://docs.brew.sh/Acceptable-Casks#rejected-casks, It seems that my repository will be rejected..
App is too obscure. Examples: An app from a code repository that is not notable enough (under 30 forks, 30 watchers, 75 stars).
Ah bummer. It's a super useful project, as it's FAST AF.
I use it in my tmux window, as I have to check for OS and use either this or sensors on Linux. I only care about Apple Silicon macs and Linux though :).
--
I think it might be worthwhile to also setup GH Actions to build the project for easier installation. When I have time in the next couple of days I'll submit this as a PR, as multi-arch builds with GH Actions are tedious at best :).
Hey, thanks for this binary. Any chance you can set up brew formula for this?