Skip to content

Commit ade794a

Browse files
committed
ci: ignore
1 parent 34271a8 commit ade794a

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

script/publish.ts

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,108 @@ import { Script } from "@opencode-ai/script"
66

77
const notes = [] as string[]
88

9+
console.log("=== publishing ===\n")
10+
11+
if (!Script.preview) {
12+
const previous = await fetch("https://registry.npmjs.org/opencode-ai/latest")
13+
.then((res) => {
14+
if (!res.ok) throw new Error(res.statusText)
15+
return res.json()
16+
})
17+
.then((data: any) => data.version)
18+
19+
const log =
20+
await $`git log v${previous}..HEAD --oneline --format="%h %s" -- packages/opencode packages/sdk packages/plugin`.text()
21+
22+
const commits = log
23+
.split("\n")
24+
.filter((line) => line && !line.match(/^\w+ (ignore:|test:|chore:|ci:)/i))
25+
.join("\n")
26+
27+
const opencode = await createOpencode()
28+
const session = await opencode.client.session.create()
29+
console.log("generating changelog since " + previous)
30+
const raw = await opencode.client.session
31+
.prompt({
32+
path: {
33+
id: session.data!.id,
34+
},
35+
body: {
36+
model: {
37+
providerID: "opencode",
38+
modelID: "kimi-k2",
39+
},
40+
parts: [
41+
{
42+
type: "text",
43+
text: `
44+
Analyze these commits and generate a changelog of all notable user facing changes.
45+
46+
Commits between ${previous} and HEAD:
47+
${commits}
48+
49+
- Do NOT make general statements about "improvements", be very specific about what was changed.
50+
- Do NOT include any information about code changes if they do not affect the user facing changes.
51+
- For commits that are already well-written and descriptive, avoid rewording them. Simply capitalize the first letter, fix any misspellings, and ensure proper English grammar.
52+
- DO NOT read any other commits than the ones listed above (THIS IS IMPORTANT TO AVOID DUPLICATING THINGS IN OUR CHANGELOG)
53+
54+
IMPORTANT: ONLY return a bulleted list of changes, do not include any other information. Do not include a preamble like "Based on my analysis..."
55+
56+
<example>
57+
- Added ability to @ mention agents
58+
- Fixed a bug where the TUI would render improperly on some terminals
59+
</example>
60+
`,
61+
},
62+
],
63+
},
64+
})
65+
.then((x) => x.data?.parts?.find((y) => y.type === "text")?.text)
66+
for (const line of raw?.split("\n") ?? []) {
67+
if (line.startsWith("- ")) {
68+
notes.push(line)
69+
}
70+
}
71+
console.log("---- Generated Changelog ----")
72+
console.log(notes.join("\n"))
73+
console.log("-----------------------------")
74+
opencode.server.close()
75+
}
76+
77+
const pkgjsons = await Array.fromAsync(
78+
new Bun.Glob("**/package.json").scan({
79+
absolute: true,
80+
}),
81+
).then((arr) => arr.filter((x) => !x.includes("node_modules") && !x.includes("dist")))
82+
83+
for (const file of pkgjsons) {
84+
let pkg = await Bun.file(file).text()
85+
pkg = pkg.replaceAll(/"version": "[^"]+"/g, `"version": "${Script.version}"`)
86+
console.log("updated:", file)
87+
await Bun.file(file).write(pkg)
88+
}
89+
90+
const extensionToml = new URL("../packages/extensions/zed/extension.toml", import.meta.url).pathname
91+
let toml = await Bun.file(extensionToml).text()
92+
toml = toml.replace(/^version = "[^"]+"/m, `version = "${Script.version}"`)
93+
toml = toml.replaceAll(/releases\/download\/v[^/]+\//g, `releases/download/v${Script.version}/`)
94+
console.log("updated:", extensionToml)
95+
await Bun.file(extensionToml).write(toml)
96+
97+
await $`bun install`
98+
99+
console.log("\n=== opencode ===\n")
100+
await import(`../packages/opencode/script/publish.ts`)
101+
102+
console.log("\n=== sdk ===\n")
103+
await import(`../packages/sdk/js/script/publish.ts`)
104+
105+
console.log("\n=== plugin ===\n")
106+
await import(`../packages/plugin/script/publish.ts`)
107+
108+
const dir = new URL("..", import.meta.url).pathname
109+
process.chdir(dir)
110+
9111
if (!Script.preview) {
10112
await $`git commit -am "release: v${Script.version}"`
11113
await $`git tag v${Script.version}`

0 commit comments

Comments
 (0)