From 5f1394ad546761456fa590e6f1e8afdb41adeca8 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 11:48:52 +0000 Subject: [PATCH 1/4] ci: Open a PR for each new @sentry/api release getsentry/sentry releases @sentry/api from static/packages/api. A daily workflow pins the catalog to the newest npm release and opens a PR, so test.yml checks the CLI, MCP and shared packages against each release. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com> --- .github/workflows/bump-sentry-api.yml | 48 ++++++++++ docs/operations/github-actions.md | 10 ++ package.json | 2 +- scripts/bump-sentry-api.mjs | 127 ++++++++++++++++++++++++++ scripts/bump-sentry-api.test.mjs | 35 +++++++ 5 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/bump-sentry-api.yml create mode 100644 scripts/bump-sentry-api.mjs create mode 100644 scripts/bump-sentry-api.test.mjs diff --git a/.github/workflows/bump-sentry-api.yml b/.github/workflows/bump-sentry-api.yml new file mode 100644 index 000000000..243faabaa --- /dev/null +++ b/.github/workflows/bump-sentry-api.yml @@ -0,0 +1,48 @@ +name: Bump @sentry/api + +# Opens a pull request that pins @sentry/api, which getsentry/sentry releases +# from static/packages/api, to its newest npm release. test.yml then checks the +# CLI, MCP and shared packages against it, so this repository validates each +# release as an outside consumer. +on: + schedule: + - cron: "41 7 * * *" + workflow_dispatch: + +permissions: + contents: read + +# A manual run and the daily run must not both push the same branch. +concurrency: + group: bump-sentry-api + cancel-in-progress: false + +jobs: + bump: + name: Bump @sentry/api + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + # A pull request opened with github.token does not start test.yml, so + # the bump pushes and opens it with the release bot's token. + - name: Get auth token + id: token + uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0 + with: + app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }} + private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }} + + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + with: + token: ${{ steps.token.outputs.token }} + + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4 + + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 + with: + node-version: "22.23.4" + + - name: Bump @sentry/api + env: + GH_TOKEN: ${{ steps.token.outputs.token }} + run: node scripts/bump-sentry-api.mjs diff --git a/docs/operations/github-actions.md b/docs/operations/github-actions.md index b67b5c694..09afb8da1 100644 --- a/docs/operations/github-actions.md +++ b/docs/operations/github-actions.md @@ -111,6 +111,16 @@ Runs the label publisher's regression tests when its workflow or tests change. Covers label replacement, stale revisions, failed classifications, and concurrent label creation. +### bump-sentry-api.yml + +Every day and on manual dispatch, `scripts/bump-sentry-api.mjs` pins the +catalog's `@sentry/api` to its newest npm release. It also updates its +`minimumReleaseAgeExclude` entry so the fresh release installs, and opens a PR +for the change. `test.yml` runs on that PR, so the CLI, MCP and shared packages +are checked against each release that getsentry/sentry publishes. The release +bot's token opens the PR, because a PR opened with `github.token` does not +start other workflows. The PR is not merged automatically. + ## Package CI checks Add a check for one workspace package to that package's `package.json`, not to diff --git a/package.json b/package.json index 63441ae69..317b1b571 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "scripts": { "docs:check": "node scripts/check-doc-links.mjs", - "test:ci-projects": "node --test scripts/ci-projects.test.mjs scripts/check-workspace-deps.test.mjs scripts/cli-nightly-version.test.mjs scripts/cli-nightly-watchdog.test.mjs scripts/codemod-version-changed.test.mjs scripts/cloudflare-deployment.test.mjs scripts/deploy-workflow.test.mjs scripts/migrate-cloudflare-token.test.mjs scripts/oxc-config.test.mjs scripts/cli-lint-rules.test.mjs scripts/workflow-policy.test.mjs", + "test:ci-projects": "node --test scripts/ci-projects.test.mjs scripts/check-workspace-deps.test.mjs scripts/cli-nightly-version.test.mjs scripts/cli-nightly-watchdog.test.mjs scripts/bump-sentry-api.test.mjs scripts/codemod-version-changed.test.mjs scripts/cloudflare-deployment.test.mjs scripts/deploy-workflow.test.mjs scripts/migrate-cloudflare-token.test.mjs scripts/oxc-config.test.mjs scripts/cli-lint-rules.test.mjs scripts/workflow-policy.test.mjs", "dev": "pnpm --filter '@sentry/mcp-cloudflare...' --if-present run build && dotenv -e .env -e .env.local -- pnpm --parallel --filter @sentry/mcp-cloudflare --filter @sentry/mcp-core --filter @sentry/mcp-server-mocks --if-present run dev", "dev:stdio": "pnpm --filter '@sentry/mcp-core...' --if-present run build 1>&2 && dotenv -e .env -e .env.local -- pnpm --silent --dir packages/cli run cli mcp", "build": "dotenv -e .env -e .env.local -- pnpm -r --filter '!sentry' --filter '!sentry-cli-docs' --if-present run build", diff --git a/scripts/bump-sentry-api.mjs b/scripts/bump-sentry-api.mjs new file mode 100644 index 000000000..9724621ae --- /dev/null +++ b/scripts/bump-sentry-api.mjs @@ -0,0 +1,127 @@ +import { execFileSync } from "node:child_process"; +import { readFileSync, writeFileSync } from "node:fs"; +import { pathToFileURL } from "node:url"; + +/** + * Pins the workspace catalog's `@sentry/api` to its newest npm release and + * opens a pull request for it, so test.yml checks the CLI, MCP and shared + * packages against each release. getsentry/sentry publishes the package from + * `static/packages/api`. + */ + +const PACKAGE = "@sentry/api"; +const WORKSPACE = "pnpm-workspace.yaml"; + +const CATALOG_ENTRY = /^(\s+"@sentry\/api":\s*)(\S+)\s*$/m; +const RELEASE_AGE_ENTRY = /^(\s+-\s*"@sentry\/api@)([^"]+)("\s*)$/m; + +/** + * Return pnpm-workspace.yaml with `@sentry/api` pinned to `version`, in the + * catalog and in `minimumReleaseAgeExclude`, which lets a fresh release + * install. Throws when either entry is missing. + */ +export function pinSentryApi(workspace, version) { + for (const [pattern, name] of [ + [CATALOG_ENTRY, "catalog"], + [RELEASE_AGE_ENTRY, "minimumReleaseAgeExclude"], + ]) { + const count = workspace.match(new RegExp(pattern.source, "gm"))?.length; + if (count !== 1) { + throw new Error( + `${WORKSPACE} needs one ${name} entry for ${PACKAGE}, found ${count ?? 0}`, + ); + } + } + const catalog = CATALOG_ENTRY.exec(workspace); + return { + current: catalog[2], + workspace: workspace + .replace(CATALOG_ENTRY, (_, key) => `${key}${version}`) + .replace( + RELEASE_AGE_ENTRY, + (_, start, _old, end) => `${start}${version}${end}`, + ), + }; +} + +/** Whether `version` is a stable release, such as 2.5.1. */ +export function isRelease(version) { + return /^\d+\.\d+\.\d+$/.test(version); +} + +function run(command, args, options = {}) { + return execFileSync(command, args, { + encoding: "utf8", + timeout: 600_000, + stdio: ["ignore", "pipe", "inherit"], + ...options, + }).trim(); +} + +function main() { + const latest = run("npm", ["view", PACKAGE, "version"]); + if (!isRelease(latest)) { + throw new Error(`Expected a release version of ${PACKAGE}, got: ${latest}`); + } + const { current, workspace } = pinSentryApi( + readFileSync(WORKSPACE, "utf8"), + latest, + ); + if (current === latest) { + console.log(`${PACKAGE} is already ${latest}.`); + return; + } + console.log(`Bumping ${PACKAGE} from ${current} to ${latest}.`); + writeFileSync(WORKSPACE, workspace); + run("pnpm", ["install", "--lockfile-only", "--ignore-scripts"], { + stdio: ["ignore", "inherit", "inherit"], + }); + + // A run that stopped before opening the PR leaves the branch behind, so + // overwrite it and reuse an open PR. + const branch = `bot/bump-sentry-api-to-${latest}`; + const title = `chore(deps): Bump ${PACKAGE} to ${latest}`; + run("git", ["checkout", "-B", branch]); + run("git", ["add", WORKSPACE, "pnpm-lock.yaml"]); + run("git", [ + "-c", + "user.name=github-actions[bot]", + "-c", + "user.email=41898282+github-actions[bot]@users.noreply.github.com", + "commit", + "-m", + title, + ]); + run("git", ["push", "--force", "--set-upstream", "origin", branch]); + const open = run("gh", [ + "pr", + "list", + "--head", + branch, + "--state", + "open", + "--json", + "number", + "--jq", + "length", + ]); + if (open === "0") { + run("gh", [ + "pr", + "create", + "--head", + branch, + "--title", + title, + "--body", + `Pins ${PACKAGE} to [${latest}](https://github.com/getsentry/sentry/releases/tag/api@${latest}), so CI checks this repository against the release.`, + ]); + } +} + +if ( + process.argv[1] && + import.meta.url === pathToFileURL(process.argv[1]).href +) { + main(); +} diff --git a/scripts/bump-sentry-api.test.mjs b/scripts/bump-sentry-api.test.mjs new file mode 100644 index 000000000..83e70e4ee --- /dev/null +++ b/scripts/bump-sentry-api.test.mjs @@ -0,0 +1,35 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import test from "node:test"; +import { isRelease, pinSentryApi } from "./bump-sentry-api.mjs"; + +const workspace = readFileSync( + new URL("../pnpm-workspace.yaml", import.meta.url), + "utf8", +); + +test("pins the catalog and the release-age exclusion together", () => { + const { current, workspace: pinned } = pinSentryApi(workspace, "9.8.7"); + assert.match(current, /^\d+\.\d+\.\d+$/); + assert.match(pinned, /^ {2}"@sentry\/api": 9\.8\.7$/m); + assert.match(pinned, /^ {2}- "@sentry\/api@9\.8\.7"$/m); + assert.equal(pinned.split("9.8.7").length - 1, 2); + // Nothing else changes. + assert.equal(pinned.replaceAll("9.8.7", current), workspace); +}); + +test("fails when an entry is missing or repeated", () => { + const withoutExclusion = workspace.replace(/^ +- "@sentry\/api@.*\n/m, ""); + assert.throws( + () => pinSentryApi(withoutExclusion, "9.8.7"), + /minimumReleaseAgeExclude/, + ); + const repeated = workspace.replace(/^( +"@sentry\/api": .*\n)/m, "$1$1"); + assert.throws(() => pinSentryApi(repeated, "9.8.7"), /found 2/); +}); + +test("accepts only stable releases", () => { + assert.equal(isRelease("2.5.1"), true); + assert.equal(isRelease("3.0.0-rc.0"), false); + assert.equal(isRelease(""), false); +}); From a2f034d9dac0291b6a79c319b25742127b722cc5 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 12:03:46 +0000 Subject: [PATCH 2/4] fix(ci): Keep open @sentry/api bump PRs and survive inherited stdout run() trimmed execFileSync's result, which is null for the pnpm install that inherits stdout, so every bump crashed before committing. Check for an open bump PR first and leave it alone, so a daily run does not force-push over adapter fixes pushed to it. --- scripts/bump-sentry-api.mjs | 65 +++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/scripts/bump-sentry-api.mjs b/scripts/bump-sentry-api.mjs index 9724621ae..c2e6dd7cf 100644 --- a/scripts/bump-sentry-api.mjs +++ b/scripts/bump-sentry-api.mjs @@ -50,12 +50,16 @@ export function isRelease(version) { } function run(command, args, options = {}) { - return execFileSync(command, args, { - encoding: "utf8", - timeout: 600_000, - stdio: ["ignore", "pipe", "inherit"], - ...options, - }).trim(); + return ( + execFileSync(command, args, { + encoding: "utf8", + timeout: 600_000, + stdio: ["ignore", "pipe", "inherit"], + ...options, + }) + // execFileSync returns null when stdout is inherited. + ?.trim() + ); } function main() { @@ -71,6 +75,26 @@ function main() { console.log(`${PACKAGE} is already ${latest}.`); return; } + + // An open bump PR can carry adapter fixes, so leave it alone. + const branch = `bot/bump-sentry-api-to-${latest}`; + const open = run("gh", [ + "pr", + "list", + "--head", + branch, + "--state", + "open", + "--json", + "number", + "--jq", + "length", + ]); + if (open !== "0") { + console.log(`A PR for ${branch} is already open.`); + return; + } + console.log(`Bumping ${PACKAGE} from ${current} to ${latest}.`); writeFileSync(WORKSPACE, workspace); run("pnpm", ["install", "--lockfile-only", "--ignore-scripts"], { @@ -78,8 +102,7 @@ function main() { }); // A run that stopped before opening the PR leaves the branch behind, so - // overwrite it and reuse an open PR. - const branch = `bot/bump-sentry-api-to-${latest}`; + // overwrite it. const title = `chore(deps): Bump ${PACKAGE} to ${latest}`; run("git", ["checkout", "-B", branch]); run("git", ["add", WORKSPACE, "pnpm-lock.yaml"]); @@ -93,30 +116,16 @@ function main() { title, ]); run("git", ["push", "--force", "--set-upstream", "origin", branch]); - const open = run("gh", [ + run("gh", [ "pr", - "list", + "create", "--head", branch, - "--state", - "open", - "--json", - "number", - "--jq", - "length", + "--title", + title, + "--body", + `Pins ${PACKAGE} to [${latest}](https://github.com/getsentry/sentry/releases/tag/api@${latest}), so CI checks this repository against the release.`, ]); - if (open === "0") { - run("gh", [ - "pr", - "create", - "--head", - branch, - "--title", - title, - "--body", - `Pins ${PACKAGE} to [${latest}](https://github.com/getsentry/sentry/releases/tag/api@${latest}), so CI checks this repository against the release.`, - ]); - } } if ( From 84d4d7a3ab9dfc64b39a63b905853ae760fd1954 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 13:39:26 +0000 Subject: [PATCH 3/4] ci: Keep one rolling PR on the newest @sentry/api release A PR per release is noisy. The bump now keeps a single PR on the bot/bump-sentry-api branch: it opens one when none is open, and when a newer release ships it rebuilds the branch from main, force-pushes with a lease and retitles the PR. A commit on the branch from anyone but the bot makes it skip with a warning instead of overwriting the commit. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com> --- .github/workflows/bump-sentry-api.yml | 10 +- docs/operations/github-actions.md | 24 +++-- scripts/bump-sentry-api.mjs | 129 +++++++++++++++++++------- scripts/bump-sentry-api.test.mjs | 14 ++- 4 files changed, 129 insertions(+), 48 deletions(-) diff --git a/.github/workflows/bump-sentry-api.yml b/.github/workflows/bump-sentry-api.yml index 243faabaa..aa4b9db75 100644 --- a/.github/workflows/bump-sentry-api.yml +++ b/.github/workflows/bump-sentry-api.yml @@ -1,9 +1,9 @@ name: Bump @sentry/api -# Opens a pull request that pins @sentry/api, which getsentry/sentry releases -# from static/packages/api, to its newest npm release. test.yml then checks the -# CLI, MCP and shared packages against it, so this repository validates each -# release as an outside consumer. +# Keeps one pull request that pins @sentry/api, which getsentry/sentry releases +# from static/packages/api, to its newest npm release, and moves it to each new +# release. test.yml then checks the CLI, MCP and shared packages against it, so +# this repository validates each release as an outside consumer. on: schedule: - cron: "41 7 * * *" @@ -35,6 +35,8 @@ jobs: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: token: ${{ steps.token.outputs.token }} + # The bump compares the open PR's branch with main. + fetch-depth: 0 - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4 diff --git a/docs/operations/github-actions.md b/docs/operations/github-actions.md index 09afb8da1..346f3b4ac 100644 --- a/docs/operations/github-actions.md +++ b/docs/operations/github-actions.md @@ -113,13 +113,23 @@ label creation. ### bump-sentry-api.yml -Every day and on manual dispatch, `scripts/bump-sentry-api.mjs` pins the -catalog's `@sentry/api` to its newest npm release. It also updates its -`minimumReleaseAgeExclude` entry so the fresh release installs, and opens a PR -for the change. `test.yml` runs on that PR, so the CLI, MCP and shared packages -are checked against each release that getsentry/sentry publishes. The release -bot's token opens the PR, because a PR opened with `github.token` does not -start other workflows. The PR is not merged automatically. +Every day and on manual dispatch, `scripts/bump-sentry-api.mjs` keeps one PR +that pins the catalog's `@sentry/api` to its newest npm release, on the +`bot/bump-sentry-api` branch. It also updates the package's +`minimumReleaseAgeExclude` entry so the fresh release installs. `test.yml` runs +on that PR, so the CLI, MCP and shared packages are checked against each release +that getsentry/sentry publishes. The release bot's token opens the PR, because a +PR opened with `github.token` does not start other workflows. + +- With no open bump PR, it opens one. +- When a newer release ships while the PR is open, it rebuilds the branch from + main with that version, force-pushes it, and retitles the PR. It never opens a + second one. +- The branch belongs to the script. If someone pushes their own commit to it, + the script stops updating the PR and logs a warning, so the commit is not + lost. Rebase it onto the new release by hand, or close it and let the next run + open a fresh PR. +- The PR is never merged automatically. ## Package CI checks diff --git a/scripts/bump-sentry-api.mjs b/scripts/bump-sentry-api.mjs index c2e6dd7cf..f22455860 100644 --- a/scripts/bump-sentry-api.mjs +++ b/scripts/bump-sentry-api.mjs @@ -3,14 +3,21 @@ import { readFileSync, writeFileSync } from "node:fs"; import { pathToFileURL } from "node:url"; /** - * Pins the workspace catalog's `@sentry/api` to its newest npm release and - * opens a pull request for it, so test.yml checks the CLI, MCP and shared - * packages against each release. getsentry/sentry publishes the package from + * Keeps one pull request that pins the workspace catalog's `@sentry/api` to + * its newest npm release, so test.yml checks the CLI, MCP and shared packages + * against each release. getsentry/sentry publishes the package from * `static/packages/api`. + * + * The PR's branch belongs to this script: each new release rebuilds it from + * main. When someone has pushed their own commit to it, the script leaves the + * branch alone and warns instead, so the commit is not lost. */ const PACKAGE = "@sentry/api"; const WORKSPACE = "pnpm-workspace.yaml"; +const BRANCH = "bot/bump-sentry-api"; +const BOT_NAME = "github-actions[bot]"; +const BOT_EMAIL = "41898282+github-actions[bot]@users.noreply.github.com"; const CATALOG_ENTRY = /^(\s+"@sentry\/api":\s*)(\S+)\s*$/m; const RELEASE_AGE_ENTRY = /^(\s+-\s*"@sentry\/api@)([^"]+)("\s*)$/m; @@ -62,6 +69,23 @@ function run(command, args, options = {}) { ); } +/** + * What to do about the bump PR. `main` and `branch` are the versions pinned + * on main and on the open bump PR's branch (undefined without an open PR); + * `foreignCommits` counts the branch's commits not made by this script. + */ +export function planBump({ latest, main, branch, foreignCommits = 0 }) { + if (main === latest) return "none"; + if (branch === undefined) return "open"; + if (branch === latest) return "none"; + return foreignCommits > 0 ? "keep" : "update"; +} + +/** The pinned version in pnpm-workspace.yaml `source`. */ +function pinnedVersion(source) { + return pinSentryApi(source, "0.0.0").current; +} + function main() { const latest = run("npm", ["view", PACKAGE, "version"]); if (!isRelease(latest)) { @@ -71,61 +95,94 @@ function main() { readFileSync(WORKSPACE, "utf8"), latest, ); - if (current === latest) { - console.log(`${PACKAGE} is already ${latest}.`); - return; - } - // An open bump PR can carry adapter fixes, so leave it alone. - const branch = `bot/bump-sentry-api-to-${latest}`; - const open = run("gh", [ + const pr = run("gh", [ "pr", "list", "--head", - branch, + BRANCH, "--state", "open", "--json", "number", "--jq", - "length", + ".[0].number // empty", ]); - if (open !== "0") { - console.log(`A PR for ${branch} is already open.`); + // The remote branch's commit, or empty when it does not exist. Pushing with + // it as the lease fails if the branch moves while this runs. + const remote = run("git", [ + "ls-remote", + "origin", + `refs/heads/${BRANCH}`, + ]).split(/\s/)[0]; + let branch; + let foreignCommits = 0; + if (pr && remote) { + run("git", ["fetch", "--quiet", "origin", BRANCH, "main"]); + branch = pinnedVersion(run("git", ["show", `${remote}:${WORKSPACE}`])); + foreignCommits = run("git", [ + "log", + "--format=%ae", + `origin/main..${remote}`, + ]) + .split("\n") + .filter((email) => email && email !== BOT_EMAIL).length; + } + + const plan = planBump({ latest, main: current, branch, foreignCommits }); + if (plan === "none") { + console.log( + `${PACKAGE} ${latest} is already pinned${branch ? ` in #${pr}` : ""}.`, + ); + return; + } + if (plan === "keep") { + console.log( + `::warning::#${pr} has commits not made by this script, so it stays on ${PACKAGE} ${branch}. Rebase it onto ${latest} by hand, or close it to let the next run open a new one.`, + ); return; } - console.log(`Bumping ${PACKAGE} from ${current} to ${latest}.`); + console.log(`Pinning ${PACKAGE} ${latest} (main has ${current}).`); writeFileSync(WORKSPACE, workspace); run("pnpm", ["install", "--lockfile-only", "--ignore-scripts"], { stdio: ["ignore", "inherit", "inherit"], }); - // A run that stopped before opening the PR leaves the branch behind, so - // overwrite it. const title = `chore(deps): Bump ${PACKAGE} to ${latest}`; - run("git", ["checkout", "-B", branch]); + const body = `Pins ${PACKAGE} to [${latest}](https://github.com/getsentry/sentry/releases/tag/api@${latest}), so CI checks this repository against the release. \`bump-sentry-api.yml\` updates this PR when a newer release ships and never merges it.`; + run("git", ["checkout", "-B", BRANCH]); run("git", ["add", WORKSPACE, "pnpm-lock.yaml"]); + run("git", ["commit", "-m", title], { + env: { + ...process.env, + GIT_AUTHOR_NAME: BOT_NAME, + GIT_AUTHOR_EMAIL: BOT_EMAIL, + GIT_COMMITTER_NAME: BOT_NAME, + GIT_COMMITTER_EMAIL: BOT_EMAIL, + }, + }); + // A leftover branch from a closed PR is overwritten too. run("git", [ - "-c", - "user.name=github-actions[bot]", - "-c", - "user.email=41898282+github-actions[bot]@users.noreply.github.com", - "commit", - "-m", - title, - ]); - run("git", ["push", "--force", "--set-upstream", "origin", branch]); - run("gh", [ - "pr", - "create", - "--head", - branch, - "--title", - title, - "--body", - `Pins ${PACKAGE} to [${latest}](https://github.com/getsentry/sentry/releases/tag/api@${latest}), so CI checks this repository against the release.`, + "push", + `--force-with-lease=refs/heads/${BRANCH}:${remote}`, + "origin", + `HEAD:refs/heads/${BRANCH}`, ]); + if (plan === "update") { + run("gh", ["pr", "edit", pr, "--title", title, "--body", body]); + } else { + run("gh", [ + "pr", + "create", + "--head", + BRANCH, + "--title", + title, + "--body", + body, + ]); + } } if ( diff --git a/scripts/bump-sentry-api.test.mjs b/scripts/bump-sentry-api.test.mjs index 83e70e4ee..4ce8ff296 100644 --- a/scripts/bump-sentry-api.test.mjs +++ b/scripts/bump-sentry-api.test.mjs @@ -1,7 +1,7 @@ import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import test from "node:test"; -import { isRelease, pinSentryApi } from "./bump-sentry-api.mjs"; +import { isRelease, pinSentryApi, planBump } from "./bump-sentry-api.mjs"; const workspace = readFileSync( new URL("../pnpm-workspace.yaml", import.meta.url), @@ -33,3 +33,15 @@ test("accepts only stable releases", () => { assert.equal(isRelease("3.0.0-rc.0"), false); assert.equal(isRelease(""), false); }); + +test("keeps one bump PR on the newest release", () => { + const latest = "2.6.0"; + assert.equal(planBump({ latest, main: "2.6.0" }), "none"); + assert.equal(planBump({ latest, main: "2.5.0" }), "open"); + assert.equal(planBump({ latest, main: "2.5.0", branch: "2.6.0" }), "none"); + assert.equal(planBump({ latest, main: "2.5.0", branch: "2.5.3" }), "update"); + assert.equal( + planBump({ latest, main: "2.5.0", branch: "2.5.3", foreignCommits: 1 }), + "keep", + ); +}); From ea60d58f141a1d8c020c2d214b72ed424db00235 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 13:51:16 +0000 Subject: [PATCH 4/4] fix(ci): Don't count merges from main as hand-made bump commits Merging main into the bump branch, such as with GitHub's Update branch, made the bump stop following new releases. The rebuild from main loses nothing such a merge added, so only non-merge commits now count. --- docs/operations/github-actions.md | 5 +++-- scripts/bump-sentry-api.mjs | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/operations/github-actions.md b/docs/operations/github-actions.md index 346f3b4ac..54e6ec7a5 100644 --- a/docs/operations/github-actions.md +++ b/docs/operations/github-actions.md @@ -127,8 +127,9 @@ PR opened with `github.token` does not start other workflows. second one. - The branch belongs to the script. If someone pushes their own commit to it, the script stops updating the PR and logs a warning, so the commit is not - lost. Rebase it onto the new release by hand, or close it and let the next run - open a fresh PR. + lost. Merging main into the branch, such as with "Update branch", doesn't + count. Rebase it onto the new release by hand, or close it and let the next + run open a fresh PR. - The PR is never merged automatically. ## Package CI checks diff --git a/scripts/bump-sentry-api.mjs b/scripts/bump-sentry-api.mjs index f22455860..671e4f3df 100644 --- a/scripts/bump-sentry-api.mjs +++ b/scripts/bump-sentry-api.mjs @@ -120,8 +120,11 @@ function main() { if (pr && remote) { run("git", ["fetch", "--quiet", "origin", BRANCH, "main"]); branch = pinnedVersion(run("git", ["show", `${remote}:${WORKSPACE}`])); + // Merging main into the branch, such as with GitHub's "Update branch", + // adds nothing the rebuild from main would lose, so merges don't count. foreignCommits = run("git", [ "log", + "--no-merges", "--format=%ae", `origin/main..${remote}`, ])