fix(release): make --dry-run truly non-mutating

The dry-run gate was at the bottom of the script, after version bump,
lockfile update, CHANGELOG sync, build, and the chore(release) commit
had already run — so a dry-run left the local repo with a stray version
commit that had to be reset. Move the gate to right after the version
selection so dry-run shows the full preview (changesets, proposed
version, override prompt) and exits before mutating anything. Drop the
now-dead late check and the redundant DRY_RUN short-circuit in confirm().

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-28 15:22:33 -07:00
parent f2171393ae
commit fb76f24c5e
2 changed files with 9 additions and 9 deletions

View File

@@ -86,7 +86,7 @@ This will trigger `release.yml` to build binaries and create a GitHub Release. N
| `pnpm changeset status` | Check pending changesets |
| `pnpm release` | Local interactive release: previews changesets, lets you accept or override the proposed version, then bumps + builds + publishes + tags |
| `pnpm release --yes` | Same, but auto-accepts the proposed version and skips the final confirmation |
| `pnpm release --dry-run` | Walks through the same preview/version-selection flow without publishing or pushing |
| `pnpm release --dry-run` | Preview only — show changesets, proposed version, and prompt for override, then exit before any file/git/npm changes |
| `pnpm release:version` | Apply changesets and bump versions (used by CI) |
| `pnpm --filter @runfusion/fusion build:exe` | Build binary for current platform |
| `pnpm --filter @runfusion/fusion build:exe -- --target <target>` | Cross-compile for a specific platform |

View File

@@ -13,7 +13,7 @@
// Usage:
// pnpm release # interactive: review changesets, accept or override version, confirm
// pnpm release --yes # accept the proposed version, skip confirmation prompt
// pnpm release --dry-run # run through steps without publishing/pushing
// pnpm release --dry-run # preview only — exit before any file/git/npm changes
import { spawnSync } from "node:child_process";
import { readFileSync, readdirSync, writeFileSync, statSync, existsSync, unlinkSync, mkdtempSync } from "node:fs";
@@ -158,7 +158,7 @@ function parseVersionKey(key) {
}
async function confirm(prompt) {
if (AUTO_YES || DRY_RUN) return true;
if (AUTO_YES) return true;
const rl = createInterface({ input: stdin, output: stdout });
const answer = (await rl.question(`${prompt} [y/N] `)).trim().toLowerCase();
rl.close();
@@ -349,6 +349,12 @@ if (chosenVersion !== proposedVersion) {
warn(`Overriding changeset-proposed version: ${proposedVersion}${chosenVersion}`);
}
if (DRY_RUN) {
warn("--dry-run: stopping before version bump. No files modified, no commit, no publish, no tag.");
info(`Would release v${chosenVersion} (${releases.length} package(s) bumped).`);
process.exit(0);
}
if (!(await confirm(`Proceed with release v${chosenVersion} (build, publish, tag)?`))) {
warn("Aborted by user.");
process.exit(0);
@@ -391,12 +397,6 @@ run(
// --- Publish --------------------------------------------------------------
if (DRY_RUN) {
warn("--dry-run: skipping npm publish, git push, and tag.");
info(`Would publish, commit, and tag v${version}.`);
process.exit(0);
}
info("Publishing to npm (non-private packages only)…");
run("pnpm -r publish --access public --no-git-checks");