Prepare
Fork Homebrew/homebrew-core repository on GitHub.
1
|
cd $(brew --repository homebrew/core)
|
1
|
git remote add <YOUR_USERNAME> https://github.com/<YOUR_USERNAME>/homebrew-core.git
|
Create new branch
1
|
git checkout -b <PROJECT_NAME> origin/master
|
1
|
brew create https://github.com/csyezheng/a2fa/releases/download/v0.16.5/a2fa_Darwin_x86_64.tar.gz
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
class A2fa < Formula
desc "Command-line tool for generating and validating one-time password"
homepage "https://github.com/csyezheng/a2fa"
url "https://github.com/csyezheng/a2fa/archive/refs/tags/v0.16.5.tar.gz"
sha256 "bd3a65a2c982c8b224aa2a3c11ff62864d61764a6a30daf86832ba6fdc7d3599"
license "Apache-2.0"
depends_on "go" => :build
def install
args = *std_go_args(ldflags: "-s -w")
args += ["-tags", "brew"] if OS.mac?
system "go", "build", *args, "./cmd/"
end
test do
assert_match "no accounts found!\n", shell_output("#{bin}/a2fa list")
end
end
|
1
|
brew install --build-from-source <formula>
|
1
|
brew audit --strict <formula>
|
1
|
audit --strict --new-formula --online <formula>
|
1
|
git add Formula/a2fa.rb
|
1
|
git commit -m 'a2fa 0.16.5'
|
1
|
git push --set-upstream <YOUR_USERNAME> <PROJECT_NAME>
|
Creating a pull request
Manually create a pull request on GitHub.
Submitting new version packages
CLI
1
|
$ brew bump-formula-pr --url https://example.com/foo-0.1.tar.gz
|
GitHub action
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
- name: Update Homebrew formula
uses: dawidd6/action-homebrew-bump-formula@v3
with:
# Required, custom GitHub access token with the 'public_repo' and 'workflow' scopes
token: ${{secrets.TOKEN}}
# Optional, will create tap repo fork in organization
org: ORG
# Optional, use the origin repository instead of forking
no_fork: false
# Optional, defaults to homebrew/core
tap: USER/REPO
# Formula name, required
formula: FORMULA
# Optional, will be determined automatically
tag: ${{github.ref}}
# Optional, will be determined automatically
revision: ${{github.sha}}
# Optional, if don't want to check for already open PRs
force: false # true
|
Reference
homebrew-bump-formula
将项目发布到 Homebrew 官方仓库