Replace Homebrew bump action with direct formula update#184
Conversation
WalkthroughAdds a manual ChangesHomebrew Formula Update Automation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/homebrew.yml:
- Around line 20-26: TAG_NAME is inserted directly into url and later used in
sed substitutions; validate or escape it before use. Add a validation step for
TAG_NAME (e.g., require a safe pattern like an optional leading "v" followed by
alphanumerics, ., _, -) and exit with an error if it doesn't match;
alternatively, escape sed metacharacters in TAG_NAME (and derived version/url)
before any sed command by replacing characters like | / & \ with escaped
versions so the sed substitution won't break. Ensure these checks/escapes are
applied to the TAG_NAME -> version/url flow and before the sed commands that
reference those variables.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 27bc6891-6ee9-48ce-94e6-653e329bd3e6
📒 Files selected for processing (1)
.github/workflows/homebrew.yml
| GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} | ||
| TAG_NAME: ${{ github.event.release.tag_name }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| version="${TAG_NAME#v}" | ||
| url="https://github.com/coderabbitai/git-worktree-runner/archive/refs/tags/${TAG_NAME}.tar.gz" |
There was a problem hiding this comment.
Validate or escape TAG_NAME before use in sed patterns.
TAG_NAME originates from github.event.release.tag_name and is embedded directly into the url variable, which is later used unescaped in sed substitution patterns (lines 40-41). Git tags can contain characters like | (the sed delimiter), & (replacement metacharacter), or backslashes that could break the sed command or cause unintended substitutions.
While the curl download will likely fail for malformed URLs (providing implicit validation), consider adding explicit validation:
Proposed fix: validate tag format
set -euo pipefail
+ # Validate tag format (vX.Y.Z)
+ if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ echo "Invalid tag format: $TAG_NAME" >&2
+ exit 1
+ fi
+
version="${TAG_NAME#v}"
url="https://github.com/coderabbitai/git-worktree-runner/archive/refs/tags/${TAG_NAME}.tar.gz"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| TAG_NAME: ${{ github.event.release.tag_name }} | |
| run: | | |
| set -euo pipefail | |
| version="${TAG_NAME#v}" | |
| url="https://github.com/coderabbitai/git-worktree-runner/archive/refs/tags/${TAG_NAME}.tar.gz" | |
| GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| TAG_NAME: ${{ github.event.release.tag_name }} | |
| run: | | |
| set -euo pipefail | |
| # Validate tag format (vX.Y.Z) | |
| if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Invalid tag format: $TAG_NAME" >&2 | |
| exit 1 | |
| fi | |
| version="${TAG_NAME#v}" | |
| url="https://github.com/coderabbitai/git-worktree-runner/archive/refs/tags/${TAG_NAME}.tar.gz" |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/homebrew.yml around lines 20 - 26, TAG_NAME is inserted
directly into url and later used in sed substitutions; validate or escape it
before use. Add a validation step for TAG_NAME (e.g., require a safe pattern
like an optional leading "v" followed by alphanumerics, ., _, -) and exit with
an error if it doesn't match; alternatively, escape sed metacharacters in
TAG_NAME (and derived version/url) before any sed command by replacing
characters like | / & \ with escaped versions so the sed substitution won't
break. Ensure these checks/escapes are applied to the TAG_NAME -> version/url
flow and before the sed commands that reference those variables.
The homebrew workflow failed on the v2.8.0 release with
unexpected HTTP 303 response. GitHub started returning 303 redirects on tarball URLs and bump-homebrew-formula-action rejects them (mislav/bump-homebrew-formula-action#340, fix unmerged, latest release predates it). The v2.8.0 formula had to be bumped by hand.This drops the action and does the bump directly in a script step: download the release tarball, sha256 it, update url + sha256 in the tap formula via the contents API with the existing
HOMEBREW_TAP_TOKEN. Same commit message format the action used. Skips cleanly if the formula is already at the tag, so reruns are safe. No third-party action left in the workflow.Also adds
workflow_dispatchwith a tag-name input so a failed bump can be rerun manually instead of editing the tap by hand.Tested every path:
v2.7.3output is byte-identical to the real v2.7.3 tap commit; bad tag and unexpected formula format both exit non-zerov2.8.0hits the already-current guard,v9.9.9fails the run on curl 404, and av2.7.3→v2.8.0round trip wrote real commits to the tap (f177412, 04e2f45) that diff clean against the historical 2.7.3 and current 2.8.0 formulasbrew fetch coderabbitai/tap/git-gtrchecks out after the round trip