Files
nicktrn cad8791859 chore: make changeset:version atomic (#3505)
Follow-up to the v4.4.5 release incident where the release PR (#3406)
was merged with a stale lockfile and stale Chart.yaml, breaking npm +
helm releases. The two automation jobs (`update-lockfile`,
`bump-chart-version`) got cancelled mid-flight by `cancel-in-progress`
when the merge fired the workflow again on `main`.

This restructures `changeset:version` so all the post-version-bump
fixups happen in the same script and end up in a single atomic commit on
`changeset-release/main`, via `changesets/action`'s normal commit step.

Pattern borrowed from Cloudflare workers-sdk, Astro, shadcn/ui.

## Before

```
push: main
└── release-pr (changeset version → bumps package.jsons, opens PR)
    └── update-lockfile (separate job, separate commit)
        └── bump-chart-version (separate job, separate commit)
```

Three jobs, three commits to the release branch.

## After

```
push: main
└── release-pr
    └── changesets/action runs:
          changeset version
          pnpm install --lockfile-only
          node scripts/bump-helm-chart.mjs
          node scripts/cleanup-server-changes.mjs
        ...all staged and committed as ONE commit by the action
```

One job, one commit.
2026-05-02 09:45:44 +01:00

19 lines
513 B
JavaScript

import { readdirSync, unlinkSync } from "node:fs";
const DIR = ".server-changes";
const KEEP = new Set(["README.md"]);
const removed = [];
for (const file of readdirSync(DIR)) {
if (!file.endsWith(".md") || KEEP.has(file)) continue;
unlinkSync(`${DIR}/${file}`);
removed.push(file);
}
if (removed.length === 0) {
console.log(`${DIR} already clean, no changes`);
} else {
console.log(`${DIR} cleaned, removed ${removed.length} consumed file(s):`);
removed.forEach((f) => console.log(` - ${f}`));
}