version.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env bun
  2. import { Script } from "@opencode-ai/script"
  3. import { $ } from "bun"
  4. const output = [`version=${Script.version}`]
  5. if (!Script.preview) {
  6. const sha = process.env.GITHUB_SHA ?? (await $`git rev-parse HEAD`.text()).trim()
  7. await $`opencode run --command changelog -- --to ${sha}`.cwd(process.cwd())
  8. const file = `${process.cwd()}/UPCOMING_CHANGELOG.md`
  9. const body = await Bun.file(file)
  10. .text()
  11. .catch(() => "No notable changes")
  12. const dir = process.env.RUNNER_TEMP ?? "/tmp"
  13. const notesFile = `${dir}/opencode-release-notes.txt`
  14. await Bun.write(notesFile, body)
  15. await $`gh release create v${Script.version} -d --title "v${Script.version}" --notes-file ${notesFile}`
  16. const release = await $`gh release view v${Script.version} --json tagName,databaseId`.json()
  17. output.push(`release=${release.databaseId}`)
  18. output.push(`tag=${release.tagName}`)
  19. // kilocode_change start - handle both beta and rc preview channels
  20. } else if (Script.channel === "beta" || Script.channel === "rc") {
  21. await $`gh release create v${Script.version} -d --prerelease --title "v${Script.version}" --repo ${process.env.GH_REPO}`
  22. const release =
  23. await $`gh release view v${Script.version} --json tagName,databaseId --repo ${process.env.GH_REPO}`.json()
  24. output.push(`release=${release.databaseId}`)
  25. output.push(`tag=${release.tagName}`)
  26. // kilocode_change end
  27. }
  28. output.push(`repo=${process.env.GH_REPO}`)
  29. if (process.env.GITHUB_OUTPUT) {
  30. await Bun.write(process.env.GITHUB_OUTPUT, output.join("\n"))
  31. }
  32. process.exit(0)