fix(release): make publish reruns safe

Reuse the existing draft release and tagged snapshot, skip already-published packages on retry, and sync dev before undrafting so release reruns stop rewriting history and can recover cleanly from partial failures.
This commit is contained in:
Kit Langton
2026-04-17 22:18:33 -04:00
parent f5cb737440
commit c79859be43
5 changed files with 127 additions and 40 deletions
+11 -1
View File
@@ -6,9 +6,19 @@ import { fileURLToPath } from "url"
const dir = fileURLToPath(new URL("..", import.meta.url))
process.chdir(dir)
async function published(name: string, version: string) {
return (await $`npm view ${name}@${version} version`.nothrow()).exitCode === 0
}
await $`bun tsc`
const pkg = await import("../package.json").then((m) => m.default)
const pkg = await import("../package.json").then(
(m) => m.default as { name: string; version: string; exports: Record<string, string> },
)
const original = JSON.parse(JSON.stringify(pkg))
if (await published(pkg.name, pkg.version)) {
console.log(`already published ${pkg.name}@${pkg.version}`)
process.exit(0)
}
for (const [key, value] of Object.entries(pkg.exports)) {
const file = value.replace("./src/", "./dist/").replace(".ts", "")
// @ts-ignore