fix(release): make release tag idempotent so a failed publish can be retried#4466
Conversation
…retried The tag vX.Y.Z was created and pushed before the npm publish loop. If publish failed partway, the remote tag already existed and a rerun died on git tag/push before it could retry publishing. Check the remote for the tag (dereferenced to its commit) first: skip the tag step when it already marks this release commit, error when it marks a different commit, otherwise create+push as before. Also reconcile a stale local tag from a prior partial run. DRY-RUN preserved.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
…otated tag, never abort on HEAD mismatch
| const headCommit = execSync('git rev-parse HEAD', { cwd: ROOT_DIR, encoding: 'utf8' }).trim(); | ||
| if (remoteTagCommit !== headCommit) { | ||
| console.warn(`⚠️ Remote tag ${tagName} points at ${remoteTagCommit}, which differs from HEAD ${headCommit}. Proceeding to publish anyway.`); | ||
| } |
There was a problem hiding this comment.
When the remote tag exists but points at a different commit, this branch only warns and still runs the publish loop from the current checkout. That lets a real vX.Y.Z tag collision proceed as if it were a retry, so npm packages can be published for a checkout that is not represented by the release tag. The retry path should skip tag creation only when the existing remote tag is the intended release commit; otherwise it should stop before publishing.
| const headCommit = execSync('git rev-parse HEAD', { cwd: ROOT_DIR, encoding: 'utf8' }).trim(); | |
| if (remoteTagCommit !== headCommit) { | |
| console.warn(`⚠️ Remote tag ${tagName} points at ${remoteTagCommit}, which differs from HEAD ${headCommit}. Proceeding to publish anyway.`); | |
| } | |
| const headCommit = execSync('git rev-parse HEAD', { cwd: ROOT_DIR, encoding: 'utf8' }).trim(); | |
| if (remoteTagCommit !== headCommit) { | |
| throw new Error(`Remote tag ${tagName} points at ${remoteTagCommit}, which differs from HEAD ${headCommit}. Refusing to publish.`); | |
| } |
Follow-up to #4464 addressing Greptile's P1 on
scripts/bump-and-publish.js.Problem: the script pushes the
vX.Y.Zgit tag before running the npm publish loop. If publish fails partway, the remote tag already exists, so a rerun fails on the existing tag before it can retry publishing — the release is stuck until the tag is manually deleted.Fix: the tag step is now idempotent. Before creating/pushing the tag, it checks the remote: if
vX.Y.Zalready exists and points at the same release commit, it skips the tag step and proceeds to publish (so a rerun retries the publish); if it points at a different commit, it errors clearly; otherwise it creates+pushes the tag as before. DRY-RUN behavior preserved.Note:
bump-and-publish.jsis byte-identical tomaster's, so the same fix applies there — happy to mirror it in a follow-up.