Skip to content

Commit aced8c9

Browse files
committed
ci: publish
1 parent 1bb6648 commit aced8c9

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

script/publish.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true"
1414
const version = await (async () => {
1515
if (snapshot) return `0.0.0-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}`
1616
if (process.env["OPENCODE_VERSION"]) return process.env["OPENCODE_VERSION"]
17-
const [major, minor, patch] = (await $`gh release list --limit 1 --json tagName --jq '.[0].tagName'`.text())
18-
.trim()
19-
.replace(/^v/, "")
20-
.split(".")
21-
.map((x) => Number(x) || 0)
17+
const npmVersion = await fetch("https://registry.npmjs.org/opencode-ai/latest")
18+
.then((res) => {
19+
if (!res.ok) throw new Error(res.statusText)
20+
return res.json()
21+
})
22+
.then((data: any) => data.version)
23+
const [major, minor, patch] = npmVersion.split(".").map((x: string) => Number(x) || 0)
2224
const t = process.env["OPENCODE_BUMP"]?.toLowerCase()
2325
if (t === "major") return `${major + 1}.0.0`
2426
if (t === "minor") return `${major}.${minor + 1}.0`
@@ -28,12 +30,12 @@ process.env["OPENCODE_VERSION"] = version
2830
console.log("version:", version)
2931

3032
if (!snapshot) {
31-
const previous = await fetch("https://api.github.com/repos/sst/opencode/releases/latest")
33+
const previous = await fetch("https://registry.npmjs.org/opencode-ai/latest")
3234
.then((res) => {
3335
if (!res.ok) throw new Error(res.statusText)
3436
return res.json()
3537
})
36-
.then((data) => data.tag_name)
38+
.then((data: any) => data.version)
3739

3840
const opencode = await createOpencode()
3941
const session = await opencode.client.session.create()

0 commit comments

Comments
 (0)