feat: migrate repo releases to manual release-please (#293)

This commit is contained in:
Trevin Chow
2026-03-17 17:58:13 -07:00
committed by GitHub
parent 74fb71731a
commit f47f829d81
44 changed files with 1967 additions and 801 deletions

View File

@@ -0,0 +1,92 @@
#!/usr/bin/env bun
import { buildReleasePreview } from "../../src/release/components"
import type { BumpOverride, ReleaseComponent } from "../../src/release/types"
function parseArgs(argv: string[]): {
title: string
files: string[]
overrides: Partial<Record<ReleaseComponent, BumpOverride>>
json: boolean
} {
let title = ""
const files: string[] = []
const overrides: Partial<Record<ReleaseComponent, BumpOverride>> = {}
let json = false
for (let index = 0; index < argv.length; index += 1) {
const arg = argv[index]
if (arg === "--title") {
title = argv[index + 1] ?? ""
index += 1
continue
}
if (arg === "--file") {
const file = argv[index + 1]
if (file) files.push(file)
index += 1
continue
}
if (arg === "--override") {
const raw = argv[index + 1] ?? ""
const [component, value] = raw.split("=")
if (component && value) {
overrides[component as ReleaseComponent] = value as BumpOverride
}
index += 1
continue
}
if (arg === "--json") {
json = true
}
}
return { title, files, overrides, json }
}
function formatPreview(preview: Awaited<ReturnType<typeof buildReleasePreview>>): string {
const lines: string[] = []
lines.push(`Release intent: ${preview.intent.raw || "(missing title)"}`)
if (preview.intent.type) {
lines.push(
`Parsed as: type=${preview.intent.type}${preview.intent.scope ? `, scope=${preview.intent.scope}` : ""}${preview.intent.breaking ? ", breaking=true" : ""}`,
)
}
if (preview.warnings.length > 0) {
lines.push("", "Warnings:")
for (const warning of preview.warnings) {
lines.push(`- ${warning}`)
}
}
if (preview.components.length === 0) {
lines.push("", "No releasable components detected.")
return lines.join("\n")
}
lines.push("", "Components:")
for (const component of preview.components) {
lines.push(`- ${component.component}`)
lines.push(` current: ${component.currentVersion}`)
lines.push(` inferred bump: ${component.inferredBump ?? "none"}`)
lines.push(` override: ${component.override}`)
lines.push(` effective bump: ${component.effectiveBump ?? "none"}`)
lines.push(` next: ${component.nextVersion ?? "unchanged"}`)
lines.push(` files: ${component.files.join(", ")}`)
}
return lines.join("\n")
}
const args = parseArgs(process.argv.slice(2))
const preview = await buildReleasePreview({
title: args.title,
files: args.files,
overrides: args.overrides,
})
if (args.json) {
console.log(JSON.stringify(preview, null, 2))
} else {
console.log(formatPreview(preview))
}

View File

@@ -0,0 +1,33 @@
#!/usr/bin/env bun
import { updateRootChangelog } from "../../src/release/metadata"
import type { ReleaseComponent } from "../../src/release/types"
type EntryInput = {
component: ReleaseComponent
version: string
date: string
sections: Record<string, string[]>
}
function parseEntries(argv: string[]): EntryInput[] {
const jsonIndex = argv.findIndex((arg) => arg === "--entries")
if (jsonIndex === -1) return []
const raw = argv[jsonIndex + 1]
if (!raw) return []
return JSON.parse(raw) as EntryInput[]
}
const write = process.argv.includes("--write")
const entries = parseEntries(process.argv.slice(2))
if (entries.length === 0) {
console.error("No changelog entries provided. Pass --entries '<json>'.")
process.exit(1)
}
const result = await updateRootChangelog({
entries,
write,
})
console.log(`${result.changed ? "update" : "keep"} ${result.path}`)

View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bun
import { syncReleaseMetadata } from "../../src/release/metadata"
const write = process.argv.includes("--write")
const versionArgs = process.argv
.slice(2)
.filter((arg) => arg.startsWith("--version:"))
.map((arg) => arg.replace("--version:", ""))
const componentVersions = Object.fromEntries(
versionArgs.map((entry) => {
const [component, version] = entry.split("=")
return [component, version]
}),
)
const result = await syncReleaseMetadata({
componentVersions,
write,
})
for (const update of result.updates) {
console.log(`${update.changed ? "update" : "keep"} ${update.path}`)
}

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bun
import { syncReleaseMetadata } from "../../src/release/metadata"
const result = await syncReleaseMetadata({ write: false })
const changed = result.updates.filter((update) => update.changed)
if (changed.length === 0) {
console.log("Release metadata is in sync.")
process.exit(0)
}
console.error("Release metadata drift detected:")
for (const update of changed) {
console.error(`- ${update.path}`)
}
process.exit(1)