Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Formula/python@3.11.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class PythonAT311 < formula
skip "Meta formulas cannot be updated"
end

# renovate: registryUrl=https://api.github.com/repos/Homebrew/homebrew-core/commits?path=Formula/p/python@3.11.rb
depends_on "https://raw.githubusercontent.com/Homebrew/homebrew-core/cca86c9c20f43a6e6f98b41e8988088188907c41/Formula/p/python@3.11.rb"

def install
Expand Down
21 changes: 21 additions & 0 deletions Formula/python@3.12.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# renovate: datasource=custom.ghfile registryUrl=Homebrew/homebrew-core depName=Formula/p/python@3.12.rb currentDigest=master
class PythonAT312 < formula
desc 'Installs Python 3.12.x'
homepage 'http://github.com/nsheaps/homebrew-devsetup'
url 'https://github.com/nsheaps/brew-meta-formula/archive/refs/tags/v1.0.0.tar.gz'
sha256 "b14702dd54ea5c48d2ebeb6425015c14794159a6b9d342178c81d2f2e79ed2db"
version '1.0.0' # bump me if you want people to re-install these things, like if the list changed.

livecheck do
skip "Meta formulas cannot be updated"
end

depends_on "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/p/python@3.12.rb"

def install
# even though there's stuff in the brew-meta-formula, brew needs something to install or it will
# complain about an empty installation
system "touch", "trick-brew-to-install-meta-formula"
prefix.install "trick-brew-to-install-meta-formula"
end
end
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,60 @@ If you want any of these configurations to happen automatically on `devsetup ins
| `gpg` | sets up gpg with a key and config |
| `aws` | sets up aws with a profile and config |

## Tracking Upstream Formulas with Renovate

This repository uses Renovate to automatically track and update formulas against their upstream versions. This is particularly useful for Python formulas that need to stay in sync with the official Homebrew versions.

### How to Create a Formula that Tracks Upstream

To create a formula that tracks an upstream formula (like Python), follow this template:

```ruby
# renovate: datasource=custom.ghfile registryUrl=Homebrew/homebrew-core depName=Formula/p/python@3.12.rb currentDigest=master
class PythonAT312 < formula
desc 'Installs Python 3.12.x'
homepage 'http://github.com/nsheaps/homebrew-devsetup'
url 'https://github.com/nsheaps/brew-meta-formula/archive/refs/tags/v1.0.0.tar.gz'
sha256 "b14702dd54ea5c48d2ebeb6425015c14794159a6b9d342178c81d2f2e79ed2db"
version '1.0.0'

livecheck do
skip "Meta formulas cannot be updated"
end

depends_on "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/p/python@3.12.rb"

def install
system "touch", "trick-brew-to-install-meta-formula"
prefix.install "trick-brew-to-install-meta-formula"
end
end
```

The key components are:

1. The comment at the top of the file with the Renovate configuration:
```ruby
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes lint errors, please fix:

  	132: Wrong amount of left-padding spaces(want multiple of 2)
  	133: Wrong amount of left-padding spaces(want multiple of 2)
  	134: Wrong amount of left-padding spaces(want multiple of 2)
  	137: Wrong amount of left-padding spaces(want multiple of 2)
  	138: Wrong amount of left-padding spaces(want multiple of 2)
  	139: Wrong amount of left-padding spaces(want multiple of 2)

# renovate: datasource=custom.ghfile registryUrl=Homebrew/homebrew-core depName=Formula/p/python@3.12.rb currentDigest=master
```

2. The `depends_on` line that references the raw GitHub URL of the upstream formula:
```ruby
depends_on "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/p/python@3.12.rb"
```

When Renovate runs, it will:
1. Check for updates to the upstream formula
2. Update the SHA in the `depends_on` line to point to the latest version
3. Create a pull request with the changes

### How It Works

The Renovate configuration in `renovate.json` uses a custom manager and datasource to:
1. Match formula files with the special comment format
2. Check the GitHub API for updates to the referenced file
3. Update the SHA in the `depends_on` line when changes are detected

## TODO

* [ ] Test `brew list` and see if it dumps list prefixed with installed tap (no tap is `homebrew/core`)
Expand Down
4 changes: 2 additions & 2 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"customType": "regex",
"fileMatch": ["Formula(/\\S+)?/\\S+\\.rb"],
"matchStrings": [
"#\\s?renovate:?\\s*(registryUrl=(?<registryUrl>.+))?\\s*\\n\\s*depends_on \"https://raw.githubusercontent.com/(?<repo>[A-Za-z0-9-_]+/[A-Za-z0-9-_]+)/(?<currentValue>[A-Za-z0-9]+)/(?<depName>.+).rb\""
"# renovate: datasource=custom.ghfile registryUrl=(?<registryUrl>[A-Za-z0-9-_/]+) depName=(?<depName>[A-Za-z0-9-_/\\.]+) currentDigest=(?<currentValue>[A-Za-z0-9-_]+)[\\s\\S]*?depends_on \"https://raw.githubusercontent.com/(?<repo>[A-Za-z0-9-_]+/[A-Za-z0-9-_]+)/(?<currentDigest>[A-Za-z0-9]+)/(?<packageName>.+).rb\""
],
"versioningTemplate": "{{# if versioning}}{{{versioning}}}{{else}}git{{/if}}",
"datasourceTemplate": "custom.github-file"
}
],
"customDatasources": {
"github-file": {
"defaultRegistryUrlTemplate": "https://api.github.com/repos/{{repo}}/commits?path={{packageName}}.rb",
"defaultRegistryUrlTemplate": "https://api.github.com/repos/{{repo}}/commits?path={{packageName}}",
"transformTemplates": [
"{\"releases\":[{\"version\": $$.[0].sha, \"releaseTimestamp\": $$.[0].commit.author.date}]}"
]
Expand Down