Make npm publish resilient to concurrent pushes to main#3
Draft
livenson wants to merge 1 commit into
Draft
Conversation
The publish job bumps the version (npm version prerelease) and pushes the commit back to main. When main advances between checkout and push (a concurrent SDK-regen push, or another publish run), the bare 'git push' is rejected with a non-fast-forward 'fetch first' error and the whole publish aborts. Serialize publish runs with a concurrency group, and make the push rebase onto origin/main and retry so a racing push no longer fails the release.
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.
Problem
The
publish-npmjob fails intermittently on the git push, aborting the release:The job checks out
main, runsnpm version prerelease(which creates a version-bump commit), then pushes it back tomain. Ifmainadvances between checkout and push — e.g. a concurrent SDK-regen push tosrc/**, or anotherpublish-npmrun — the baregit pushis a non-fast-forward and is rejected, so the publish never happens. This is a well-known GitHub Actions publish race.Fix
concurrencygroup (publish-npm,cancel-in-progress: false) so publish runs are serialized instead of racing each other; queued runs still publish rather than being cancelled.git push origin HEAD:main→ on rejectiongit pull --rebase origin mainand retry, up to 5 times with backoff) so a push from another workflow (e.g. the SDK regen, which touches disjointsrc/**files) no longer fails the release.No change to publish auth or versioning behavior.
Out of scope — separate blocker
Some runs also fail later at
npm publishitself withnpm error 404 ... PUT https://registry.npmjs.org/waldur-js-client. That is an npm-side authentication/trusted-publisher problem (the workflow uses OIDC provenance viaid-token: write), not something this PR can fix — it needs the npmwaldur-js-clienttrusted-publisher / token configuration checked by a maintainer. Filing this note so it isn't lost.Testing
YAML validated locally. Best verified by watching the next
mainpublish run (or aworkflow_dispatch) complete without the fetch-first rejection.🤖 Generated with Claude Code