Skip to content

fix: avoid duplicate draft releases when publishing multiple dry runs (next)#4327

Open
claude[bot] wants to merge 2 commits into
nextfrom
fix-github-publisher-duplicate-releases-next
Open

fix: avoid duplicate draft releases when publishing multiple dry runs (next)#4327
claude[bot] wants to merge 2 commits into
nextfrom
fix-github-publisher-duplicate-releases-next

Conversation

@claude

@claude claude Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Requested via Slack thread

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • The changes are appropriately documented (if applicable).
  • The changes have sufficient test coverage (if applicable).
  • The testsuite passes successfully on my local machine (if applicable).

Summarize your changes:

Ports the fix for #4325 to next — this is the next port of #4326.

Before: Running electron-forge publish --from-dry-run with multiple saved dry runs (e.g. one per platform) against the GitHub publisher could create two or more draft releases for the same version, with the assets split between them. Each restored dry run triggers its own publish() call on the same publisher instance, and each call re-lists releases to find an existing one — but GitHub's "list releases" API is eventually consistent, so it can miss the draft release created just seconds earlier by the previous dry run, causing a second createRelease for the same tag.

After: Only one draft release is created per version. Subsequent publish() calls in the same process reuse the release they just found or created instead of re-querying the eventually consistent listing.

How: Same semantics as #4326, adapted to next (where the source file is PublisherGitHub.ts): an instance-level knownReleases map keyed by tag name is consulted before hitting the list/create APIs and populated after a release is found or created. The two GetResponseDataTypeFromEndpointMethod type aliases were hoisted from the method body to module scope so the map can be typed. The regression spec (packages/publisher/github/spec/PublisherGitHub.spec.ts) simulates the eventually consistent listing and asserts that publishing two dry-run results for the same version creates exactly one release with both assets uploaded to it. All 15 tests in the package pass on next.


Generated by Claude Code

When resuming multiple saved dry runs (publish --from-dry-run), the same
PublisherGithub instance is asked to publish once per dry run. Each call
listed the repository's releases to find the target release, but GitHub's
list releases API is eventually consistent, so a release created seconds
earlier by the previous call could be missing from the listing - causing
a second, duplicate draft release to be created for the same tag and the
platform assets to be split across the two drafts.

Remember the releases found or created during this process, keyed by tag
name, and consult that cache before hitting the list releases endpoint.

Fixes #4325

# Conflicts:
#	packages/publisher/github/src/PublisherGithub.ts
The spec imported fs-extra, which is not a dependency of the
publisher-github package on this branch (knip failed CI with an
unlisted-dependency error); use node:fs/promises instead.

Also stub GITHUB_TOKEN and pass an explicit authToken in the publisher
config so the spec does not depend on ambient credentials — CI runners
have no GITHUB_TOKEN and the GitHub client constructor throws without
either. Mirrors the equivalent fix on the main-branch PR.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VpZV6TdUUfbWBHduegyqgc
@erickzhao
erickzhao marked this pull request as ready for review July 22, 2026 22:39
@erickzhao
erickzhao requested a review from a team as a code owner July 22, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants