Skip to content

Commit eac11c0

Browse files
committed
ci: stuff
1 parent 0e804c3 commit eac11c0

2 files changed

Lines changed: 44 additions & 25 deletions

File tree

.github/workflows/publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ jobs:
7171
GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
7272
AUR_KEY: ${{ secrets.AUR_KEY }}
7373
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
74+
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}

script/publish.ts

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bun
22

33
import { $ } from "bun"
4-
4+
import { createOpencodeClient, createOpencodeServer } from "@opencode-ai/sdk"
55
if (process.versions.bun !== "1.2.21") {
66
throw new Error("This script requires bun@1.2.21")
77
}
@@ -66,30 +66,48 @@ if (!snapshot) {
6666
})
6767
.then((data) => data.tag_name)
6868

69-
console.log("finding commits between", previous, "and", "HEAD")
70-
const commits = await fetch(`https://api.github.com/repos/sst/opencode/compare/${previous}...HEAD`)
71-
.then((res) => res.json())
72-
.then((data) => data.commits || [])
73-
74-
const raw = commits.map((commit: any) => `- ${commit.commit.message.split("\n").join(" ")}`)
75-
console.log(raw)
76-
77-
const notes =
78-
raw
79-
.filter((x: string) => {
80-
const lower = x.toLowerCase()
81-
return (
82-
!lower.includes("release:") &&
83-
!lower.includes("ignore:") &&
84-
!lower.includes("chore:") &&
85-
!lower.includes("ci:") &&
86-
!lower.includes("wip:") &&
87-
!lower.includes("docs:") &&
88-
!lower.includes("doc:")
89-
)
90-
})
91-
.join("\n") || "No notable changes"
92-
69+
const server = await createOpencodeServer()
70+
const client = createOpencodeClient({ baseUrl: server.url })
71+
const session = await client.session.create()
72+
console.log("generating changelog since " + previous)
73+
const notes = await client.session
74+
.prompt({
75+
path: {
76+
id: session.data!.id,
77+
},
78+
body: {
79+
parts: [
80+
{
81+
type: "text",
82+
text: `
83+
Analyze the commits between ${previous} and HEAD.
84+
85+
We care about changes to
86+
- packages/opencode
87+
- packages/sdk
88+
- packages/plugin
89+
90+
We do not care about anything else
91+
92+
Return a changelog of all notable user facing changes.
93+
94+
- Do NOT make general statements about "improvements", be very specific about what was changed.
95+
- Do NOT include any information about code changes if they do not affect the user facing changes.
96+
97+
IMPORTANT: ONLY return a bulleted list of changes, do not include any other information. Do not include a preamble like "Based on my analysis..."
98+
99+
<example>
100+
- Added ability to @ mention agents
101+
- Fixed a bug where the TUI would render improperly on some terminals
102+
</example>
103+
`,
104+
},
105+
],
106+
},
107+
})
108+
.then((x) => x.data?.parts?.find((y) => y.type === "text")?.text)
109+
console.log(notes)
110+
server.close()
93111
await $`gh release create v${version} --title "v${version}" --notes ${notes} ./packages/opencode/dist/*.zip`
94112
}
95113
if (snapshot) {

0 commit comments

Comments
 (0)