You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
INFRA-2867-Fix workflow inputs to allow branch name (#108)
* INFRA-2867-Fix workflow inputs to allow branch name
Signed-off-by: Pavel Dvorkin <pavel.dvorkin@consensys.net>
* INFRA-2867-Updated branch variable names to make it clearer
Signed-off-by: Pavel Dvorkin <pavel.dvorkin@consensys.net>
* INFRA-2867: Updated comments set previous branch regex
Signed-off-by: Pavel Dvorkin <pavel.dvorkin@consensys.net>
---------
Signed-off-by: Pavel Dvorkin <pavel.dvorkin@consensys.net>
#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 branch name, tag or commit hash (e.g., release/7.7.0, v7.7.0, or 76fbc500034db9779e9ff7ce637ac5be1da0493d)
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')
20
20
21
21
set -e
22
22
set -u
23
23
set -o pipefail
24
24
25
25
# Input validation
26
26
PLATFORM="${1}"
27
-
PREVIOUS_VERSION="${2}"
27
+
PREVIOUS_VERSION_REF="${2}"
28
28
NEW_VERSION="${3}"
29
29
NEW_VERSION_NUMBER="${4:-}"
30
30
GIT_USER_NAME="${5:-metamaskbot}"
@@ -292,7 +292,7 @@ create_release_pr() {
292
292
create_changelog_pr() {
293
293
local platform="$1"
294
294
local new_version="$2"
295
-
localprevious_version="$3"
295
+
localprevious_version_ref="$3"
296
296
local release_branch_name="$4"
297
297
local changelog_branch_name="$5"
298
298
@@ -306,15 +306,40 @@ create_changelog_pr() {
306
306
# Need to run from .github-tools context to inherit it's dependencies/environment
307
307
echo"Current Directory: $(pwd)"
308
308
PROJECT_GIT_DIR=$(pwd)
309
+
310
+
# By default, DIFF_BASE is set to the provided `previous_version_ref` (which can be a branch name, tag, or commit hash).
311
+
# 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>`).
312
+
# This is required for the `generate-rc-commits.mjs` script to resolve the branch and successfully run the `git log` command.
313
+
# Otherwise, DIFF_BASE remains unchanged.
314
+
DIFF_BASE="${previous_version_ref}"
315
+
316
+
# Only consider known release branch patterns to avoid regex pitfalls:
317
+
# - Extension: Version-vx.y.z
318
+
# - Mobile: release/x.y.z
319
+
if [[ "${previous_version_ref}"=~ ^Version-v[0-9]+\.[0-9]+\.[0-9]+$ ||"${previous_version_ref}"=~ ^release/[0-9]+\.[0-9]+\.[0-9]+$ ]];then
320
+
echo"Previous version looks like a release branch: ${previous_version_ref}"
321
+
# Check if the exact branch exists on origin without interpolating into a regex
322
+
if git ls-remote --heads origin "${previous_version_ref}"| grep -q ".";then
323
+
echo"Detected remote branch for previous version: ${previous_version_ref}"
324
+
git fetch origin "${previous_version_ref}"
325
+
DIFF_BASE="origin/${previous_version_ref}"
326
+
else
327
+
echo"Remote branch not found on origin: ${previous_version_ref}. Will use as-is."
328
+
fi
329
+
else
330
+
echo"Previous version is not a recognized release branch pattern. Treating as tag or SHA: ${previous_version_ref}"
331
+
fi
332
+
333
+
# Switch to github-tools directory
309
334
cd ./github-tools/
310
335
ls -ltra
311
336
corepack prepare yarn@4.5.1 --activate
312
337
# This can't be done from the actions context layer due to the upstream repository having it's own context set with yarn
313
338
yarn --cwd install
314
339
315
340
echo"Generating test plan csv.."
316
-
yarn run gen:commits "${platform}""${previous_version}""${release_branch_name}""${PROJECT_GIT_DIR}"
317
-
341
+
yarn run gen:commits "${platform}""${DIFF_BASE}""${release_branch_name}""${PROJECT_GIT_DIR}"
342
+
318
343
# Skipping Google Sheets update since there is no need for it anymore
319
344
# TODO: Remove this once the current post-main validation approach is stable
// 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)
0 commit comments