Skip to content

fix(publish): Fail the publish when the release branch merge fails - #965

Merged
BYK merged 1 commit into
masterfrom
byk/fix/publish-fail-on-merge-failure
Nov 5, 2026
Merged

BYK merged 1 commit into
masterfrom
byk/fix/publish-fail-on-merge-failure

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #964. When Craft can't merge the release branch back, it now fails the publish instead of logging a warning. That way the failure shows up in getsentry/publish and can be retried or recovered from there.

The toolkit cli/0.48.0 publish (job log) is the motivating case. Every target shipped, but the merge hit a conflict. Craft warned and reported success, so the run was green while the release branch stayed unmerged and postReleaseBump was skipped. Someone had to read the logs to notice. getsentry/toolkit#2028 cleans up that release.

What changed

  • When handleReleaseBranch fails with a merge conflict, a push failure, or any other error, craft publish now throws ReleaseBranchMergeError. The error says every target published and lists the conflicting files and the diff. It also says how to recover:
    • merge the target branch into the release branch and push it, so the retry merges the new head, or
    • merge the release branch into the target branch yourself with a merge commit (not a squash), so the retry is a no-op merge plus cleanup.
  • The publish state file is kept, so the retry skips the published targets and only merges. In getsentry/publish, the issue checkboxes already do the same, so re-adding accepted retries only the merge.
  • The post-release bump and the post-release command are skipped. They run on the successful retry.
  • BranchCleanupError stays a warning, because the merge was already pushed and a retry can't help.
  • Sentry reporting now goes through the global error handler, instead of a captureException call in the merge path.

This reverses the earlier decision that the merge is non-blocking housekeeping. I updated .lore.md and the release-workflow docs to match.

Verification

  • New publishMain tests: a merge conflict and a push failure both reject with ReleaseBranchMergeError and keep the state file, and a failed merge skips the bump. The existing cleanup-failure test still passes as a warning.
  • pnpm lint and tsc pass, and the src/commands and resolver tests pass (91 tests). In the full pnpm test, the only failures are the same e2e failures (24 in prepare-dry-run.e2e and one other file) that I also see on master in my sandbox.

Companion: getsentry/publish#10269 fixes the getsentry/publish failure comment. That comment says "Bad branch? You can delete with ease and start over", which is the wrong advice once targets have published, because the version is already out. It now lists the done targets and says to retry by re-adding accepted.

via @BYK.

--

View Session in Sentry

Every target has published by then, but a warning hid broken releases:
the release branch stayed unmerged and postReleaseBump was skipped.
Throw ReleaseBranchMergeError with recovery steps instead, and keep the
publish state so a retry skips the published targets and only merges.
Branch cleanup failures after a pushed merge stay warnings.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-11-05 21:33 UTC

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not changed: the getsentry/publish failure comment still says "Bad branch? You can delete with ease and start over". For a merge failure that's the wrong advice: deleting the branch makes the retry fail with "Could not find the release branch".

Let's file an issue to fix this with useful advice

@BYK
BYK merged commit 2bd9e66 into master Nov 5, 2026
29 checks passed
@BYK
BYK deleted the byk/fix/publish-fail-on-merge-failure branch November 5, 2026 21:33
BYK added a commit to getsentry/publish that referenced this pull request Nov 6, 2026
…rgets done (#10269)

Companion to getsentry/craft#965. With that change, Craft fails the
publish when it can't merge the release branch back, even though every
target already shipped. The failure comment here then says "Bad branch?
You can delete with ease and start over", which is the wrong advice: the
version is already out, so starting over can't work, and the fix is to
retry.

**What changed**

- The "Inform about failure" and "Inform about cancellation" steps now
get `CRAFT_STATE_FILE_PATH` (the same `.issue` hard link that "Update
completed targets" reads).
- `post-result.js` reads the published targets from it. When any target
is checked, the comment lists them and says to fix the cause in the run
logs and re-add `accepted`, because the retry skips the checked targets.
Otherwise the comment keeps the "Bad branch?" link.
- If the state file can't be read, the step logs a warning and posts the
default comment, so a bad state file can't drop the failure comment.

Example:

> Failed to publish. ([run logs](…))
>
> _Already done: `npm`, `github`. Don't delete the release branch and
start over. Fix the cause in the run logs, then add the `accepted` label
again: the retry skips the done targets._

**Caveat:** the state file also has targets that someone checked by hand
to skip them, so a run that fails before it publishes anything but has
hand-checked targets gets the retry advice too. I think that's fine,
because retrying is still safe there.

**Verification:** `pnpm test` (163 tests) and `pnpm lint` pass. The new
tests cover the comment with and without done targets, reading the state
file (present, missing, unreadable), and the workflow wiring.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3A5a127b87e1c9aa82f1ac698f -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A5a127b87e1c9aa82f1ac698f/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <126780+BYK@users.noreply.github.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.

1 participant