Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
INFRA-2867: Updated comments set previous branch regex
Signed-off-by: Pavel Dvorkin <[email protected]>
  • Loading branch information
XxdpavelxX committed Aug 26, 2025
commit d036fbf427c56d487ef9ec7d1a4e0185bca85cdf
27 changes: 20 additions & 7 deletions .github/scripts/create-platform-release-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
# Parameters:
# platform - 'mobile' or 'extension'
# previous_version_ref - Previous release version tag or branch name (e.g., v7.7.0)
# previous_version_ref - Previous release version branch name, tag or commit hash (e.g., release/7.7.0, v7.7.0, or 76fbc500034db9779e9ff7ce637ac5be1da0493d)
# new_version - New semantic version (e.g., 7.8.0)
# new_version_number - Build version for mobile platform (optional, required for mobile)
# git_user_name - Git user name for commits (optional, defaults to 'metamaskbot')
Expand Down Expand Up @@ -307,14 +307,27 @@ create_changelog_pr() {
echo "Current Directory: $(pwd)"
PROJECT_GIT_DIR=$(pwd)

# Resolve previous_version_ref when it's a branch name: fetch and use origin/<branch>. This enables branch names to be used as previous version references.
# By default, DIFF_BASE is set to the provided `previous_version_ref` (which can be a branch name, tag, or commit hash).
# If `previous_version_ref` matches a remote branch on origin, we fetch it and update DIFF_BASE to the fully qualified remote ref (`origin/<branch>`).
# This is required for the `generate-rc-commits.mjs` script to resolve the branch and successfully run the `git log` command.
# Otherwise, DIFF_BASE remains unchanged.
DIFF_BASE="${previous_version_ref}"
if git ls-remote --heads origin "${previous_version_ref}" | grep -qE "\srefs/heads/${previous_version_ref}$"; then
echo "Detected remote branch for previous version: ${previous_version_ref}"
git fetch origin "${previous_version_ref}"
DIFF_BASE="origin/${previous_version_ref}"

# Only consider known release branch patterns to avoid regex pitfalls:
# - Extension: Version-vx.y.z
# - Mobile: release/x.y.z
if [[ "${previous_version_ref}" =~ ^Version-v[0-9]+\.[0-9]+\.[0-9]+$ || "${previous_version_ref}" =~ ^release/[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Previous version looks like a release branch: ${previous_version_ref}"
# Check if the exact branch exists on origin without interpolating into a regex
if git ls-remote --heads origin "${previous_version_ref}" | grep -q "."; then
echo "Detected remote branch for previous version: ${previous_version_ref}"
git fetch origin "${previous_version_ref}"
DIFF_BASE="origin/${previous_version_ref}"
else
echo "Remote branch not found on origin: ${previous_version_ref}. Will use as-is."
fi
else
echo "No remote branch detected for previous version: ${previous_version_ref}"
echo "Previous version is not a recognized release branch pattern. Treating as tag or SHA: ${previous_version_ref}"
fi

# Switch to github-tools directory
Expand Down
1 change: 1 addition & 0 deletions .github/scripts/generate-rc-commits.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ async function getTeam(repository, prNumber) {
}

// Function to filter commits based on unique commit messages and group by teams
// Input parameters refA and refB can be a branch name, a tag or a commit hash (e.g., release/7.7.0, v7.7.0, or 76fbc500034db9779e9ff7ce637ac5be1da0493d)
async function filterCommitsByTeam(platform, refA, refB) {

const MAX_COMMITS = 500; // Limit the number of commits to process
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ on:
previous-version-ref:
required: true
type: string
description: 'Previous release version tag or branch name. eg: v7.7.0'
description: 'Previous release version branch name, tag or commit hash (e.g., release/7.7.0, v7.7.0, or 76fbc500034db9779e9ff7ce637ac5be1da0493d)'
# Flag to indicate if the release is a test release for development purposes only
mobile-template-sheet-id:
required: false
Expand Down
Loading