From f63561dce4353e87348a891d36e11e82abafe042 Mon Sep 17 00:00:00 2001 From: shishu314 Date: Thu, 2 Oct 2025 16:21:37 -0400 Subject: [PATCH] Update patch PRs with additional content (#10180) Co-authored-by: Shi Shu --- scripts/releasing/create-patch-pr.js | 7 ++-- scripts/releasing/patch-trigger.js | 58 ++++++++++++++++++---------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/scripts/releasing/create-patch-pr.js b/scripts/releasing/create-patch-pr.js index 8e61c77593..e614f7b316 100644 --- a/scripts/releasing/create-patch-pr.js +++ b/scripts/releasing/create-patch-pr.js @@ -50,9 +50,10 @@ async function main() { const releaseInfo = getLatestReleaseInfo(channel); const latestTag = releaseInfo.currentTag; + const nextVersion = releaseInfo.nextVersion; const releaseBranch = `release/${latestTag}-pr-${pullRequestNumber}`; - const hotfixBranch = `hotfix/${latestTag}/${channel}/cherry-pick-${commit.substring(0, 7)}`; + const hotfixBranch = `hotfix/${latestTag}/${nextVersion}/${channel}/cherry-pick-${commit.substring(0, 7)}`; // Create the release branch from the tag if it doesn't exist. if (!branchExists(releaseBranch)) { @@ -190,8 +191,8 @@ async function main() { console.log( `Creating pull request from ${hotfixBranch} to ${releaseBranch}...`, ); - let prTitle = `fix(patch): cherry-pick ${commit.substring(0, 7)} to ${releaseBranch}`; - let prBody = `This PR automatically cherry-picks commit ${commit} to patch the ${channel} release.`; + let prTitle = `fix(patch): cherry-pick ${commit.substring(0, 7)} to ${releaseBranch} to patch version ${releaseInfo.currentTag} and create version ${releaseInfo.nextVersion}`; + let prBody = `This PR automatically cherry-picks commit ${commit} to patch version ${releaseInfo.currentTag} in the ${channel} release to create version ${releaseInfo.nextVersion}.`; if (hasConflicts) { prTitle = `fix(patch): cherry-pick ${commit.substring(0, 7)} to ${releaseBranch} [CONFLICTS]`; diff --git a/scripts/releasing/patch-trigger.js b/scripts/releasing/patch-trigger.js index 178c737702..d7fcb013f5 100644 --- a/scripts/releasing/patch-trigger.js +++ b/scripts/releasing/patch-trigger.js @@ -14,6 +14,42 @@ import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; +/** + * Extract base version and channel info from hotfix branch name. Branches can + * be in multiple formats: + * - New NEW: hotfix/v0.5.3/v0.5.4/preview/cherry-pick-abc -> v0.5.4 and preview + * - New format: hotfix/v0.5.3/preview/cherry-pick-abc -> v0.5.3 and preview + * - Old format: hotfix/v0.5.3/cherry-pick-abc -> v0.5.3 and stable (default) + * We check the formats from newest to oldest. If the channel found is invalid, + * an error is thrown. + */ +function getBranchInfo({ branchName, context }) { + const parts = branchName.split('/'); + const version = parts[1]; + let channel = 'stable'; // default for old format + if (parts.length >= 5 && (parts[3] === 'stable' || parts[3] === 'preview')) { + channel = parts[3]; + } else if ( + parts.length >= 4 && + (parts[2] === 'stable' || parts[2] === 'preview') + ) { + // New format with explicit channel + channel = parts[2]; + } else if (context.eventName === 'workflow_dispatch') { + // Manual dispatch, infer from version name + channel = version.includes('preview') ? 'preview' : 'stable'; + } + + // Validate channel + if (channel !== 'stable' && channel !== 'preview') { + throw new Error( + `Invalid channel: ${channel}. Must be 'stable' or 'preview'.`, + ); + } + + return { channel, version }; +} + async function main() { const argv = await yargs(hideBin(process.argv)) .option('head-ref', { @@ -79,27 +115,7 @@ async function main() { console.log(`Processing patch trigger for branch: ${headRef}`); - // Extract base version and channel from hotfix branch name - // New format: hotfix/v0.5.3/preview/cherry-pick-abc -> v0.5.3 and preview - // Old format: hotfix/v0.5.3/cherry-pick-abc -> v0.5.3 and stable (default) - const parts = headRef.split('/'); - const version = parts[1]; - let channel = 'stable'; // default for old format - - if (parts.length >= 4 && (parts[2] === 'stable' || parts[2] === 'preview')) { - // New format with explicit channel - channel = parts[2]; - } else if (context.eventName === 'workflow_dispatch') { - // Manual dispatch, infer from version name - channel = version.includes('preview') ? 'preview' : 'stable'; - } - - // Validate channel - if (channel !== 'stable' && channel !== 'preview') { - throw new Error( - `Invalid channel: ${channel}. Must be 'stable' or 'preview'.`, - ); - } + const { version, channel } = getBranchInfo({ branchName: headRef, context }); // Try to find the original PR that requested this patch let originalPr = null;