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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user