version.ts 884 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env bun
  2. import { Script } from "@opencode-ai/script"
  3. import { $ } from "bun"
  4. import { buildNotes, getLatestRelease } from "./changelog"
  5. const output = [`version=${Script.version}`]
  6. if (!Script.preview) {
  7. const previous = await getLatestRelease()
  8. const notes = await buildNotes(previous, "HEAD")
  9. const body = notes.join("\n") || "No notable changes"
  10. const dir = process.env.RUNNER_TEMP ?? "/tmp"
  11. const file = `${dir}/opencode-release-notes.txt`
  12. await Bun.write(file, body)
  13. await $`gh release create v${Script.version} -d --title "v${Script.version}" --notes-file ${file}`
  14. const release = await $`gh release view v${Script.version} --json id,tagName`.json()
  15. output.push(`release=${release.id}`)
  16. output.push(`tag=${release.tagName}`)
  17. }
  18. if (process.env.GITHUB_OUTPUT) {
  19. await Bun.write(process.env.GITHUB_OUTPUT, output.join("\n"))
  20. }
  21. process.exit(0)