Open5

Homebrew の公式リポジトリに新しい Formula を追加する

YoppyYoppy
brew tap --force homebrew/core
brew update

# Formulaを生成
brew create --set-name "gh-deps" --go "https://github.com/yoppyDev/gh-deps/archive/refs/tags/v1.0.0.tar.gz"
brew audit --new "gh-deps"

# 出力結果
gh-deps
  * line 2, col 8: Description is too long. It should be less than 80 characters. The current length is 85.
  * line 2, col 9: Description shouldn't start with an article.
  * line 2, col 93: Description shouldn't end with a full stop.
  * line 3, col 12: Formula should have a homepage.
  * Formulae in homebrew/core must specify a license.
  * GitHub repository not notable enough (<30 forks, <30 watchers and <75 stars)
Error: 6 problems in 1 formula detected.

↑の元に修正

vi $(brew --repository homebrew/core)/Formula/g/gh-deps.rb

修正後

class GhDeps < Formula
  desc "Search for repositories that use a specific library"
  homepage "https://github.com/yoppyDev/gh-deps"
  url "https://github.com/yoppyDev/gh-deps/archive/refs/tags/v1.0.0.tar.gz"
  sha256 "8ab171691df186998ea77d17c48dccaca18f9fe7745238e0411b5fc6a58c8f97"
  license ""

  depends_on "go" => :build

  def install
    system "go", "build", *std_go_args(ldflags: "-s -w")
  end

  test do
    system "false"
  end
end

インストール & 動作確認

HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source --verbose --debug "gh-deps"
gh-deps -L=Go -l="github.com/spf13/cobra"
"github.com/spf13/cobra" in:file language:Go
Found 13 repositories using github.com/spf13/cobra with language Go and stars condition :
 - sgykfjsm/cobra-viper-sample (https://github.com/sgykfjsm/cobra-viper-sample) - 6 stars
YoppyYoppy

用語

https://docs.brew.sh/Formula-Cookbook

名前 説明
Formula HomebrewでソフトウェアをインストールするためのRubyスクリプト。ソフトウェアのビルドとインストール手順、依存関係、テスト方法を定義します。
Tap Homebrewのリポジトリのことで、複数のFormulaを含むことができます。ユーザーはTapを追加することで、カスタムのソフトウェアをHomebrewでインストールできるようになります。
YoppyYoppy

Github Actionを実行した際にでたエラー

403 Resource not accessible

⨯ release failed after 1m32s               error=scm releases: failed to publish artifacts: could not release: PATCH https://api.github.com/repos/yoppyDev/gh-deps/releases/151051415: 403 Resource not accessible by integration []
Error: The process '/opt/hostedtoolcache/goreleaser-action/1.25.1/x64/goreleaser' failed with exit code 1

Workflow permissionsの権限を Read repository contents and packages permissions -> Read and write permissionsに変更した