-
Notifications
You must be signed in to change notification settings - Fork 201
fix: release script squash-merge compat and backmerge automation #12162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 4 commits
36861b4
9b15248
07ef2a2
33f7c0c
66bb840
c0f8456
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -515,7 +515,9 @@ const doRegularRelease = async () => { | |
| // Two sub-states within idle: | ||
| // 1. Release branch ahead of main (prerelease merged) -> create release -> main PR | ||
| // 2. Release branch matches main (fresh start) -> create develop -> release PR | ||
| const prereleaseMerged = releaseSha !== mainSha | ||
| // Use content diff (not SHA) to handle squash merges where SHAs diverge but content is identical | ||
| const releaseMatchesMain = !(await git().diff(['origin/main', 'origin/release'])) | ||
| const prereleaseMerged = releaseSha !== mainSha && !releaseMatchesMain | ||
|
|
||
| if (prereleaseMerged) { | ||
| const messages = await getCommitMessages(`${latestTag}..origin/release`) | ||
|
|
@@ -610,21 +612,38 @@ const doRegularRelease = async () => { | |
| await git().push(['origin', '--tags']) | ||
| console.log(chalk.green(`Tagged ${nextVersion}.`)) | ||
|
|
||
| console.log(chalk.green('Creating PR to sync private to main...')) | ||
| const privatePrUrl = await createPr({ | ||
| base: 'private', | ||
| head: 'main', | ||
| title: `chore: sync private to ${nextVersion}`, | ||
| body: `Sync private branch to main after release ${nextVersion}.`, | ||
| }) | ||
| console.log(chalk.green(`Private sync PR created: ${privatePrUrl}`)) | ||
| console.log(chalk.green('Merge it on GitHub to complete the release.')) | ||
| const existingPrivatePrAfterTag = await findOpenPr('main', 'private') | ||
| if (existingPrivatePrAfterTag) { | ||
| console.log( | ||
| chalk.yellow( | ||
| `Private sync PR already open: #${existingPrivatePrAfterTag.number}. Merge it on GitHub.`, | ||
| ), | ||
| ) | ||
| } else { | ||
| console.log(chalk.green('Creating PR to sync private to main...')) | ||
| const privatePrUrl = await createPr({ | ||
| base: 'private', | ||
| head: 'main', | ||
| title: `chore: sync private to ${nextVersion}`, | ||
| body: `Sync private branch to main after release ${nextVersion}.`, | ||
| }) | ||
| console.log(chalk.green(`Private sync PR created: ${privatePrUrl}`)) | ||
| console.log(chalk.green('Merge it on GitHub to complete the release.')) | ||
| } | ||
| break | ||
| } | ||
|
|
||
| case 'tagged_private_stale': { | ||
| console.log(chalk.yellow(`${nextVersion} is tagged but private is behind main.`)) | ||
|
|
||
| const privateDiff = await git().diff(['origin/main', 'origin/private']) | ||
| if (!privateDiff) { | ||
| console.log( | ||
| chalk.green('Private is already in sync with main content-wise. Nothing to do.'), | ||
| ) | ||
| break | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const existingPrivatePr = await findOpenPr('main', 'private') | ||
| if (existingPrivatePr) { | ||
| console.log( | ||
|
|
@@ -642,6 +661,26 @@ const doRegularRelease = async () => { | |
| }) | ||
| console.log(chalk.green(`Private sync PR created: ${privatePrUrl}`)) | ||
| } | ||
|
|
||
| const existingBackmerge = await findOpenPr('main', 'develop') | ||
| if (!existingBackmerge) { | ||
| const mainDevelopCommits = await getCommitMessages('origin/develop..origin/main') | ||
| if (mainDevelopCommits.length > 0) { | ||
| console.log(chalk.green('Creating backmerge PR (main -> develop)...')) | ||
| const backmergeUrl = await createPr({ | ||
| base: 'develop', | ||
| head: 'main', | ||
| title: `chore: backmerge ${nextVersion} into develop`, | ||
| body: `Backmerge main into develop after release ${nextVersion}.`, | ||
| }) | ||
| console.log(chalk.green(`Backmerge PR created: ${backmergeUrl}`)) | ||
| console.log(chalk.green('Setting auto-merge with merge commit strategy...')) | ||
| await pify(exec)(`gh pr merge --auto --merge ${backmergeUrl}`) | ||
| console.log( | ||
| chalk.green('Auto-merge set. Backmerge will merge automatically when CI passes.'), | ||
| ) | ||
| } | ||
| } | ||
|
Comment on lines
+671
to
689
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Auto-merge is skipped when backmerge PR already exists. Right now, 🔧 Minimal fix (apply in both regular + hotfix backmerge blocks)- const existingBackmerge = await findOpenPr('main', 'develop')
- if (!existingBackmerge) {
+ const existingBackmerge = await findOpenPr('main', 'develop')
+ if (existingBackmerge) {
+ console.log(chalk.yellow(`Backmerge PR already open: #${existingBackmerge.number}.`))
+ console.log(chalk.green('Setting auto-merge with merge commit strategy...'))
+ await pify(exec)(`gh pr merge --auto --merge ${existingBackmerge.number}`)
+ console.log(
+ chalk.green('Auto-merge set. Backmerge will merge automatically when CI passes.'),
+ )
+ } else {
const mainDevelopCommits = await getCommitMessages('origin/develop..origin/main')
if (mainDevelopCommits.length > 0) {
console.log(chalk.green('Creating backmerge PR (main -> develop)...'))
const backmergeUrl = await createPr({
base: 'develop',
head: 'main',
title: `chore: backmerge ${nextVersion} into develop`,
body: `Backmerge main into develop after release ${nextVersion}.`,
})
console.log(chalk.green(`Backmerge PR created: ${backmergeUrl}`))
console.log(chalk.green('Setting auto-merge with merge commit strategy...'))
await pify(exec)(`gh pr merge --auto --merge ${backmergeUrl}`)
console.log(
chalk.green('Auto-merge set. Backmerge will merge automatically when CI passes.'),
)
}
}Also applies to: 860-877 🤖 Prompt for AI Agents |
||
| break | ||
| } | ||
|
|
||
|
|
@@ -787,6 +826,14 @@ const doHotfixRelease = async () => { | |
| case 'tagged_private_stale': { | ||
| console.log(chalk.yellow(`${nextVersion} is tagged but private is behind main.`)) | ||
|
|
||
| const privateDiffHotfix = await git().diff(['origin/main', 'origin/private']) | ||
| if (!privateDiffHotfix) { | ||
| console.log( | ||
| chalk.green('Private is already in sync with main content-wise. Nothing to do.'), | ||
| ) | ||
| break | ||
| } | ||
|
|
||
| const existingPrivatePr = await findOpenPr('main', 'private') | ||
| if (existingPrivatePr) { | ||
| console.log( | ||
|
|
@@ -817,6 +864,11 @@ const doHotfixRelease = async () => { | |
| body: `Backmerge main into develop after hotfix ${nextVersion}.`, | ||
| }) | ||
| console.log(chalk.green(`Backmerge PR created: ${backmergeUrl}`)) | ||
| console.log(chalk.green('Setting auto-merge with merge commit strategy...')) | ||
| await pify(exec)(`gh pr merge --auto --merge ${backmergeUrl}`) | ||
| console.log( | ||
| chalk.green('Auto-merge set. Backmerge will merge automatically when CI passes.'), | ||
| ) | ||
| } | ||
| } | ||
| break | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.