publish.ts 849 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env bun
  2. import { $ } from "bun"
  3. const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true"
  4. const version = snapshot
  5. ? `0.0.0-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}`
  6. : process.env["OPENCODE_VERSION"]
  7. if (!version) {
  8. throw new Error("OPENCODE_VERSION is required")
  9. }
  10. process.env["OPENCODE_VERSION"] = version
  11. await import(`../packages/opencode/script/publish.ts`)
  12. await import(`../packages/sdk/js/script/publish.ts`)
  13. // await import(`../packages/sdk/stainless/generate.ts`)
  14. if (!snapshot) {
  15. await $`git commit -am "Release v${version}"`
  16. await $`git tag v${version}`
  17. await $`git push origin HEAD --tags`
  18. }
  19. if (snapshot) {
  20. await $`git commit --allow-empty -m "Snapshot release v${version}"`
  21. await $`git tag v${version}`
  22. await $`git push origin v${version}`
  23. await $`git reset --soft HEAD~1`
  24. }