version.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  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 $`bun script/changelog.ts --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. } else if (Script.channel === "beta") {
  20. await $`gh release create v${Script.version} -d --title "v${Script.version}" --repo ${process.env.GH_REPO}`
  21. const release =
  22. await $`gh release view v${Script.version} --json tagName,databaseId --repo ${process.env.GH_REPO}`.json()
  23. output.push(`release=${release.databaseId}`)
  24. output.push(`tag=${release.tagName}`)
  25. }
  26. output.push(`repo=${process.env.GH_REPO}`)
  27. if (process.env.GITHUB_OUTPUT) {
  28. await Bun.write(process.env.GITHUB_OUTPUT, output.join("\n"))
  29. }
  30. process.exit(0)