publish.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/env bun
  2. import { $ } from "bun"
  3. import { Script } from "@opencode-ai/script"
  4. const highlightsTemplate = `
  5. <!--
  6. Add highlights before publishing. Delete this section if no highlights.
  7. - For multiple highlights, use multiple <highlight> tags
  8. - Highlights with the same source attribute get grouped together
  9. -->
  10. <!--
  11. <highlight source="SourceName (TUI/Desktop/Web/Core)">
  12. <h2>Feature title goes here</h2>
  13. <p short="Short description used for Desktop Recap">
  14. Full description of the feature or change
  15. </p>
  16. https://github.com/user-attachments/assets/uuid-for-video (you will want to drag & drop the video or picture)
  17. <img
  18. width="1912"
  19. height="1164"
  20. alt="image"
  21. src="https://github.com/user-attachments/assets/uuid-for-image"
  22. />
  23. </highlight>
  24. -->
  25. `
  26. console.log("=== publishing ===\n")
  27. const pkgjsons = await Array.fromAsync(
  28. new Bun.Glob("**/package.json").scan({
  29. absolute: true,
  30. }),
  31. ).then((arr) => arr.filter((x) => !x.includes("node_modules") && !x.includes("dist")))
  32. for (const file of pkgjsons) {
  33. let pkg = await Bun.file(file).text()
  34. pkg = pkg.replaceAll(/"version": "[^"]+"/g, `"version": "${Script.version}"`)
  35. console.log("updated:", file)
  36. await Bun.file(file).write(pkg)
  37. }
  38. const extensionToml = new URL("../packages/extensions/zed/extension.toml", import.meta.url).pathname
  39. let toml = await Bun.file(extensionToml).text()
  40. toml = toml.replace(/^version = "[^"]+"/m, `version = "${Script.version}"`)
  41. toml = toml.replaceAll(/releases\/download\/v[^/]+\//g, `releases/download/v${Script.version}/`)
  42. console.log("updated:", extensionToml)
  43. await Bun.file(extensionToml).write(toml)
  44. await $`bun install`
  45. await import(`../packages/sdk/js/script/build.ts`)
  46. if (Script.release) {
  47. await $`git commit -am "release: v${Script.version}"`
  48. await $`git tag v${Script.version}`
  49. await $`git fetch origin`
  50. await $`git cherry-pick HEAD..origin/dev`.nothrow()
  51. await $`git push origin HEAD --tags --no-verify --force-with-lease`
  52. await new Promise((resolve) => setTimeout(resolve, 5_000))
  53. await $`gh release edit v${Script.version} --draft=false`
  54. }
  55. console.log("\n=== cli ===\n")
  56. await import(`../packages/opencode/script/publish.ts`)
  57. console.log("\n=== sdk ===\n")
  58. await import(`../packages/sdk/js/script/publish.ts`)
  59. console.log("\n=== plugin ===\n")
  60. await import(`../packages/plugin/script/publish.ts`)
  61. const dir = new URL("..", import.meta.url).pathname
  62. process.chdir(dir)