Skip to content

Conversation

@XxdpavelxX
Copy link
Contributor

@XxdpavelxX XxdpavelxX commented Dec 8, 2025


Note

Adds a composite GitHub Action and Bash script to automatically merge all older release/* branches into a newly created release branch, favoring the new branch on conflicts and pushing if merges occur.

  • CI/GitHub Actions:
    • New composite action /.github/actions/merge-previous-releases/action.yml to merge previous release/* branches into a new release branch.
    • Checks out target branch and tools repo, configures git user, and runs merge script with provided inputs.
  • Script:
    • New /.github/scripts/merge-previous-releases.sh:
      • Parses release/X.Y.Z, enumerates older release branches, sorts them, and merges into the new branch.
      • Skips branches already merged; uses -X ours to favor destination on conflicts and resolves remaining conflicts programmatically.
      • Commits merges, excludes github-tools from staging, and pushes only if any merges occurred.

Written by Cursor Bugbot for commit 535b887. This will update automatically on new commits. Configure here.

Testing:
consensys-test/metamask-mobile-test-workflow#59

  1. Multiple branches, one already merged: https://github.com/consensys-test/metamask-mobile-test-workflow/actions/runs/20072233678
  2. Multiple branches, neither merged: https://github.com/consensys-test/metamask-mobile-test-workflow/actions/runs/20073029520
  3. Multiple branches, with merge conflicts: https://github.com/consensys-test/metamask-mobile-test-workflow/actions/runs/20073136324

Signed-off-by: Pavel Dvorkin <pavel.dvorkin@consensys.net>
@XxdpavelxX XxdpavelxX force-pushed the INFRA-3187-AutomateMergingReleaseBranches branch from 29c17fe to ed5be17 Compare December 8, 2025 20:40
@XxdpavelxX XxdpavelxX self-assigned this Dec 9, 2025
Mrtenz
Mrtenz previously requested changes Dec 10, 2025
Comment on lines 33 to 37
- name: Checkout GitHub tools repository
uses: actions/checkout@v5
with:
repository: metamask/github-tools
path: ./github-tools
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will check out the main branch of github-tools, which is prone to breaking. Please change this workflow to an action instead, and use this pattern:

github-tools-repository:
description: 'The GitHub repository containing the GitHub tools. Defaults to the GitHub tools action repositor, and usually does not need to be changed.'
required: false
default: ${{ github.action_repository }}
github-tools-ref:
description: 'The SHA of the action to use. Defaults to the current action ref, and usually does not need to be changed.'
required: false
default: ${{ github.action_ref }}

- name: Checkout GitHub tools repository
if: ${{ steps.label-check.outputs.skip_check != 'true' }}
uses: actions/checkout@v6
with:
repository: ${{ inputs.github-tools-repository }}
ref: ${{ inputs.github-tools-ref }}
path: ./.github-tools

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@XxdpavelxX XxdpavelxX requested a review from Mrtenz December 10, 2025 15:46
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this workflow necessary now? The action can be called from other repositories directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I removed the workflow

token: ${{ secrets.github-token || secrets.GITHUB_TOKEN }}

- name: Merge previous releases
uses: metamask/github-tools/.github/actions/merge-previous-releases@INFRA-3187-AutomateMergingReleaseBranches
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Workflow references feature branch that will be deleted

The workflow references the action using @INFRA-3187-AutomateMergingReleaseBranches, which is a feature branch name. Once this PR is merged, this branch will likely be deleted, causing the workflow to fail when it tries to fetch the action. This aligns with the reviewer comment from @Mrtenz who noted that referencing the main branch is "prone to breaking" and suggested using a proper versioning pattern with github.action_repository and github.action_ref.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was in the workflow and has been removed

@XxdpavelxX XxdpavelxX requested a review from Mrtenz December 10, 2025 16:21
Copy link
Member

@Mrtenz Mrtenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action looks good to me. I don't have context on the script itself, so will let someone else review that!

Comment on lines 40 to 41
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this to be metamaskbot?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, these are just used for commit metadata, but let me update it to metamaskbot like our other workflows. Fixed

if [[ -n "$file" ]]; then
echo " - Conflict in: ${file} → keeping destination version"
git_exec checkout --ours "$file"
git_exec add "$file"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Delete/modify conflicts may cause script failure

When resolving merge conflicts, git checkout --ours "$file" will fail if the file was deleted in the destination branch ("ours") but modified in the source branch. Git reports "error: path does not have our version" and exits with non-zero status. With set -e enabled, this causes the entire script to abort instead of gracefully handling the conflict by keeping the deletion. This affects modify/delete conflicts that aren't resolved by the initial git merge -X ours command.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@XxdpavelxX XxdpavelxX merged commit 0c60787 into main Dec 15, 2025
20 of 21 checks passed
@XxdpavelxX XxdpavelxX deleted the INFRA-3187-AutomateMergingReleaseBranches branch December 15, 2025 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants