version.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  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. await $`opencode run --command changelog`.cwd(process.cwd())
  7. const file = `${process.cwd()}/UPCOMING_CHANGELOG.md`
  8. const body = await Bun.file(file)
  9. .text()
  10. .catch(() => "No notable changes")
  11. const dir = process.env.RUNNER_TEMP ?? "/tmp"
  12. const notesFile = `${dir}/opencode-release-notes.txt`
  13. await Bun.write(notesFile, body)
  14. await $`gh release create v${Script.version} -d --title "v${Script.version}" --notes-file ${notesFile}`
  15. const release = await $`gh release view v${Script.version} --json tagName,databaseId`.json()
  16. output.push(`release=${release.databaseId}`)
  17. output.push(`tag=${release.tagName}`)
  18. } else if (Script.channel === "beta") {
  19. await $`gh release create v${Script.version} -d --title "v${Script.version}" --repo ${process.env.GH_REPO}`
  20. const release =
  21. await $`gh release view v${Script.version} --json tagName,databaseId --repo ${process.env.GH_REPO}`.json()
  22. output.push(`release=${release.databaseId}`)
  23. output.push(`tag=${release.tagName}`)
  24. }
  25. output.push(`repo=${process.env.GH_REPO}`)
  26. if (process.env.GITHUB_OUTPUT) {
  27. await Bun.write(process.env.GITHUB_OUTPUT, output.join("\n"))
  28. }
  29. process.exit(0)