fix: stop rewriting dev during release publish
This commit is contained in:
parent
54078c4cae
commit
f5cb737440
2 changed files with 33 additions and 21 deletions
|
|
@ -12,30 +12,34 @@ const pkgjsons = await Array.fromAsync(
|
||||||
}),
|
}),
|
||||||
).then((arr) => arr.filter((x) => !x.includes("node_modules") && !x.includes("dist")))
|
).then((arr) => arr.filter((x) => !x.includes("node_modules") && !x.includes("dist")))
|
||||||
|
|
||||||
for (const file of pkgjsons) {
|
const extensionToml = fileURLToPath(new URL("../packages/extensions/zed/extension.toml", import.meta.url))
|
||||||
let pkg = await Bun.file(file).text()
|
|
||||||
pkg = pkg.replaceAll(/"version": "[^"]+"/g, `"version": "${Script.version}"`)
|
async function prepareReleaseFiles() {
|
||||||
console.log("updated:", file)
|
for (const file of pkgjsons) {
|
||||||
await Bun.file(file).write(pkg)
|
let pkg = await Bun.file(file).text()
|
||||||
|
pkg = pkg.replaceAll(/"version": "[^"]+"/g, `"version": "${Script.version}"`)
|
||||||
|
console.log("updated:", file)
|
||||||
|
await Bun.file(file).write(pkg)
|
||||||
|
}
|
||||||
|
|
||||||
|
let toml = await Bun.file(extensionToml).text()
|
||||||
|
toml = toml.replace(/^version = "[^"]+"/m, `version = "${Script.version}"`)
|
||||||
|
toml = toml.replaceAll(/releases\/download\/v[^/]+\//g, `releases/download/v${Script.version}/`)
|
||||||
|
console.log("updated:", extensionToml)
|
||||||
|
await Bun.file(extensionToml).write(toml)
|
||||||
|
|
||||||
|
await $`bun install`
|
||||||
|
await $`./packages/sdk/js/script/build.ts`
|
||||||
}
|
}
|
||||||
|
|
||||||
const extensionToml = fileURLToPath(new URL("../packages/extensions/zed/extension.toml", import.meta.url))
|
await prepareReleaseFiles()
|
||||||
let toml = await Bun.file(extensionToml).text()
|
|
||||||
toml = toml.replace(/^version = "[^"]+"/m, `version = "${Script.version}"`)
|
|
||||||
toml = toml.replaceAll(/releases\/download\/v[^/]+\//g, `releases/download/v${Script.version}/`)
|
|
||||||
console.log("updated:", extensionToml)
|
|
||||||
await Bun.file(extensionToml).write(toml)
|
|
||||||
|
|
||||||
await $`bun install`
|
|
||||||
await import(`../packages/sdk/js/script/build.ts`)
|
|
||||||
|
|
||||||
if (Script.release) {
|
if (Script.release) {
|
||||||
if (!Script.preview) {
|
if (!Script.preview) {
|
||||||
|
await $`git switch --detach`
|
||||||
await $`git commit -am "release: v${Script.version}"`
|
await $`git commit -am "release: v${Script.version}"`
|
||||||
await $`git tag v${Script.version}`
|
await $`git tag -f v${Script.version}`
|
||||||
await $`git fetch origin`
|
await $`git push origin refs/tags/v${Script.version} --force --no-verify`
|
||||||
await $`git cherry-pick HEAD..origin/dev`.nothrow()
|
|
||||||
await $`git push origin HEAD --tags --no-verify --force-with-lease`
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 5_000))
|
await new Promise((resolve) => setTimeout(resolve, 5_000))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,5 +58,13 @@ await import(`../packages/sdk/js/script/publish.ts`)
|
||||||
console.log("\n=== plugin ===\n")
|
console.log("\n=== plugin ===\n")
|
||||||
await import(`../packages/plugin/script/publish.ts`)
|
await import(`../packages/plugin/script/publish.ts`)
|
||||||
|
|
||||||
|
if (Script.release && !Script.preview) {
|
||||||
|
await $`git fetch origin`
|
||||||
|
await $`git checkout -B dev origin/dev`
|
||||||
|
await prepareReleaseFiles()
|
||||||
|
await $`git commit -am "sync release versions for v${Script.version}"`
|
||||||
|
await $`git push origin HEAD:dev --no-verify`
|
||||||
|
}
|
||||||
|
|
||||||
const dir = fileURLToPath(new URL("..", import.meta.url))
|
const dir = fileURLToPath(new URL("..", import.meta.url))
|
||||||
process.chdir(dir)
|
process.chdir(dir)
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@ import { Script } from "@opencode-ai/script"
|
||||||
import { $ } from "bun"
|
import { $ } from "bun"
|
||||||
|
|
||||||
const output = [`version=${Script.version}`]
|
const output = [`version=${Script.version}`]
|
||||||
|
const sha = process.env.GITHUB_SHA ?? (await $`git rev-parse HEAD`.text()).trim()
|
||||||
|
|
||||||
if (!Script.preview) {
|
if (!Script.preview) {
|
||||||
const sha = process.env.GITHUB_SHA ?? (await $`git rev-parse HEAD`.text()).trim()
|
|
||||||
await $`bun script/changelog.ts --to ${sha}`.cwd(process.cwd())
|
await $`bun script/changelog.ts --to ${sha}`.cwd(process.cwd())
|
||||||
const file = `${process.cwd()}/UPCOMING_CHANGELOG.md`
|
const file = `${process.cwd()}/UPCOMING_CHANGELOG.md`
|
||||||
const body = await Bun.file(file)
|
const body = await Bun.file(file)
|
||||||
|
|
@ -15,12 +15,12 @@ if (!Script.preview) {
|
||||||
const dir = process.env.RUNNER_TEMP ?? "/tmp"
|
const dir = process.env.RUNNER_TEMP ?? "/tmp"
|
||||||
const notesFile = `${dir}/opencode-release-notes.txt`
|
const notesFile = `${dir}/opencode-release-notes.txt`
|
||||||
await Bun.write(notesFile, body)
|
await Bun.write(notesFile, body)
|
||||||
await $`gh release create v${Script.version} -d --title "v${Script.version}" --notes-file ${notesFile}`
|
await $`gh release create v${Script.version} -d --target ${sha} --title "v${Script.version}" --notes-file ${notesFile}`
|
||||||
const release = await $`gh release view v${Script.version} --json tagName,databaseId`.json()
|
const release = await $`gh release view v${Script.version} --json tagName,databaseId`.json()
|
||||||
output.push(`release=${release.databaseId}`)
|
output.push(`release=${release.databaseId}`)
|
||||||
output.push(`tag=${release.tagName}`)
|
output.push(`tag=${release.tagName}`)
|
||||||
} else if (Script.channel === "beta") {
|
} else if (Script.channel === "beta") {
|
||||||
await $`gh release create v${Script.version} -d --title "v${Script.version}" --repo ${process.env.GH_REPO}`
|
await $`gh release create v${Script.version} -d --target ${sha} --title "v${Script.version}" --repo ${process.env.GH_REPO}`
|
||||||
const release =
|
const release =
|
||||||
await $`gh release view v${Script.version} --json tagName,databaseId --repo ${process.env.GH_REPO}`.json()
|
await $`gh release view v${Script.version} --json tagName,databaseId --repo ${process.env.GH_REPO}`.json()
|
||||||
output.push(`release=${release.databaseId}`)
|
output.push(`release=${release.databaseId}`)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue