nmtysh.log

Tech系のネタや日々の独り言などを書いています。

Homebrewにformula更新のPull Requestを送ってみた

node-buildの新しいVerが公開されたので、HomebrewにPull Requestを送ってみることにしました。
手順を自分用の備忘録としてまとめました。

Scraped latest definitions by nodenv-bot · Pull Request #804 · nodenv/node-build

環境

手順

CONTRIBUTING.md の手順に従ってコマンドを実行します。

$ brew update
$ brew update
()
$ brew upgrade
()
$ brew doctor
()
$ brew livecheck --installed
Warning: livecheck is a developer command, so Homebrew's
developer mode has been automatically turned on.
To turn developer mode off, run:
  brew developer off
(略)
node-build: 4.9.111 ==> 4.9.112
(略)

エラーになりました。

$ brew bump-formula-pr --strict node-build --version=4.9.112
Error: This formula is not in a tap!

なんでエラーになるのかと少し悩みましたが、Homebrewのバージョンが4.0.0に上がった時リポジトリが不要になったのでuntapしていました。
なので、tapします。リポジトリが大きく645MBほどあるため、10分前後かかりました。

$ brew tap
nodenv/nodenv

$ brew tap homebrew/core
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 1464452, done.
remote: Counting objects: 100% (364/364), done.
remote: Compressing objects: 100% (141/141), done.
remote: Total 1464452 (delta 231), reused 320 (delta 223), pack-reused 1464088
Receiving objects: 100% (1464452/1464452), 570.07 MiB | 2.11 MiB/s, done.
Resolving deltas: 100% (1023271/1023271), done.
Updating files: 100% (6970/6970), done.
Tapped 2 commands and 6625 formulae (6,981 files, 626MB).
==> Downloading https://formulae.brew.sh/api/formula.jws.json
#=#=#

$ brew tap
homebrew/core
nodenv/nodenv

改めて、 brew updatebrew doctor などを実行してから、 brew bump-formula-pr を実行します。

$ brew bump-formula-pr --strict node-build --version=4.9.112
==> Installing 'bundler' gem
()
Bundle complete! 37 Gemfile dependencies, 80 gems now installed.
Bundled gems are installed into `../../usr/local/Homebrew/Library/Homebrew/vendor/bundle`
==> Downloading https://github.com/nodenv/node-build/archive/v4.9.112.tar.gz
==> Downloading from https://codeload.github.com/nodenv/node-build/tar.gz/refs/t
##=O#- #
Warning: Cannot verify integrity of '6da19f56ff900032a027191881040942a040fc22234056bca29710700fe79cc0--node-build-4.9.112.tar.gz'.
No checksum was provided for this resource.
For your reference, the checksum is:
  sha256 "15e268c17765646bf9066408eddb5690bedcf362f3888303543787929b7abf4e"
==> replace /https:\/\/github\.com\/nodenv\/node\-build\/archive\/v4\.9\.111\.ta
==> replace "0139885e8b732ce7bc61c6289cf387d7046806aa3ef19f53ac19d965e0007cea" w
Error: Unable to fork: GitHub API Error: You must be logged in to do that.
The GitHub credentials in the macOS keychain may be invalid.
Clear them with:
  printf "protocol=https\nhost=github.com\n" | git credential-osxkeychain erase
Create a GitHub personal access token:
https://github.com/settings/tokens/new?scopes=gist,repo,workflow&description=Homebrew
echo 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.zshrc

!

bundlerのインストールが行われエラーになりました(これはどこにインストールされたんだろう…)
APIトークンが必要とのこと。
出力されたURLにアクセスして、APIトークンを作成して、環境変数にセットします。
※your_token_hereの部分は作成したトークンに置き換えます。

echo 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.zshenv
export HOMEBREW_GITHUB_API_TOKEN=your_token_here

気を取り直して再度コマンドを実行します。

$ brew bump-formula-pr --strict node-build --version=4.9.112
==> Downloading https://github.com/nodenv/node-build/archive/v4.9.112.tar.gz
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/6da19f56ff900032a027191881040942a040fc22234056bca29710700fe79cc0--node-build-4.9.112.tar.gz
Warning: Cannot verify integrity of '6da19f56ff900032a027191881040942a040fc22234056bca29710700fe79cc0--node-build-4.9.112.tar.gz'.
No checksum was provided for this resource.
For your reference, the checksum is:
  sha256 "15e268c17765646bf9066408eddb5690bedcf362f3888303543787929b7abf4e"
==> replace /https:\/\/github\.com\/nodenv\/node\-build\/archive\/v4\.9\.111\.ta
==> replace "0139885e8b732ce7bc61c6289cf387d7046806aa3ef19f53ac19d965e0007cea" w
M   Formula/node-build.rb
Switched to a new branch 'bump-node-build-4.9.112'
[bump-node-build-4.9.112 2a67d8d6852] node-build 4.9.112
 1 file changed, 2 insertions(+), 2 deletions(-)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
remote:
remote: Create a pull request for 'bump-node-build-4.9.112' on GitHub by visiting:
remote:      https://github.com/matayoshi/homebrew-core/pull/new/bump-node-build-4.9.112
remote:
To https://github.com/matayoshi/homebrew-core.git
 * [new branch]              bump-node-build-4.9.112 -> bump-node-build-4.9.112
branch 'bump-node-build-4.9.112' set up to track 'https://******@github.com/matayoshi/homebrew-core.git/bump-node-build-4.9.112' by rebasing.

Pull Requestが作成できました。

node-build 4.9.112 by matayoshi · Pull Request #128673 · Homebrew/homebrew-core
Approveされたら数時間でマージされました。GitHub Actionsで色々自動化されていてすごいですね。

おまけ

"Installing 'bundler' gem" されたものは /usr/local/Homebrew/Library/Homebrew/vendor/ に置かれたようです。
良く見るとログに書いてありますね……( Bundled gems are installed into〜 )
bundleerのキャッシュは ~/.bundle/cache に生成されました。

参考