Skip to content

Commit 3dcd328

Browse files
committed
INFRA-2867-Updated branch variable names to make it clearer
Signed-off-by: Pavel Dvorkin <pavel.dvorkin@consensys.net>
1 parent 6b13ad6 commit 3dcd328

3 files changed

Lines changed: 31 additions & 29 deletions

File tree

.github/scripts/create-platform-release-pr.sh

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88
# 3. A version bump PR for the main branch
99
#
1010
# Usage:
11-
# create-platform-release-pr.sh <platform> <previous_version> <new_version> [new_version_number] [git_user_name] [git_user_email]
11+
# create-platform-release-pr.sh <platform> <previous_version_ref> <new_version> [new_version_number] [git_user_name] [git_user_email]
1212
#
1313
# Parameters:
14-
# platform - 'mobile' or 'extension'
15-
# previous_version - Previous release version tag (e.g., v7.7.0)
16-
# new_version - New semantic version (e.g., 7.8.0)
17-
# new_version_number - Build version for mobile platform (optional, required for mobile)
18-
# git_user_name - Git user name for commits (optional, defaults to 'metamaskbot')
19-
# git_user_email - Git user email for commits (optional, defaults to 'metamaskbot@users.noreply.github.com')
14+
# platform - 'mobile' or 'extension'
15+
# previous_version_ref - Previous release version tag or branch name (e.g., v7.7.0)
16+
# new_version - New semantic version (e.g., 7.8.0)
17+
# new_version_number - Build version for mobile platform (optional, required for mobile)
18+
# git_user_name - Git user name for commits (optional, defaults to 'metamaskbot')
19+
# git_user_email - Git user email for commits (optional, defaults to 'metamaskbot@users.noreply.github.com')
2020

2121
set -e
2222
set -u
2323
set -o pipefail
2424

2525
# Input validation
2626
PLATFORM="${1}"
27-
PREVIOUS_VERSION="${2}"
27+
PREVIOUS_VERSION_REF="${2}"
2828
NEW_VERSION="${3}"
2929
NEW_VERSION_NUMBER="${4:-}"
3030
GIT_USER_NAME="${5:-metamaskbot}"
@@ -292,7 +292,7 @@ create_release_pr() {
292292
create_changelog_pr() {
293293
local platform="$1"
294294
local new_version="$2"
295-
local previous_version="$3"
295+
local previous_version_ref="$3"
296296
local release_branch_name="$4"
297297
local changelog_branch_name="$5"
298298

@@ -307,12 +307,14 @@ create_changelog_pr() {
307307
echo "Current Directory: $(pwd)"
308308
PROJECT_GIT_DIR=$(pwd)
309309

310-
# Resolve previous_version when it's a branch name: fetch and use origin/<branch>
311-
DIFF_BASE="${previous_version}"
312-
if git ls-remote --heads origin "${previous_version}" | grep -qE "\srefs/heads/${previous_version}$"; then
313-
echo "Detected remote branch for previous version: ${previous_version}"
314-
git fetch origin "${previous_version}"
315-
DIFF_BASE="origin/${previous_version}"
310+
# 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.
311+
DIFF_BASE="${previous_version_ref}"
312+
if git ls-remote --heads origin "${previous_version_ref}" | grep -qE "\srefs/heads/${previous_version_ref}$"; then
313+
echo "Detected remote branch for previous version: ${previous_version_ref}"
314+
git fetch origin "${previous_version_ref}"
315+
DIFF_BASE="origin/${previous_version_ref}"
316+
else
317+
echo "No remote branch detected for previous version: ${previous_version_ref}"
316318
fi
317319

318320
# Switch to github-tools directory
@@ -445,7 +447,7 @@ main() {
445447
if [ "$TEST_ONLY" == "true" ]; then
446448
echo "Skipping changelog generation in test mode"
447449
else
448-
create_changelog_pr "$PLATFORM" "$NEW_VERSION" "$PREVIOUS_VERSION" "$release_branch_name" "$changelog_branch_name"
450+
create_changelog_pr "$PLATFORM" "$NEW_VERSION" "$PREVIOUS_VERSION_REF" "$release_branch_name" "$changelog_branch_name"
449451
fi
450452

451453
# Step 3: Create version bump PR for main branch

.github/scripts/generate-rc-commits.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async function getTeam(repository, prNumber) {
5959
}
6060

6161
// Function to filter commits based on unique commit messages and group by teams
62-
async function filterCommitsByTeam(platform, branchA, branchB) {
62+
async function filterCommitsByTeam(platform, refA, refB) {
6363

6464
const MAX_COMMITS = 500; // Limit the number of commits to process
6565
console.log('Filtering commits by team...');
@@ -81,8 +81,8 @@ async function filterCommitsByTeam(platform, branchA, branchB) {
8181
const git = simpleGit();
8282

8383
const logOptions = {
84-
from: branchB,
85-
to: branchA,
84+
from: refB,
85+
to: refA,
8686
format: {
8787
hash: '%H',
8888
author: '%an',
@@ -92,7 +92,7 @@ async function filterCommitsByTeam(platform, branchA, branchB) {
9292

9393
const log = await git.log(logOptions);
9494

95-
console.log(`Total commits between ${branchA} and ${branchB}: ${log.total}`);
95+
console.log(`Total commits between ${refA} and ${refB}: ${log.total}`);
9696
console.log(`Processing up to ${Math.min(log.all.length, MAX_COMMITS)} commits...`);
9797

9898
const commitsByTeam = {};
@@ -204,26 +204,26 @@ async function main() {
204204

205205
if (args.length !== 4) {
206206
console.error(
207-
'Usage: node generate-rc-commits.mjs platform branchA branchB',
207+
'Usage: node generate-rc-commits.mjs platform refA refB',
208208
);
209209
console.error('Received:', args, ' with length:', args.length);
210210
process.exit(1);
211211
}
212212

213213
const platform = args[0];
214-
const branchA = args[1];
215-
const branchB = args[2];
214+
const refA = args[1];
215+
const refB = args[2];
216216
const gitDir = args[3];
217217

218218
// Change the working directory to the git repository path
219219
// Since this is invoked by a shared workflow, the working directory is not guaranteed to be the repository root
220220
process.chdir(gitDir);
221221

222222
console.log(
223-
`Generating CSV file for commits between ${branchA} and ${branchB} on ${platform} platform...`,
223+
`Generating CSV file for commits between ${refA} and ${refB} on ${platform} platform...`,
224224
);
225225

226-
const commitsByTeam = await filterCommitsByTeam(platform, branchA, branchB);
226+
const commitsByTeam = await filterCommitsByTeam(platform, refA, refB);
227227

228228
if (Object.keys(commitsByTeam).length === 0) {
229229
console.log('No commits found.');

.github/workflows/create-release-pr.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ on:
1919
required: false
2020
type: string
2121
description: 'The build version for the mobile platform.'
22-
previous-version-tag:
22+
previous-version-ref:
2323
required: true
2424
type: string
25-
description: 'Previous release version tag. eg: v7.7.0'
25+
description: 'Previous release version tag or branch name. eg: v7.7.0'
2626
# Flag to indicate if the release is a test release for development purposes only
2727
mobile-template-sheet-id:
2828
required: false
@@ -108,7 +108,7 @@ jobs:
108108
echo "Checkout Base Branch: ${{ inputs.checkout-base-branch }}"
109109
echo "Release PR Base Branch: ${{ inputs.release-pr-base-branch }}"
110110
echo "Semver Version: ${{ inputs.semver-version }}"
111-
echo "Previous Version Tag: ${{ inputs.previous-version-tag }}"
111+
echo "Previous Version Reference: ${{ inputs.previous-version-ref }}"
112112
echo "Test Only Mode: ${{ inputs.test-only }}"
113113
if [[ "${{ inputs.platform }}" == "mobile" ]]; then
114114
echo "Mobile Build Version: ${{ inputs.mobile-build-version }}"
@@ -140,7 +140,7 @@ jobs:
140140
# Execute the script from github-tools
141141
./github-tools/.github/scripts/create-platform-release-pr.sh \
142142
${{ inputs.platform }} \
143-
${{ inputs.previous-version-tag }} \
143+
${{ inputs.previous-version-ref }} \
144144
${{ inputs.semver-version }} \
145145
${{ inputs.mobile-build-version }} \
146146
${{ inputs.git-user-name }} \

0 commit comments

Comments
 (0)