Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e0747c

Browse files
committed
ci
1 parent 66ec378 commit 9e0747c

2 files changed

Lines changed: 88 additions & 2 deletions

File tree

script/changelog-debug.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env bun
2+
3+
import { $ } from "bun"
4+
import { parseArgs } from "util"
5+
import { getLatestRelease } from "./changelog"
6+
7+
const paths = [
8+
"packages/opencode",
9+
"packages/sdk",
10+
"packages/plugin",
11+
"packages/desktop",
12+
"packages/app",
13+
"sdks/vscode",
14+
"packages/extensions",
15+
"github",
16+
]
17+
18+
const clean = (text: string) => text.split("\n").filter(Boolean)
19+
20+
const ref = (value: string, head = false) => {
21+
if (head && value === "HEAD") return value
22+
if (value.startsWith("v")) return value
23+
return `v${value}`
24+
}
25+
26+
const { values } = parseArgs({
27+
args: Bun.argv.slice(2),
28+
options: {
29+
from: { type: "string", short: "f" },
30+
to: { type: "string", short: "t", default: "HEAD" },
31+
base: { type: "string", short: "b", default: "origin/dev" },
32+
help: { type: "boolean", short: "h", default: false },
33+
},
34+
})
35+
36+
if (values.help) {
37+
console.log(`
38+
Usage: bun script/changelog-debug.ts [options]
39+
40+
Options:
41+
-f, --from <version> Starting version (default: latest GitHub release)
42+
-t, --to <ref> Ending ref (default: HEAD)
43+
-b, --base <ref> Compare base for ahead/behind (default: origin/dev)
44+
-h, --help Show this help message
45+
46+
Examples:
47+
bun script/changelog-debug.ts
48+
bun script/changelog-debug.ts -f 1.0.200 -t dev
49+
bun script/changelog-debug.ts -f 1.0.200 -t HEAD -b origin/dev
50+
`)
51+
process.exit(0)
52+
}
53+
54+
const to = values.to!
55+
const from = values.from ?? (await getLatestRelease())
56+
const fromRef = ref(from)
57+
const toRef = ref(to, true)
58+
59+
console.log(`Debugging changelog range: ${fromRef} -> ${toRef}\n`)
60+
61+
const [ahead, behind] = await $`git rev-list --left-right --count ${values.base}...HEAD`
62+
.text()
63+
.then((text) => text.trim().split("\t"))
64+
65+
console.log(`Ahead/behind ${values.base}: ahead=${ahead ?? "0"} behind=${behind ?? "0"}`)
66+
67+
const gh = await $`gh api "/repos/anomalyco/opencode/compare/${fromRef}...${toRef}" --jq '.commits[].sha'`
68+
.text()
69+
.then(clean)
70+
71+
const localAll = await $`git log ${fromRef}..${toRef} --oneline --format="%H"`.text().then(clean)
72+
const localFiltered = await $`git log ${fromRef}..${toRef} --oneline --format="%H" -- ${paths}`.text().then(clean)
73+
74+
const ghSet = new Set(gh)
75+
const missing = localFiltered.filter((hash) => !ghSet.has(hash))
76+
77+
console.log(`GitHub compare commits: ${gh.length}`)
78+
console.log(`Local commits (all): ${localAll.length}`)
79+
console.log(`Local commits (filtered paths): ${localFiltered.length}`)
80+
console.log(`Filtered commits missing from GitHub compare: ${missing.length}`)
81+
82+
if (missing.length > 0) {
83+
console.log("\nMissing hashes (first 10):")
84+
console.log(missing.slice(0, 10).join("\n"))
85+
}

script/publish.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,16 @@ await $`bun install`
5858
await import(`../packages/sdk/js/script/build.ts`)
5959

6060
if (Script.release) {
61-
const previous = await getLatestRelease()
62-
const notes = await buildNotes(previous, "HEAD")
6361
// notes.unshift(highlightsTemplate)
6462
await $`git commit -am "release: v${Script.version}"`
6563
await $`git tag v${Script.version}`
6664
await $`git fetch origin`
6765
await $`git cherry-pick HEAD..origin/dev`.nothrow()
6866
await $`git push origin HEAD --tags --no-verify --force-with-lease`
6967
await new Promise((resolve) => setTimeout(resolve, 5_000))
68+
const previous = await getLatestRelease()
69+
console.log("previous", previous)
70+
const notes = await buildNotes(previous, "dev")
7071
await $`gh release edit v${Script.version} --draft=false --title "v${Script.version}" --notes ${notes.join("\n") || "No notable changes"}`
7172
}
7273

0 commit comments

Comments
 (0)