From 9e0747c9b4ec41e7ba5dbe6891770cfa600f768d Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Fri, 30 Jan 2026 00:39:23 -0500 Subject: [PATCH] ci --- script/changelog-debug.ts | 85 +++++++++++++++++++++++++++++++++++++++ script/publish.ts | 5 ++- 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 script/changelog-debug.ts diff --git a/script/changelog-debug.ts b/script/changelog-debug.ts new file mode 100644 index 0000000000..1144d3b0cb --- /dev/null +++ b/script/changelog-debug.ts @@ -0,0 +1,85 @@ +#!/usr/bin/env bun + +import { $ } from "bun" +import { parseArgs } from "util" +import { getLatestRelease } from "./changelog" + +const paths = [ + "packages/opencode", + "packages/sdk", + "packages/plugin", + "packages/desktop", + "packages/app", + "sdks/vscode", + "packages/extensions", + "github", +] + +const clean = (text: string) => text.split("\n").filter(Boolean) + +const ref = (value: string, head = false) => { + if (head && value === "HEAD") return value + if (value.startsWith("v")) return value + return `v${value}` +} + +const { values } = parseArgs({ + args: Bun.argv.slice(2), + options: { + from: { type: "string", short: "f" }, + to: { type: "string", short: "t", default: "HEAD" }, + base: { type: "string", short: "b", default: "origin/dev" }, + help: { type: "boolean", short: "h", default: false }, + }, +}) + +if (values.help) { + console.log(` +Usage: bun script/changelog-debug.ts [options] + +Options: + -f, --from Starting version (default: latest GitHub release) + -t, --to Ending ref (default: HEAD) + -b, --base Compare base for ahead/behind (default: origin/dev) + -h, --help Show this help message + +Examples: + bun script/changelog-debug.ts + bun script/changelog-debug.ts -f 1.0.200 -t dev + bun script/changelog-debug.ts -f 1.0.200 -t HEAD -b origin/dev +`) + process.exit(0) +} + +const to = values.to! +const from = values.from ?? (await getLatestRelease()) +const fromRef = ref(from) +const toRef = ref(to, true) + +console.log(`Debugging changelog range: ${fromRef} -> ${toRef}\n`) + +const [ahead, behind] = await $`git rev-list --left-right --count ${values.base}...HEAD` + .text() + .then((text) => text.trim().split("\t")) + +console.log(`Ahead/behind ${values.base}: ahead=${ahead ?? "0"} behind=${behind ?? "0"}`) + +const gh = await $`gh api "/repos/anomalyco/opencode/compare/${fromRef}...${toRef}" --jq '.commits[].sha'` + .text() + .then(clean) + +const localAll = await $`git log ${fromRef}..${toRef} --oneline --format="%H"`.text().then(clean) +const localFiltered = await $`git log ${fromRef}..${toRef} --oneline --format="%H" -- ${paths}`.text().then(clean) + +const ghSet = new Set(gh) +const missing = localFiltered.filter((hash) => !ghSet.has(hash)) + +console.log(`GitHub compare commits: ${gh.length}`) +console.log(`Local commits (all): ${localAll.length}`) +console.log(`Local commits (filtered paths): ${localFiltered.length}`) +console.log(`Filtered commits missing from GitHub compare: ${missing.length}`) + +if (missing.length > 0) { + console.log("\nMissing hashes (first 10):") + console.log(missing.slice(0, 10).join("\n")) +} diff --git a/script/publish.ts b/script/publish.ts index 23a6e5c9df..5fa84825b3 100755 --- a/script/publish.ts +++ b/script/publish.ts @@ -58,8 +58,6 @@ await $`bun install` await import(`../packages/sdk/js/script/build.ts`) if (Script.release) { - const previous = await getLatestRelease() - const notes = await buildNotes(previous, "HEAD") // notes.unshift(highlightsTemplate) await $`git commit -am "release: v${Script.version}"` await $`git tag v${Script.version}` @@ -67,6 +65,9 @@ if (Script.release) { await $`git cherry-pick HEAD..origin/dev`.nothrow() await $`git push origin HEAD --tags --no-verify --force-with-lease` await new Promise((resolve) => setTimeout(resolve, 5_000)) + const previous = await getLatestRelease() + console.log("previous", previous) + const notes = await buildNotes(previous, "dev") await $`gh release edit v${Script.version} --draft=false --title "v${Script.version}" --notes ${notes.join("\n") || "No notable changes"}` }