publish.ts 3.1 KB

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