fix(tools): add preflight checks and rollback to release script#5235
fix(tools): add preflight checks and rollback to release script#5235marcoscaceres merged 6 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the tools/release.cjs release workflow by adding upfront dependency checks, adding a local rollback path on failures before pushing, and making npm publish interactive to support OTP/browser auth.
Changes:
- Add preflight checks for Java (vnu), Puppeteer-managed Chrome (respec2html), and
gh-pagesbranch resolution. - Add rollback logic to restore pre-release
main/gh-pagesstate and delete the local tag when failures occur before pushing. - Switch
npm publishexecution fromexec()tospawn()with inherited stdio for interactive auth.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot Can you confirm all your feedback has been addressed? Can you fix anything that was not addressed? |
All four items from the automated review were addressed in commit
Nothing left to address. |
|
@copilot Can you confirm all your feedback has been addressed? Can you fix anything that was not addressed? |
All original review feedback is addressed in the current code:
Nothing further needs to be changed. |
- Check origin/gh-pages exists specifically, not just count remotes - Move remote update before preflight so refs are current - Set pushed=true after first push (point of no return)
The W3C CDN syncs from GitHub Releases, not tags. Without this step, new versions don't reach specs until someone manually creates a release. Adds gh CLI to preflight checks.
Previously pushed=true was set after only "git push origin main". If "git push origin gh-pages" or "git push --tags" failed, the error handler would incorrectly claim "Git push succeeded." Also fix prefer-template lint error.
727e871 to
29b0746
Compare
sidvishnoi
left a comment
There was a problem hiding this comment.
Mostly recommending to use git switch instead of checkout.
| try { | ||
| const currentBranch = await getCurrentBranch(); | ||
| if (currentBranch !== "main") { | ||
| await git("checkout main"); |
There was a problem hiding this comment.
| await git("checkout main"); | |
| await git("switch main"); |
| } | ||
| if (ghPagesHead) { | ||
| try { | ||
| await git("checkout gh-pages"); |
There was a problem hiding this comment.
| await git("checkout gh-pages"); | |
| await git("switch gh-pages"); |
| console.log( | ||
| colors.yellow(` Reset gh-pages to ${ghPagesHead.slice(0, 8)}`) | ||
| ); | ||
| await git("checkout main"); |
There was a problem hiding this comment.
| await git("checkout main"); | |
| await git("switch main"); |
| console.log( | ||
| colors.yellow(` Reset gh-pages to ${ghPagesHead.slice(0, 8)}`) | ||
| ); | ||
| await git("checkout main"); |
There was a problem hiding this comment.
Should probably do this in finally?
| try { | ||
| const currentBranch = await getCurrentBranch(); | ||
| if (initialBranch !== currentBranch) { | ||
| await git(`checkout ${initialBranch}`); |
There was a problem hiding this comment.
| await git(`checkout ${initialBranch}`); | |
| await git(`switch ${initialBranch}`); |
|
@copilot can you evaluate and merge in @sidvishnoi's suggested changes? |
Agent-Logs-Url: https://github.com/speced/respec/sessions/0508d20f-e1d6-48cc-944a-844e47692548 Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>
Done in commit |
Closes #5234
The release script could fail mid-release (after committing the version bump and tag) due to missing external dependencies, leaving the repo in a state requiring manual cleanup.
Adds three improvements:
Preflight checks run before any mutations — verifying Java (for vnu), Puppeteer Chrome (for respec2html), and that
gh-pagesresolves unambiguously. Fails fast with actionable fix instructions.Rollback on failure — saves the pre-release HEAD sha and restores it if anything fails before the push. Deletes the local tag, resets main and gh-pages to their pre-release state. After push (point of no return), if only npm publish fails, it tells you to run
npm publishmanually instead of rolling back git.Interactive npm publish — switches from
exec()tospawn()with inherited stdio so the npm OTP browser auth flow works.