Skip to content

fix: open a pull request when publishing the homebrew formula - #631

Open
NickJosevski wants to merge 2 commits into
mainfrom
nj/fix-541
Open

fix: open a pull request when publishing the homebrew formula#631
NickJosevski wants to merge 2 commits into
mainfrom
nj/fix-541

Conversation

@NickJosevski

@NickJosevski NickJosevski commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #541

Root cause

The publish step clones the tap, commits the regenerated formula, pushes a releases/<version> branch, no pr and merge happens.

Confirmed against the tap: branches exist for every release from 0.3.2 through 2.21.4, master is still on 2.20.0, and the only pull request ever opened is #69 — raised by hand by an external user, @jnv, in June.

Change

  • Open the pull request via GitHub API after push
  • Force-push the release branch. The step does shallow clone, branches each run, so a re-run's commit is a sibling of any existing releases/<version>. Forcing also makes a re-run update the open PR instead of failing.
  • Treat a 422 mentioning already exists as success, so re-running a release is harmless.
  • Fail loudly. $ErrorActionPreference = "Stop", $LASTEXITCODE checked after each git call API errors. A clone or push failure previously left the step green.
  • Fix the argument guard. if (!$packageVersion || !$extractedPath) used ||, PowerShell's pipeline chain operator, where -or was meant, so the guard never evaluated as a boolean.
  • Exit early when the formula is unchanged, rather than relying on the || chain.

Testing

Ran on pwsh 7 on Unix like the hosted-ubuntucontainer, against a scratch tap seeded with the real formula at 2.20.0.

Case Result
First release PR opened, base master, correct one-line version diff, exit 0
Re-run of the same version Force-push updates the branch, existing PR is detected, exit 0
Unrelated API failure (invalid base) Throws with GitHub's validation body, exit 1

The first two rows are what caught the force-push bug: before it, a re-run died at the push and never reached the already-exists handling.

🤖 Generated with Claude Code

NickJosevski and others added 2 commits August 4, 2026 18:43
The deployment step cloned the tap, committed the regenerated formula and
pushed a releases/<version> branch, then stopped. Nothing ever opened a
pull request, so the branch sat unmerged and master kept serving an older
formula. The tap has accumulated a branch per release since 0.3.2 while
`brew install octopus-cli` has been stuck on 2.20.0.

Open the pull request over the GitHub API once the branch is pushed, and
treat "a pull request already exists" as success so re-running a release
is harmless.

Also make the step fail loudly rather than quietly. $LASTEXITCODE is now
checked after each git call, ErrorActionPreference is Stop, and the
argument guard uses -or rather than ||, which is a pipeline chain
operator and was never evaluating as a boolean.

Fixes #541

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Re-running a release failed at the push. The step clones master shallowly
and branches from it each time, so its commit is a sibling of any existing
releases/<version> rather than a descendant, and a plain push is rejected
as non-fast-forward — before the already-exists handling was ever reached.

Also throw with the response body. Exception.Message only ever says
"Response status code does not indicate success"; the body names the field
GitHub rejected.

Both verified against a scratch tap under pwsh 7 on Unix.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@NickJosevski
NickJosevski marked this pull request as ready for review August 5, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Homebrew Tap is not updated on release

1 participant