Skip to content

Split publish.mjs into named steps - #55

Open
sistrall wants to merge 1 commit into
mainfrom
refactor/publish-script-steps
Open

Split publish.mjs into named steps#55
sistrall wants to merge 1 commit into
mainfrom
refactor/publish-script-steps

Conversation

@sistrall

Copy link
Copy Markdown
Contributor

Same release, same order, same behaviour. Only the shape changed.

Before: one 160-line main(), with banner comments marking the phases.
After: each phase is a function that owns its step() heading, and main() is the release:

const main = async () => {
  const { distTag } = parseOptions(process.argv.slice(2));
  const branch = preflight(distTag);

  const plan = hasPendingChangesets() ? prepareRelease() : readPublishPlan();

  publishAndTag(distTag);
  push(branch);
  await publishReleaseNotes(plan, distTag);
};

The file now reads in four sections: shell helpers, read-only questions about the repo, the steps, the release.

One structural change. The old bumping flag was tested twice, on either side of the plan read: if (bumping) { build, test, bump } … read plan … if (bumping) commit. Those five are now prepareRelease(), so the fork in main is one ternary naming the two cases — cut a release, or resume one that already bumped and committed.

Smaller ones: the commit subject moved into releaseSubject(plan); the tmpfile handling merged into readPublishPlan, so reading the plan, printing it and refusing an empty one are one function.

Checked: biome clean, and the abort paths still fire (--bogus, --tag with no value, dirty tree). Everything past preflight would need a real release to exercise.

@sistrall sistrall self-assigned this Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant