ci
This commit is contained in:
+17
-16
@@ -8,7 +8,6 @@ console.log("=== publishing ===\n")
|
|||||||
|
|
||||||
const dir = fileURLToPath(new URL("..", import.meta.url))
|
const dir = fileURLToPath(new URL("..", import.meta.url))
|
||||||
process.chdir(dir)
|
process.chdir(dir)
|
||||||
|
|
||||||
const tag = `v${Script.version}`
|
const tag = `v${Script.version}`
|
||||||
|
|
||||||
const pkgjsons = await Array.fromAsync(
|
const pkgjsons = await Array.fromAsync(
|
||||||
@@ -17,11 +16,7 @@ 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")))
|
||||||
|
|
||||||
if (Script.release && !Script.preview) {
|
async function prepareReleaseFiles() {
|
||||||
await $`git fetch origin --tags`
|
|
||||||
await $`git switch --detach`
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const file of pkgjsons) {
|
for (const file of pkgjsons) {
|
||||||
let pkg = await Bun.file(file).text()
|
let pkg = await Bun.file(file).text()
|
||||||
pkg = pkg.replaceAll(/"version": "[^"]+"/g, `"version": "${Script.version}"`)
|
pkg = pkg.replaceAll(/"version": "[^"]+"/g, `"version": "${Script.version}"`)
|
||||||
@@ -37,34 +32,40 @@ console.log("updated:", extensionToml)
|
|||||||
await Bun.file(extensionToml).write(toml)
|
await Bun.file(extensionToml).write(toml)
|
||||||
|
|
||||||
await $`bun install`
|
await $`bun install`
|
||||||
await import(`../packages/sdk/js/script/build.ts`)
|
await $`./packages/sdk/js/script/build.ts`
|
||||||
process.chdir(dir)
|
}
|
||||||
|
|
||||||
|
if (Script.release && !Script.preview) {
|
||||||
|
await $`git fetch origin --tags`
|
||||||
|
await $`git switch --detach`
|
||||||
|
}
|
||||||
|
|
||||||
|
await prepareReleaseFiles()
|
||||||
|
|
||||||
console.log("\n=== cli ===\n")
|
console.log("\n=== cli ===\n")
|
||||||
await import(`../packages/opencode/script/publish.ts`)
|
await $`bun ./packages/opencode/script/publish.ts`
|
||||||
|
|
||||||
console.log("\n=== sdk ===\n")
|
console.log("\n=== sdk ===\n")
|
||||||
await import(`../packages/sdk/js/script/publish.ts`)
|
await $`bun ./packages/sdk/js/script/publish.ts`
|
||||||
|
|
||||||
console.log("\n=== plugin ===\n")
|
console.log("\n=== plugin ===\n")
|
||||||
await import(`../packages/plugin/script/publish.ts`)
|
await $`bun ./packages/plugin/script/publish.ts`
|
||||||
|
|
||||||
if (Script.release) {
|
if (Script.release) {
|
||||||
await import(`../packages/desktop/scripts/finalize-latest-json.ts`)
|
await $`bun ./packages/desktop/scripts/finalize-latest-json.ts`
|
||||||
await import(`../packages/desktop-electron/scripts/finalize-latest-yml.ts`)
|
await $`bun ./packages/desktop-electron/scripts/finalize-latest-yml.ts`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Script.release && !Script.preview) {
|
if (Script.release && !Script.preview) {
|
||||||
process.chdir(dir)
|
|
||||||
await $`git commit -am "release: ${tag}"`
|
await $`git commit -am "release: ${tag}"`
|
||||||
const releaseCommit = (await $`git rev-parse HEAD`.text()).trim()
|
|
||||||
await $`git tag -d ${tag}`.nothrow()
|
await $`git tag -d ${tag}`.nothrow()
|
||||||
await $`git tag ${tag}`
|
await $`git tag ${tag}`
|
||||||
await $`git push origin refs/tags/${tag} --force-with-lease --no-verify`
|
await $`git push origin refs/tags/${tag} --force-with-lease --no-verify`
|
||||||
await new Promise((resolve) => setTimeout(resolve, 5_000))
|
await new Promise((resolve) => setTimeout(resolve, 5_000))
|
||||||
await $`git fetch origin`
|
await $`git fetch origin`
|
||||||
await $`git checkout -B dev origin/dev`
|
await $`git checkout -B dev origin/dev`
|
||||||
await $`git cherry-pick ${releaseCommit}`
|
await prepareReleaseFiles()
|
||||||
|
await $`git commit -am "sync release versions for ${tag}"`
|
||||||
await $`git push origin HEAD:dev --no-verify`
|
await $`git push origin HEAD:dev --no-verify`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user