Skip to content

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

Draft
NickJosevski wants to merge 1 commit into
mainfrom
nj/fix-541
Draft

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

Conversation

@NickJosevski

Copy link
Copy Markdown
Contributor

Fixes #541

Root cause

The publish step in .octopus/deployment_process.ocl clones the tap, commits the regenerated formula, pushes a releases/<version> branch — and stops:

git diff-index --quiet HEAD || (git commit -a -m "Update for release $packageVersion" `
    && git push --repo $origin --set-upstream origin $branchName `
)

There is no gh pr create and no API call. The branch lands and nothing merges it.

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.

DISTRIBUTION.md already documents this step as "Create pull request to update homebrew", so the intent was always there; the implementation just stops one call short.

Change

Open the pull request over the GitHub API after the push, using the token the step already holds. A 422 mentioning already exists is treated as success, so re-running a release is harmless.

Fail loudly. $ErrorActionPreference = "Stop", and $LASTEXITCODE is checked after each git call. 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. Now [string]::IsNullOrWhiteSpace(...) -or ....

Exit early when the formula is unchanged, rather than relying on the || chain.

Two corrections to earlier analysis in #541

I posted two claims in that thread that a closer look disproves:

  1. "Line 90 is invalid PowerShell." If it were a parse error, nothing after it would run and no branches would exist. Branches do exist for every release, so the script parses and executes. The || is genuinely wrong, but it is latent — $packageVersion and $extractedPath always come from $OctopusParameters, so the guard never had to fire. It is not what broke the tap.
  2. "Branches stop at 2.21.1, so the step may be failing outright." That was an artefact of an unpaginated API call. With --paginate, releases/2.21.3 and releases/2.21.4 are both present. The step succeeds every time; it simply never opens the PR.

The single defect is the missing pull request.

Testing

⚠️ Not executed. This is deployment-process code that only runs inside the release pipeline, and PowerShell is not available in my environment. What I have verified:

  • the OCL parses structurally — braces and EOT heredoc markers balance, all five steps intact
  • the tap's default branch is master, which is what base is set to
  • the Authorization: Bearer header form avoids the SecureString requirement that -Authentication Bearer -Token imposes

It wants a reviewer who can run PowerShell, and a dry run against a scratch repository before the next release. Given the step has been silently half-working for two years, I would rather flag that than imply more confidence than I have.

Follow-up

The tap has ~20 stale releases/* branches that will never merge. Worth deleting them once a real PR flow is working, so the next failure is visible instead of hidden in the noise.

🤖 Generated with Claude Code

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>
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