fix: avoid duplicate draft releases when publishing multiple dry runs#4326
Open
claude[bot] wants to merge 2 commits into
Open
fix: avoid duplicate draft releases when publishing multiple dry runs#4326claude[bot] wants to merge 2 commits into
claude[bot] wants to merge 2 commits into
Conversation
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
This was referenced Jul 21, 2026
CI runners have no GITHUB_TOKEN in the environment, so the GitHub client constructor threw before the mock could take effect. Pass an explicit authToken through the publisher config and stub the env var so the spec exercises the same code path everywhere.
erickzhao
approved these changes
Jul 22, 2026
erickzhao
marked this pull request as ready for review
July 22, 2026 22:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested via Slack thread
Summarize your changes:
Before: Running
electron-forge publish --from-dry-runwith 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 ownPublisherGithub.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 secondcreateReleasefor 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:
PublisherGithubnow keeps an instance-levelknownReleasesmap keyed by tag name. It is consulted before hitting the list/create APIs and populated after a release is found or created, so later calls for the same tag short-circuit to the known release. The twoGetResponseDataTypeFromEndpointMethodtype aliases were hoisted from the method body to module scope so the map can be typed. A regression spec (packages/publisher/github/spec/PublisherGithub.spec.ts) simulates the eventually consistent listing (always returning an empty list) and asserts that publishing two dry-run results for the same version creates exactly one release and uploads both assets to it.Fixes #4325
Generated by Claude Code