From 5ecff75c854ff5322be1738efcbce33cf6ca6033 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Fri, 5 Sep 2025 15:16:47 -0400 Subject: [PATCH 01/14] INFRA-2911-Skip generating commits.dvs for hotfixes --- .github/scripts/create-platform-release-pr.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index a646999b..5fc6ba49 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -46,6 +46,11 @@ if [[ -z $NEW_VERSION_NUMBER && $PLATFORM == "mobile" ]]; then exit 1 fi +if [[ -z $PREVIOUS_VERSION_REF ]]; then + echo "Error: No previous version reference specified." + exit 1 +fi + From 3ae9840205f2e66ca4cd96466e539238a0bc845d Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Fri, 5 Sep 2025 15:32:49 -0400 Subject: [PATCH 02/14] INFRA-2911-Skip generating commits.dvs for hotfixes --- .github/scripts/create-platform-release-pr.sh | 89 ++++++++++--------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 5fc6ba49..94e55ab3 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -46,10 +46,6 @@ if [[ -z $NEW_VERSION_NUMBER && $PLATFORM == "mobile" ]]; then exit 1 fi -if [[ -z $PREVIOUS_VERSION_REF ]]; then - echo "Error: No previous version reference specified." - exit 1 -fi @@ -317,43 +313,50 @@ create_changelog_pr() { echo "Generating changelog via auto-changelog.." npx @metamask/auto-changelog@4.1.0 update --rc --repo "${GITHUB_REPOSITORY_URL}" --currentVersion "${new_version}" --autoCategorize - # Need to run from .github-tools context to inherit it's dependencies/environment - echo "Current Directory: $(pwd)" - PROJECT_GIT_DIR=$(pwd) - - # 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/`). - # 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}" - - # 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}" + # Skip commits.csv for hotfix releases (previous_version_ref empty) + local skip_csv=false + if [[ -z "${previous_version_ref}" ]]; then + echo "Hotfix release detected (previous-version-ref empty); skipping commits.csv generation." + skip_csv=true + else + # Need to run from .github-tools context to inherit it's dependencies/environment + echo "Current Directory: $(pwd)" + PROJECT_GIT_DIR=$(pwd) + + # 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/`). + # 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}" + + # 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 "Remote branch not found on origin: ${previous_version_ref}. Will use as-is." + echo "Previous version is not a recognized release branch pattern. Treating as tag or SHA: ${previous_version_ref}" fi - else - echo "Previous version is not a recognized release branch pattern. Treating as tag or SHA: ${previous_version_ref}" - fi - # Switch to github-tools directory - cd ./github-tools/ - ls -ltra - corepack prepare yarn@4.5.1 --activate - # This can't be done from the actions context layer due to the upstream repository having it's own context set with yarn - yarn --cwd install + # Switch to github-tools directory + cd ./github-tools/ + ls -ltra + corepack prepare yarn@4.5.1 --activate + # This can't be done from the actions context layer due to the upstream repository having it's own context set with yarn + yarn --cwd install + + echo "Generating test plan csv.." + yarn run gen:commits "${platform}" "${DIFF_BASE}" "${release_branch_name}" "${PROJECT_GIT_DIR}" + fi - echo "Generating test plan csv.." - yarn run gen:commits "${platform}" "${DIFF_BASE}" "${release_branch_name}" "${PROJECT_GIT_DIR}" - # Skipping Google Sheets update since there is no need for it anymore # TODO: Remove this once the current post-main validation approach is stable # if [[ "${TEST_ONLY:-false}" == 'false' ]]; then @@ -365,12 +368,18 @@ create_changelog_pr() { # Commit and Push Changelog Changes (exclude commits.csv) echo "Adding and committing changes.." - if ! (git commit -am "update changelog for ${new_version}"); then - echo "Error: No changes detected." - exit 1 + local commit_msg="update changelog for ${new_version}" + if $skip_csv; then + commit_msg="${commit_msg} (hotfix - no test plan)" + fi + if ! (git commit -am "${commit_msg}"); then + echo "No changes detected; skipping commit." fi local pr_body="This PR updates the change log for ${new_version}." + if $skip_csv; then + pr_body="${pr_body} (Hotfix - no test plan generated.)" + fi # Use helper functions for push and PR creation push_branch_with_handling "${changelog_branch_name}" From a7527bc44a4c1a28df7b04132e8c4f61f06374a5 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Fri, 5 Sep 2025 15:33:53 -0400 Subject: [PATCH 03/14] INFRA-2911-Skip generating commits.cvs for hotfixes --- .github/scripts/create-platform-release-pr.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 94e55ab3..de1d7047 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -49,7 +49,6 @@ fi - # Helper Functions # --------------- From 24214ba58e77c1a2eef70e9f39429c876b898868 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Fri, 5 Sep 2025 15:51:51 -0400 Subject: [PATCH 04/14] INFRA-2911-Skip generating commits.cvs for hotfixes --- .github/scripts/create-platform-release-pr.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index de1d7047..c0840cc6 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -46,7 +46,10 @@ if [[ -z $NEW_VERSION_NUMBER && $PLATFORM == "mobile" ]]; then exit 1 fi - +if [[ -z $PREVIOUS_VERSION_REF ]]; then + echo "Error: No previous version reference specified." + exit 1 +fi # Helper Functions From 66e16bf17be07570cf0b7611d46db8e4f02cf4e6 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Fri, 5 Sep 2025 16:03:57 -0400 Subject: [PATCH 05/14] INFRA-2911-Skip generating commits.cvs for hotfixes --- .github/scripts/create-platform-release-pr.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index c0840cc6..37d159d6 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -22,9 +22,18 @@ set -e set -u set -o pipefail +# Log all positional arguments for debugging +echo "Script called with arguments:" +echo "1 (PLATFORM): $1" +echo "2 (PREVIOUS_VERSION_REF): $2" +echo "3 (NEW_VERSION): $3" +echo "4 (NEW_VERSION_NUMBER): $4" +echo "5 (GIT_USER_NAME): $5" +echo "6 (GIT_USER_EMAIL): $6" + # Input validation PLATFORM="${1}" -PREVIOUS_VERSION_REF="${2}" +PREVIOUS_VERSION_REF="${2//[[:space:]]/}" # Trim whitespace NEW_VERSION="${3}" NEW_VERSION_NUMBER="${4:-}" GIT_USER_NAME="${5:-metamaskbot}" From 8d9c1ed6bf9cb9b9ceeb5ca1461fdd8b3383ba83 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Fri, 5 Sep 2025 16:17:01 -0400 Subject: [PATCH 06/14] INFRA-2911-Skip generating commits.cvs for hotfixes --- .github/scripts/create-platform-release-pr.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 37d159d6..287bb4c4 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -39,6 +39,18 @@ NEW_VERSION_NUMBER="${4:-}" GIT_USER_NAME="${5:-metamaskbot}" GIT_USER_EMAIL="${6:-metamaskbot@users.noreply.github.com}" +# Move logging here +echo "Assigned variables:" +echo "PLATFORM: $PLATFORM" +echo "PREVIOUS_VERSION_REF: $PREVIOUS_VERSION_REF" +echo "NEW_VERSION: $NEW_VERSION" +echo "NEW_VERSION_NUMBER: $NEW_VERSION_NUMBER" +echo "GIT_USER_NAME: $GIT_USER_NAME" +echo "GIT_USER_EMAIL: $GIT_USER_EMAIL" + +# Add trimming for NEW_VERSION +NEW_VERSION="${NEW_VERSION//[[:space:]]/}" + # Validate required parameters if [[ -z $PLATFORM ]]; then echo "Error: No platform specified." From dabffc04db49cfc9daff62a566641e22a7728368 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Fri, 5 Sep 2025 16:20:29 -0400 Subject: [PATCH 07/14] INFRA-2911-Skip generating commits.cvs for hotfixes --- .github/scripts/create-platform-release-pr.sh | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 287bb4c4..a7e22373 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -22,24 +22,15 @@ set -e set -u set -o pipefail -# Log all positional arguments for debugging -echo "Script called with arguments:" -echo "1 (PLATFORM): $1" -echo "2 (PREVIOUS_VERSION_REF): $2" -echo "3 (NEW_VERSION): $3" -echo "4 (NEW_VERSION_NUMBER): $4" -echo "5 (GIT_USER_NAME): $5" -echo "6 (GIT_USER_EMAIL): $6" - # Input validation PLATFORM="${1}" PREVIOUS_VERSION_REF="${2//[[:space:]]/}" # Trim whitespace -NEW_VERSION="${3}" +NEW_VERSION="${3//[[:space:]]/}" # Trim whitespace NEW_VERSION_NUMBER="${4:-}" GIT_USER_NAME="${5:-metamaskbot}" GIT_USER_EMAIL="${6:-metamaskbot@users.noreply.github.com}" -# Move logging here +# Log assigned variables for debugging (after defaults and trimming) echo "Assigned variables:" echo "PLATFORM: $PLATFORM" echo "PREVIOUS_VERSION_REF: $PREVIOUS_VERSION_REF" @@ -48,9 +39,6 @@ echo "NEW_VERSION_NUMBER: $NEW_VERSION_NUMBER" echo "GIT_USER_NAME: $GIT_USER_NAME" echo "GIT_USER_EMAIL: $GIT_USER_EMAIL" -# Add trimming for NEW_VERSION -NEW_VERSION="${NEW_VERSION//[[:space:]]/}" - # Validate required parameters if [[ -z $PLATFORM ]]; then echo "Error: No platform specified." @@ -68,8 +56,8 @@ if [[ -z $NEW_VERSION_NUMBER && $PLATFORM == "mobile" ]]; then fi if [[ -z $PREVIOUS_VERSION_REF ]]; then - echo "Error: No previous version reference specified." - exit 1 + echo "Error: No previous version reference specified." + exit 1 fi From 3f1587e4fc84503f3b78f995388feb4330403c23 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Fri, 5 Sep 2025 16:26:44 -0400 Subject: [PATCH 08/14] INFRA-2911-Skip generating commits.cvs for hotfixes --- .github/scripts/create-platform-release-pr.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index a7e22373..a4a5c3e3 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -22,10 +22,10 @@ set -e set -u set -o pipefail -# Input validation -PLATFORM="${1}" -PREVIOUS_VERSION_REF="${2//[[:space:]]/}" # Trim whitespace -NEW_VERSION="${3//[[:space:]]/}" # Trim whitespace +# Input assignments with defaults to handle shifting/empty args +PLATFORM="${1:-}" +PREVIOUS_VERSION_REF="${2//[[:space:]]/:-}" # Trim whitespace, default empty for hotfixes +NEW_VERSION="${3//[[:space:]]/:-}" # Trim whitespace, default empty NEW_VERSION_NUMBER="${4:-}" GIT_USER_NAME="${5:-metamaskbot}" GIT_USER_EMAIL="${6:-metamaskbot@users.noreply.github.com}" @@ -39,7 +39,7 @@ echo "NEW_VERSION_NUMBER: $NEW_VERSION_NUMBER" echo "GIT_USER_NAME: $GIT_USER_NAME" echo "GIT_USER_EMAIL: $GIT_USER_EMAIL" -# Validate required parameters +# Validate required parameters (allow empty PREVIOUS_VERSION_REF for hotfixes) if [[ -z $PLATFORM ]]; then echo "Error: No platform specified." exit 1 @@ -55,10 +55,7 @@ if [[ -z $NEW_VERSION_NUMBER && $PLATFORM == "mobile" ]]; then exit 1 fi -if [[ -z $PREVIOUS_VERSION_REF ]]; then - echo "Error: No previous version reference specified." - exit 1 -fi +# Note: Skip PREVIOUS_VERSION_REF validation to allow empty for hotfixes # Helper Functions From bbbb67e4013f5cd7219f3c315b385b67311d17d1 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Fri, 5 Sep 2025 16:45:25 -0400 Subject: [PATCH 09/14] INFRA-2911-Skip generating commits.cvs for hotfixes --- .github/workflows/create-release-pr.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index a4240416..03dcfe05 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -139,12 +139,12 @@ jobs: run: | # Execute the script from github-tools ./github-tools/.github/scripts/create-platform-release-pr.sh \ - ${{ inputs.platform }} \ - ${{ inputs.previous-version-ref }} \ - ${{ inputs.semver-version }} \ - ${{ inputs.mobile-build-version }} \ - ${{ inputs.git-user-name }} \ - ${{ inputs.git-user-email }} + "${{ inputs.platform }}" \ + "${{ inputs.previous-version-ref }}" \ + "${{ inputs.semver-version }}" \ + "${{ inputs.mobile-build-version }}" \ + "${{ inputs.git-user-name }}" \ + "${{ inputs.git-user-email }}" # Step 6: Upload commits.csv as artifact (if generated) - name: Upload commits.csv artifact From 5e15345796c7cbb0005cec8a1e5bc79f43218cbe Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Fri, 5 Sep 2025 16:51:00 -0400 Subject: [PATCH 10/14] INFRA-2911-Skip generating commits.cvs for hotfixes --- .github/scripts/create-platform-release-pr.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index a4a5c3e3..cd558f12 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -22,10 +22,13 @@ set -e set -u set -o pipefail -# Input assignments with defaults to handle shifting/empty args -PLATFORM="${1:-}" -PREVIOUS_VERSION_REF="${2//[[:space:]]/:-}" # Trim whitespace, default empty for hotfixes -NEW_VERSION="${3//[[:space:]]/:-}" # Trim whitespace, default empty +# Input assignments (quoted args prevent shifting). Use defaults only for optional args. +PLATFORM="${1}" +PREVIOUS_VERSION_REF="${2:-}" +# Trim whitespace-only values to truly empty for hotfix handling +PREVIOUS_VERSION_REF="${PREVIOUS_VERSION_REF//[[:space:]]/}" +NEW_VERSION="${3}" +NEW_VERSION="${NEW_VERSION//[[:space:]]/}" NEW_VERSION_NUMBER="${4:-}" GIT_USER_NAME="${5:-metamaskbot}" GIT_USER_EMAIL="${6:-metamaskbot@users.noreply.github.com}" From a9d33d51c636119d83b7f090a243dcc611d3d606 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Fri, 5 Sep 2025 16:56:56 -0400 Subject: [PATCH 11/14] INFRA-2911-Skip generating commits.cvs for hotfixes --- .github/scripts/create-platform-release-pr.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index cd558f12..f6e6ba33 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -366,6 +366,8 @@ create_changelog_pr() { echo "Generating test plan csv.." yarn run gen:commits "${platform}" "${DIFF_BASE}" "${release_branch_name}" "${PROJECT_GIT_DIR}" + # Return to project root after generating commits.csv + cd ../ fi # Skipping Google Sheets update since there is no need for it anymore @@ -375,7 +377,7 @@ create_changelog_pr() { # # Create a new Release Sheet Page for the new version with our commits.csv content # yarn run update-release-sheet "${platform}" "${new_version}" "${GOOGLE_DOCUMENT_ID}" "./commits.csv" "${PROJECT_GIT_DIR}" "${MOBILE_TEMPLATE_SHEET_ID}" "${EXTENSION_TEMPLATE_SHEET_ID}" # fi - cd ../ + # Note: Only change directories when we actually entered ./github-tools/ # Commit and Push Changelog Changes (exclude commits.csv) echo "Adding and committing changes.." From 90a5adfe4ad1c166148ca42e0f6bc28b6d9b54d3 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Fri, 5 Sep 2025 17:04:33 -0400 Subject: [PATCH 12/14] INFRA-2911-Skip generating commits.cvs for hotfixes --- .github/scripts/create-platform-release-pr.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index f6e6ba33..7b5270b2 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -440,6 +440,18 @@ Platform: ${platform}" echo "Version bump committed" fi + # Ensure base branch exists locally; fetch from origin if missing + if ! git rev-parse --verify --quiet "refs/heads/${main_branch}" >/dev/null; then + echo "Base branch ${main_branch} not found locally. Attempting to fetch from origin..." + if git ls-remote --heads origin "${main_branch}" | grep -q "."; then + git fetch origin "${main_branch}:${main_branch}" || git fetch origin "${main_branch}" + echo "Fetched base branch ${main_branch} from origin." + else + echo "Error: Base branch not found on origin: ${main_branch}" + exit 1 + fi + fi + # If the version bump branch has no commits ahead of main, skip pushing/PR creation # Validate refs before computing ahead count to avoid masking errors # Fail fast with a error message if the base branch doesn’t exist locally (or isn’t fetched) @@ -519,7 +531,7 @@ main() { fi # Step 3: Create version bump PR for main branch - create_version_bump_pr "$PLATFORM" "$NEW_VERSION" "$next_version" "$version_bump_branch_name" "$release_branch_name" "main" + create_version_bump_pr "$PLATFORM" "$NEW_VERSION" "$next_version" "$version_bump_branch_name" "$release_branch_name" "$BASE_BRANCH" # Final summary echo "" From bb2b66d93f2a7c8d3665fdd2497dea1e0a3a7cd9 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Mon, 8 Sep 2025 10:38:14 -0400 Subject: [PATCH 13/14] INFRA-2911-Skip generating commits.cvs for hotfixes Signed-off-by: Pavel Dvorkin --- .github/scripts/create-platform-release-pr.sh | 21 ++++++++----------- .github/workflows/create-release-pr.yml | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 7b5270b2..fabbc224 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -25,7 +25,7 @@ set -o pipefail # Input assignments (quoted args prevent shifting). Use defaults only for optional args. PLATFORM="${1}" PREVIOUS_VERSION_REF="${2:-}" -# Trim whitespace-only values to truly empty for hotfix handling +# Normalize whitespace-only values; hotfixes are indicated by the literal string 'null' PREVIOUS_VERSION_REF="${PREVIOUS_VERSION_REF//[[:space:]]/}" NEW_VERSION="${3}" NEW_VERSION="${NEW_VERSION//[[:space:]]/}" @@ -58,9 +58,6 @@ if [[ -z $NEW_VERSION_NUMBER && $PLATFORM == "mobile" ]]; then exit 1 fi -# Note: Skip PREVIOUS_VERSION_REF validation to allow empty for hotfixes - - # Helper Functions # --------------- @@ -324,11 +321,11 @@ create_changelog_pr() { echo "Generating changelog via auto-changelog.." npx @metamask/auto-changelog@4.1.0 update --rc --repo "${GITHUB_REPOSITORY_URL}" --currentVersion "${new_version}" --autoCategorize - # Skip commits.csv for hotfix releases (previous_version_ref empty) - local skip_csv=false - if [[ -z "${previous_version_ref}" ]]; then - echo "Hotfix release detected (previous-version-ref empty); skipping commits.csv generation." - skip_csv=true + # Skip commits.csv for hotfix releases (previous_version_ref is literal "null") + # - When we create a new major/minor releases, we fetch all commits included in the release, by fetching the diff between HEAD and previous version reference. + # - When we create a new hotfix releases, there are no commits included in the release by default (they will be cherry-picked one by one). So we don't have previous version reference, which is why the value is set to 'null'. + if [[ "${previous_version_ref,,}" == "null" ]]; then + echo "Hotfix release detected (previous-version-ref is 'null'); skipping commits.csv generation." else # Need to run from .github-tools context to inherit it's dependencies/environment echo "Current Directory: $(pwd)" @@ -382,7 +379,7 @@ create_changelog_pr() { # Commit and Push Changelog Changes (exclude commits.csv) echo "Adding and committing changes.." local commit_msg="update changelog for ${new_version}" - if $skip_csv; then + if [[ "${previous_version_ref,,}" == "null" ]]; then commit_msg="${commit_msg} (hotfix - no test plan)" fi if ! (git commit -am "${commit_msg}"); then @@ -390,7 +387,7 @@ create_changelog_pr() { fi local pr_body="This PR updates the change log for ${new_version}." - if $skip_csv; then + if [[ "${previous_version_ref,,}" == "null" ]]; then pr_body="${pr_body} (Hotfix - no test plan generated.)" fi @@ -531,7 +528,7 @@ main() { fi # Step 3: Create version bump PR for main branch - create_version_bump_pr "$PLATFORM" "$NEW_VERSION" "$next_version" "$version_bump_branch_name" "$release_branch_name" "$BASE_BRANCH" + create_version_bump_pr "$PLATFORM" "$NEW_VERSION" "$next_version" "$version_bump_branch_name" "$release_branch_name" "main" # Final summary echo "" diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index 03dcfe05..2abb99b2 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -22,7 +22,7 @@ on: previous-version-ref: required: true type: string - description: 'Previous release version branch name, tag or commit hash (e.g., release/7.7.0, v7.7.0, or 76fbc500034db9779e9ff7ce637ac5be1da0493d)' + description: 'Previous release version branch name, tag or commit hash (e.g., release/7.7.0, v7.7.0, or 76fbc500034db9779e9ff7ce637ac5be1da0493d). For hotfix releases, pass the literal string "null".' # Flag to indicate if the release is a test release for development purposes only mobile-template-sheet-id: required: false From 863e289d998a8a200375636bc37ff13713047e37 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Mon, 8 Sep 2025 15:09:19 -0400 Subject: [PATCH 14/14] INFRA-2911-Skip generating commits.cvs for hotfixes --- .github/scripts/create-platform-release-pr.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index fabbc224..426ff59e 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -322,8 +322,8 @@ create_changelog_pr() { npx @metamask/auto-changelog@4.1.0 update --rc --repo "${GITHUB_REPOSITORY_URL}" --currentVersion "${new_version}" --autoCategorize # Skip commits.csv for hotfix releases (previous_version_ref is literal "null") - # - When we create a new major/minor releases, we fetch all commits included in the release, by fetching the diff between HEAD and previous version reference. - # - When we create a new hotfix releases, there are no commits included in the release by default (they will be cherry-picked one by one). So we don't have previous version reference, which is why the value is set to 'null'. + # - When we create a new major/minor release, we fetch all commits included in the release, by fetching the diff between HEAD and previous version reference. + # - When we create a new hotfix release, there are no commits included in the release by default (they will be cherry-picked one by one). So we don't have previous version reference, which is why the value is set to 'null'. if [[ "${previous_version_ref,,}" == "null" ]]; then echo "Hotfix release detected (previous-version-ref is 'null'); skipping commits.csv generation." else