summaryrefslogtreecommitdiffhomepage
path: root/script/version.ts
blob: 2c158d22228cba91b9a79345578c5e4456e7b913 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bun

import { Script } from "@opencode-ai/script"
import { $ } from "bun"
import { buildNotes, getLatestRelease } from "./changelog"

const output = [`version=${Script.version}`]

if (!Script.preview) {
  await $`gh release create v${Script.version} -d --title "v${Script.version}" ${Script.preview ? "--prerelease" : ""}`
  const release = await $`gh release view v${Script.version} --json id,tagName`.json()
  const previous = await getLatestRelease(Script.version)
  const notes = await buildNotes(previous, "HEAD")
  const body = notes.join("\n") || "No notable changes"
  await $`gh release edit v${Script.version} --title "v${Script.version}" --notes ${body}`
  output.push(`release=${release.id}`)
  output.push(`tag=${release.tagName}`)
}

if (process.env.GITHUB_OUTPUT) {
  await Bun.write(process.env.GITHUB_OUTPUT, output.join("\n"))
}