summaryrefslogtreecommitdiffhomepage
path: root/script/beta.ts
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2026-02-01 19:26:21 -0500
committerDax Raad <[email protected]>2026-02-01 19:29:26 -0500
commitd35956fd9272e302201d99548a1389315a20cdaf (patch)
treefea41091d7f3515883f461243f53e69b00060991 /script/beta.ts
parent7417e6eb38e96c5e3904a4503740a305475d154a (diff)
downloadopencode-d35956fd9272e302201d99548a1389315a20cdaf.tar.gz
opencode-d35956fd9272e302201d99548a1389315a20cdaf.zip
ci: prevent rate limit errors when fetching team PRs for beta releases
Diffstat (limited to 'script/beta.ts')
-rwxr-xr-xscript/beta.ts54
1 files changed, 28 insertions, 26 deletions
diff --git a/script/beta.ts b/script/beta.ts
index 7a3dfcccf..a17f02a09 100755
--- a/script/beta.ts
+++ b/script/beta.ts
@@ -1,8 +1,11 @@
#!/usr/bin/env bun
+import { Script } from "@opencode-ai/script"
+
interface PR {
number: number
title: string
+ author: { login: string }
}
interface RunResult {
@@ -12,15 +15,29 @@ interface RunResult {
}
async function main() {
- console.log("Fetching open contributor PRs...")
-
- const prsResult = await $`gh pr list --label contributor --state open --json number,title --limit 100`.nothrow()
- if (prsResult.exitCode !== 0) {
- throw new Error(`Failed to fetch PRs: ${prsResult.stderr}`)
+ console.log("Fetching open PRs from team members...")
+
+ const allPrs: PR[] = []
+ for (const member of Script.team) {
+ const result = await $`gh pr list --state open --author ${member} --json number,title,author --limit 100`.nothrow()
+ if (result.exitCode !== 0) continue
+ const memberPrs: PR[] = JSON.parse(result.stdout)
+ allPrs.push(...memberPrs)
}
- const prs: PR[] = JSON.parse(prsResult.stdout)
- console.log(`Found ${prs.length} open contributor PRs`)
+ const seen = new Set<number>()
+ const prs = allPrs.filter((pr) => {
+ if (seen.has(pr.number)) return false
+ seen.add(pr.number)
+ return true
+ })
+
+ console.log(`Found ${prs.length} open PRs from team members`)
+
+ if (prs.length === 0) {
+ console.log("No team PRs to merge")
+ return
+ }
console.log("Fetching latest dev branch...")
const fetchDev = await $`git fetch origin dev`.nothrow()
@@ -35,7 +52,6 @@ async function main() {
}
const applied: number[] = []
- const skipped: Array<{ number: number; reason: string }> = []
for (const pr of prs) {
console.log(`\nProcessing PR #${pr.number}: ${pr.title}`)
@@ -43,9 +59,7 @@ async function main() {
console.log(" Fetching PR head...")
const fetch = await run(["git", "fetch", "origin", `pull/${pr.number}/head:pr/${pr.number}`])
if (fetch.exitCode !== 0) {
- console.log(` Failed to fetch PR head: ${fetch.stderr}`)
- skipped.push({ number: pr.number, reason: `Fetch failed: ${fetch.stderr}` })
- continue
+ throw new Error(`Failed to fetch PR #${pr.number}: ${fetch.stderr}`)
}
console.log(" Merging...")
@@ -55,34 +69,24 @@ async function main() {
await $`git merge --abort`.nothrow()
await $`git checkout -- .`.nothrow()
await $`git clean -fd`.nothrow()
- skipped.push({ number: pr.number, reason: "Has conflicts" })
- continue
+ throw new Error(`Failed to merge PR #${pr.number}: Has conflicts`)
}
const mergeHead = await $`git rev-parse -q --verify MERGE_HEAD`.nothrow()
if (mergeHead.exitCode !== 0) {
console.log(" No changes, skipping")
- skipped.push({ number: pr.number, reason: "No changes" })
continue
}
const add = await $`git add -A`.nothrow()
if (add.exitCode !== 0) {
- console.log(" Failed to stage")
- await $`git checkout -- .`.nothrow()
- await $`git clean -fd`.nothrow()
- skipped.push({ number: pr.number, reason: "Failed to stage" })
- continue
+ throw new Error(`Failed to stage changes for PR #${pr.number}`)
}
const commitMsg = `Apply PR #${pr.number}: ${pr.title}`
const commit = await run(["git", "commit", "-m", commitMsg])
if (commit.exitCode !== 0) {
- console.log(` Failed to commit: ${commit.stderr}`)
- await $`git checkout -- .`.nothrow()
- await $`git clean -fd`.nothrow()
- skipped.push({ number: pr.number, reason: `Commit failed: ${commit.stderr}` })
- continue
+ throw new Error(`Failed to commit PR #${pr.number}: ${commit.stderr}`)
}
console.log(" Applied successfully")
@@ -92,8 +96,6 @@ async function main() {
console.log("\n--- Summary ---")
console.log(`Applied: ${applied.length} PRs`)
applied.forEach((num) => console.log(` - PR #${num}`))
- console.log(`Skipped: ${skipped.length} PRs`)
- skipped.forEach((x) => console.log(` - PR #${x.number}: ${x.reason}`))
console.log("\nForce pushing beta branch...")
const push = await $`git push origin beta --force --no-verify`.nothrow()