From 8f7f26770c73091f192bec0523ab83dcc2579ccf Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Thu, 5 Jun 2025 16:31:13 +0200 Subject: [PATCH 01/14] feat(gh-action): align version management mobile and extension These changes are for unifying the release process between extension and mobile, including made the same release version branch, which is different at the moment. It will create `"release/${new_version}"` branches as a pattern. --- .github/scripts/create-platform-release-pr.sh | 92 ++++++++++++------- .github/scripts/set-semvar-version.sh | 62 ++++++++----- 2 files changed, 98 insertions(+), 56 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 8d47e749..45288b57 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -1,14 +1,22 @@ #!/usr/bin/env bash +# Script to create platform release PRs for MetaMask +# This script handles the creation of release PRs for both mobile and extension platforms +# It creates two PRs: +# 1. A release PR with version updates +# 2. A changelog PR with updated changelog and test plan + set -e set -u set -o pipefail +# Input validation PLATFORM="${1}" PREVIOUS_VERSION="${2}" NEW_VERSION="${3}" NEW_VERSION_NUMBER="${4:-}" +# Validate required parameters if [[ -z $PLATFORM ]]; then echo "Error: No platform specified." exit 1 @@ -24,8 +32,14 @@ if [[ -z $NEW_VERSION_NUMBER && $PLATFORM == "mobile" ]]; then exit 1 fi -get_expected_changed_files() { + + +# Helper Functions +# --------------- + +# Returns a space-separated list of files that are expected to change for a given platform +get_expected_changed_files() { local platform="$1" local expected_changed_files="" @@ -41,37 +55,37 @@ get_expected_changed_files() { echo "$expected_changed_files" } -# Returns the release branch name to use for the given platform +# Returns the release branch name based on platform and version +# For all platforms: release/{version} +# If TEST_ONLY=true: release-testing/{version} get_release_branch_name() { - # Input arguments - local platform="$1" # Platform can be 'mobile' or 'extension' - local new_version="$2" # Semantic version, e.g., '12.9.2' + local platform="$1" + local new_version="$2" - # Check if TEST_ONLY environment variable is set to "true" - # This is to run a development version of the release process without impacting downstream automation - if [ "$TEST_ONLY" == "true" ]; then - echo "release-testing/${new_version}" - return 0 + # Validate platform + if [[ "$platform" != "mobile" && "$platform" != "extension" ]]; then + echo "Error: Unknown platform '$platform'. Must be 'mobile' or 'extension'." + exit 1 fi - # Determine the release branch name based on platform - if [ "$platform" == "mobile" ]; then - RELEASE_BRANCH_NAME="release/${new_version}" - echo "${RELEASE_BRANCH_NAME}" - elif [ "$platform" == "extension" ]; then - RELEASE_BRANCH_NAME="Version-v${new_version}" - echo "${RELEASE_BRANCH_NAME}" - else - echo "Error: Unknown platform '$platform'. Must be 'mobile' or 'extension'." - exit 1 + # Use test branch if TEST_ONLY is true + if [ "$TEST_ONLY" == "true" ]; then + echo "release-testing/${new_version}" + return 0 fi -} + # Use consistent release branch naming for all platforms + echo "release/${new_version}" +} +# Main Script +# ---------- +# Initialize branch names RELEASE_BRANCH_NAME=$(get_release_branch_name $PLATFORM $NEW_VERSION) CHANGELOG_BRANCH_NAME="chore/${NEW_VERSION}-Changelog" +# Prepare release PR body with team sign-off checklist RELEASE_BODY="This is the release candidate for version ${NEW_VERSION}. The changelog will be found in another PR ${CHANGELOG_BRANCH_NAME}. # Team sign-off checklist @@ -91,6 +105,8 @@ RELEASE_BODY="This is the release candidate for version ${NEW_VERSION}. The chan # Reference - Testing plan sheet - https://docs.google.com/spreadsheets/d/1tsoodlAlyvEUpkkcNcbZ4PM9HuC9cEM80RZeoVv5OCQ/edit?gid=404070372#gid=404070372" +# Git Configuration +# ---------------- echo "Configuring git.." git config user.name metamaskbot git config user.email metamaskbot@users.noreply.github.com @@ -98,7 +114,8 @@ git config user.email metamaskbot@users.noreply.github.com echo "Fetching from remote..." git fetch -# Check out the existing release branch from the remote +# Release Branch Setup +# ------------------- echo "Checking out the release branch: ${RELEASE_BRANCH_NAME}" git checkout "${RELEASE_BRANCH_NAME}" @@ -107,18 +124,15 @@ echo "Release Branch Checked Out" echo "version : ${NEW_VERSION}" echo "platform : ${PLATFORM}" +# Version Updates +# -------------- echo "Running version update scripts.." -# Bump versions for the release ./github-tools/.github/scripts/set-semvar-version.sh "${NEW_VERSION}" ${PLATFORM} -if [[ "$PLATFORM" == "mobile" ]]; then - ./github-tools/.github/scripts/set-mobile-build-version.sh "${NEW_VERSION_NUMBER}" -fi - +# Commit Changes +# ------------- changed_files=$(get_expected_changed_files "$PLATFORM") - -# Echo the files to be added echo "Files to be staged for commit: $changed_files" echo "Adding and committing changes.." @@ -126,19 +140,19 @@ echo "Adding and committing changes.." # Track our changes git add $changed_files -# Generate a commit based on PLATFORM +# Generate commit message based on platform if [ "$PLATFORM" = "mobile" ]; then git commit -m "bump semvar version to ${NEW_VERSION} && build version to ${NEW_VERSION_NUMBER}" elif [ "$PLATFORM" = "extension" ]; then git commit -m "bump semvar version to ${NEW_VERSION}" fi - +# Push Changes and Create Release PR +# --------------------------------- echo "Pushing changes to the remote.." git push --set-upstream origin "${RELEASE_BRANCH_NAME}" -echo Creating release PR.. - +echo "Creating release PR.." gh pr create \ --draft \ --title "feat: ${NEW_VERSION}" \ @@ -147,12 +161,15 @@ gh pr create \ echo "Release PR Created" +# Changelog Branch Setup +# --------------------- echo "Checking out ${CHANGELOG_BRANCH_NAME}" git checkout -b "${CHANGELOG_BRANCH_NAME}" echo "Changelog Branch Created" +# Generate Changelog and Test Plan +# ------------------------------ 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 @@ -163,6 +180,7 @@ 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}" "${PREVIOUS_VERSION}" "${RELEASE_BRANCH_NAME}" "${PROJECT_GIT_DIR}" @@ -171,6 +189,8 @@ echo "Updating release sheet.." yarn run update-release-sheet "${PLATFORM}" "${NEW_VERSION}" "${GOOGLE_DOCUMENT_ID}" "./commits.csv" "${PROJECT_GIT_DIR}" "${MOBILE_TEMPLATE_SHEET_ID}" "${EXTENSION_TEMPLATE_SHEET_ID}" cd ../ +# Commit and Push Changelog Changes +# ------------------------------- echo "Adding and committing changes.." git add ./commits.csv @@ -186,7 +206,9 @@ PR_BODY="This PR updates the change log for ${NEW_VERSION} and generates the tes echo "Pushing changes to the remote.." git push --set-upstream origin "${CHANGELOG_BRANCH_NAME}" -echo Creating release PR.. +# Create Changelog PR +# ----------------- +echo "Creating changelog PR.." gh pr create \ --draft \ --title "chore: ${CHANGELOG_BRANCH_NAME}" \ diff --git a/.github/scripts/set-semvar-version.sh b/.github/scripts/set-semvar-version.sh index 5b6e0b06..45d91d8c 100755 --- a/.github/scripts/set-semvar-version.sh +++ b/.github/scripts/set-semvar-version.sh @@ -1,81 +1,97 @@ #!/usr/bin/env bash +# Script to update semantic versioning across MetaMask platform files +# This script handles version updates for both mobile and extension platforms +# For mobile: Updates package.json, Android build.gradle, Bitrise config, and iOS project files +# For extension: Updates package.json only + set -e set -u set -o pipefail -# Check if exactly 2 arguments are provided +# Input validation if [[ $# -ne 2 ]]; then - echo "Usage: $0 " + echo "Usage: $0 " exit 1 fi +# Script parameters SEMVER_VERSION=$1 PLATFORM=$2 -NAT='0|[1-9][0-9]*' -ALPHANUM='[0-9]*[A-Za-z-][0-9A-Za-z-]*' -IDENT="$NAT|$ALPHANUM" -FIELD='[0-9A-Za-z-]+' +# Regular expression patterns for semantic version validation +NAT='0|[1-9][0-9]*' # Non-negative integer +ALPHANUM='[0-9]*[A-Za-z-][0-9A-Za-z-]*' # Alphanumeric identifier +IDENT="$NAT|$ALPHANUM" # Identifier (number or alphanumeric) +FIELD='[0-9A-Za-z-]+' # Field (alphanumeric with hyphens) +# Full semantic version regex pattern +# Matches: v1.2.3-alpha.1+build.123 SEMVER_REGEX="\ ^[vV]?\ ($NAT)\\.($NAT)\\.($NAT)\ (\\-(${IDENT})(\\.(${IDENT}))*)?\ (\\+${FIELD}(\\.${FIELD})*)?$" +# File paths for version updates PACKAGE_JSON_FILE=package.json ANDROID_BUILD_GRADLE_FILE=android/app/build.gradle BITRISE_YML_FILE=bitrise.yml IOS_PROJECT_FILE=ios/MetaMask.xcodeproj/project.pbxproj +# Helper Functions +# --------------- + +# Converts semantic version to numeric format (e.g., 1.2.3 -> 123) semver_to_nat () { echo "${1//./}" } +# Logs error message and exits with status code 1 log_and_exit () { echo "$1" && exit 1 } +# Updates version in package.json using jq package_json() { - - # update package.json + # Create temporary file for jq operation tmp="${PACKAGE_JSON_FILE}_temp" jq ".version = \"$SEMVER_VERSION\"" $PACKAGE_JSON_FILE > "$tmp" mv "$tmp" $PACKAGE_JSON_FILE echo "- $PACKAGE_JSON_FILE updated" - } +# Updates version in mobile-specific files +# Handles both macOS and Linux environments update_mobile_files () { - # Check operating system and execute platform-specific sed commands if [[ "$OSTYPE" == "darwin"* ]]; then - # macOS - - # update android/app/build.gradle + # macOS specific updates + + # Update Android version in build.gradle echo "Updating Android build.gradle file..." sed -i '' 's/\(\s*versionName \)".*"/\1"'"$SEMVER_VERSION"'"/' "$ANDROID_BUILD_GRADLE_FILE" echo "- $ANDROID_BUILD_GRADLE_FILE successfully updated" - # update bitrise.yml + # Update version in Bitrise configuration echo "Updating Bitrise configuration files..." sed -i '' 's/\(\s*VERSION_NAME: \).*/\1'"$SEMVER_VERSION"'/' "$BITRISE_YML_FILE" echo "- $BITRISE_YML_FILE successfully updated" + # Update iOS marketing version echo "Updating iOS project settings..." sed -i '' 's/\(\s*MARKETING_VERSION = \).*/\1'"$SEMVER_VERSION;"'/' "$IOS_PROJECT_FILE" echo "- $IOS_PROJECT_FILE successfully updated" else - # Linux - - # update android/app/build.gradle + # Linux specific updates + + # Update Android version in build.gradle echo "Updating Android build.gradle file..." sed -i 's/\(\s*versionName \)".*"/\1"'"$SEMVER_VERSION"'"/' "$ANDROID_BUILD_GRADLE_FILE" echo "- $ANDROID_BUILD_GRADLE_FILE updated" - # update bitrise.yml + # Update version in Bitrise configuration echo "Updating Bitrise configuration files..." sed -i 's/\(\s*VERSION_NAME: \).*/\1'"$SEMVER_VERSION"'/' "$BITRISE_YML_FILE" echo "- $BITRISE_YML_FILE updated" @@ -84,9 +100,9 @@ update_mobile_files () { echo "Updating iOS project settings..." sed -i 's/\(\s*MARKETING_VERSION = \).*/\1'"$SEMVER_VERSION;"'/' "$IOS_PROJECT_FILE" echo "- $IOS_PROJECT_FILE updated" - fi + # Print summary of updates echo "- $ANDROID_BUILD_GRADLE_FILE updated" echo "- $BITRISE_YML_FILE updated" echo "- $IOS_PROJECT_FILE updated" @@ -96,12 +112,15 @@ update_mobile_files () { echo "SEMVER version: $SEMVER_VERSION" } -# abort if values are empty +# Main Script +# ---------- + +# Validate input parameters if [[ -z $SEMVER_VERSION ]]; then log_and_exit "SEMVER_VERSION not specified, aborting!" fi -# check if SEMVER_VERSION is not valid semver +# Validate semantic version format if ! [[ $SEMVER_VERSION =~ $SEMVER_REGEX ]]; then log_and_exit "$SEMVER_VERSION is invalid semver!" fi @@ -114,6 +133,7 @@ echo "Updating files:" # Update the version in the package.json file package_json +# Platform-specific updates if [[ $PLATFORM == "mobile" ]]; then update_mobile_files fi From f5f37f688d90dde1a40446ec07299334fccd3370 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 6 Jun 2025 13:44:24 +0200 Subject: [PATCH 02/14] chore: add conditional for updating the spreadsheet For testing, we don't wanna execute the spreadsheet step, just create the commits csv file. --- .github/scripts/create-platform-release-pr.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 45288b57..7634ad05 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -184,9 +184,11 @@ yarn --cwd install echo "Generating test plan csv.." yarn run gen:commits "${PLATFORM}" "${PREVIOUS_VERSION}" "${RELEASE_BRANCH_NAME}" "${PROJECT_GIT_DIR}" -echo "Updating release sheet.." -# 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}" +if [[ "${TEST_ONLY:-true}" != "true" ]]; then + echo "Updating release sheet.." + # 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 ../ # Commit and Push Changelog Changes From dc463ebd88c072298797e29b01ad61571b37d835 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 6 Jun 2025 13:58:23 +0200 Subject: [PATCH 03/14] chore: set ref code to call --- .github/workflows/create-release-pr.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index 0a3dcba5..61657a80 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -55,6 +55,7 @@ on: jobs: create-release-pr: + name: Create Release Pull Request runs-on: ubuntu-latest permissions: contents: write @@ -73,7 +74,8 @@ jobs: uses: actions/checkout@v4 with: repository: MetaMask/github-tools - ref: main + #ref: main + ref: ale/unify-create-release-mobile-extension path: github-tools # Step 3: Setup environment from github-tools From 23b56a13fa355740842f67ee799b672f670eb45e Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Mon, 9 Jun 2025 13:51:57 +0200 Subject: [PATCH 04/14] chore: conditional to skip update GC document --- .github/scripts/create-platform-release-pr.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 7634ad05..49cf39d1 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -184,7 +184,7 @@ yarn --cwd install echo "Generating test plan csv.." yarn run gen:commits "${PLATFORM}" "${PREVIOUS_VERSION}" "${RELEASE_BRANCH_NAME}" "${PROJECT_GIT_DIR}" -if [[ "${TEST_ONLY:-true}" != "true" ]]; then +if [[ "${TEST_ONLY:-false}" == 'true' ]]; then echo "Updating release sheet.." # 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}" From 49194dc7c56b25b954a15948f61939b3c8b6b794 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Mon, 9 Jun 2025 14:01:33 +0200 Subject: [PATCH 05/14] chore: improve conditionals To allow to re-run the workflow, in case there aren't changes to push to remote --- .github/scripts/create-platform-release-pr.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 49cf39d1..9f164ab0 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -142,15 +142,28 @@ git add $changed_files # Generate commit message based on platform if [ "$PLATFORM" = "mobile" ]; then - git commit -m "bump semvar version to ${NEW_VERSION} && build version to ${NEW_VERSION_NUMBER}" + if ! git commit -m "bump semvar version to ${NEW_VERSION} && build version to ${NEW_VERSION_NUMBER}"; then + echo "No changes to commit for mobile version bump" + fi elif [ "$PLATFORM" = "extension" ]; then - git commit -m "bump semvar version to ${NEW_VERSION}" + if ! git commit -m "bump semvar version to ${NEW_VERSION}"; then + echo "No changes to commit for extension version bump" + fi fi # Push Changes and Create Release PR # --------------------------------- echo "Pushing changes to the remote.." -git push --set-upstream origin "${RELEASE_BRANCH_NAME}" +if ! git push --set-upstream origin "${RELEASE_BRANCH_NAME}"; then + echo "No changes to push to ${RELEASE_BRANCH_NAME}" + # Check if branch exists remotely + if git ls-remote --heads origin "${RELEASE_BRANCH_NAME}" | grep -q "${RELEASE_BRANCH_NAME}"; then + echo "Branch ${RELEASE_BRANCH_NAME} already exists remotely" + else + echo "Error: Failed to push and branch doesn't exist remotely" + exit 1 + fi +fi echo "Creating release PR.." gh pr create \ From b4acdbce61971961861a419329a89d6a2c339355 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Mon, 9 Jun 2025 14:17:49 +0200 Subject: [PATCH 06/14] chore: check if pr already exists --- .github/scripts/create-platform-release-pr.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 9f164ab0..110cd7ee 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -166,13 +166,17 @@ if ! git push --set-upstream origin "${RELEASE_BRANCH_NAME}"; then fi echo "Creating release PR.." -gh pr create \ - --draft \ - --title "feat: ${NEW_VERSION}" \ - --body "${RELEASE_BODY}" \ - --head "${RELEASE_BRANCH_NAME}"; - -echo "Release PR Created" +# Check if PR already exists +if gh pr list --search "head:${RELEASE_BRANCH_NAME}" --json number --jq 'length' | grep -q "1"; then + echo "PR for branch ${RELEASE_BRANCH_NAME} already exists" +else + gh pr create \ + --draft \ + --title "feat: ${NEW_VERSION}" \ + --body "${RELEASE_BODY}" \ + --head "${RELEASE_BRANCH_NAME}" + echo "Release PR Created" +fi # Changelog Branch Setup # --------------------- From d305fcb229bf10556ece784383521d104bf21d2d Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Tue, 10 Jun 2025 11:38:53 +0200 Subject: [PATCH 07/14] chore: improve inputs --- .github/scripts/create-platform-release-pr.sh | 2 +- .github/workflows/create-release-pr.yml | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 110cd7ee..3bc36bd5 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -201,7 +201,7 @@ yarn --cwd install echo "Generating test plan csv.." yarn run gen:commits "${PLATFORM}" "${PREVIOUS_VERSION}" "${RELEASE_BRANCH_NAME}" "${PROJECT_GIT_DIR}" -if [[ "${TEST_ONLY:-false}" == 'true' ]]; then +if [[ "${TEST_ONLY:-false}" == 'false' ]]; then echo "Updating release sheet.." # 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}" diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index 61657a80..4ddd1742 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -45,6 +45,11 @@ on: required: true type: string description: 'The platform for which the release PR is being created.' + github-tools-version: + required: true + type: string + description: 'The version of github-tools to use. Defaults to main.' + default: 'main' secrets: github-token: required: true @@ -75,7 +80,8 @@ jobs: with: repository: MetaMask/github-tools #ref: main - ref: ale/unify-create-release-mobile-extension + # ref: ale/unify-create-release-mobile-extension + ref: ${{ inputs.github-tools-version }} path: github-tools # Step 3: Setup environment from github-tools From ab3ddeea0f3cd0ff02adf2e448f0952ab72f2786 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Tue, 10 Jun 2025 16:09:38 +0200 Subject: [PATCH 08/14] chore: restore step removed for test --- .github/scripts/create-platform-release-pr.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 3bc36bd5..94af4eca 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -129,6 +129,9 @@ echo "platform : ${PLATFORM}" echo "Running version update scripts.." ./github-tools/.github/scripts/set-semvar-version.sh "${NEW_VERSION}" ${PLATFORM} +if [[ "$PLATFORM" == "mobile" ]]; then + ./github-tools/.github/scripts/set-mobile-build-version.sh "${NEW_VERSION_NUMBER}" +fi # Commit Changes # ------------- From ad5741e12450ff37571ca2c5fb82eced1920eb1c Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Tue, 10 Jun 2025 16:54:22 +0200 Subject: [PATCH 09/14] chore: remove repeated steps, and improve script This will tackle the same things for mobile and extensions, adding the conditionals to execute mobile specific steps --- .github/scripts/create-platform-release-pr.sh | 3 --- .github/scripts/set-semvar-version.sh | 13 +++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 94af4eca..3bc36bd5 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -129,9 +129,6 @@ echo "platform : ${PLATFORM}" echo "Running version update scripts.." ./github-tools/.github/scripts/set-semvar-version.sh "${NEW_VERSION}" ${PLATFORM} -if [[ "$PLATFORM" == "mobile" ]]; then - ./github-tools/.github/scripts/set-mobile-build-version.sh "${NEW_VERSION_NUMBER}" -fi # Commit Changes # ------------- diff --git a/.github/scripts/set-semvar-version.sh b/.github/scripts/set-semvar-version.sh index 45d91d8c..8cea5a0e 100755 --- a/.github/scripts/set-semvar-version.sh +++ b/.github/scripts/set-semvar-version.sh @@ -125,6 +125,19 @@ if ! [[ $SEMVER_VERSION =~ $SEMVER_REGEX ]]; then log_and_exit "$SEMVER_VERSION is invalid semver!" fi +# Validate inputs for mobile platform +if [[ $PLATFORM == "mobile" ]]; then + # Get current version numbers from bitrise.yml + CURRENT_VERSION_NUMBER=$(awk '/^\s+VERSION_NUMBER: /{print $2}' $BITRISE_YML_FILE); + CURRENT_FLASK_VERSION_NUMBER=$(awk '/^\s+FLASK_VERSION_NUMBER: /{print $2}' $BITRISE_YML_FILE); + + # Ensure version number of main variant and flask are aligned + if [[ "$CURRENT_VERSION_NUMBER" != "$CURRENT_FLASK_VERSION_NUMBER" ]]; then + echo "VERSION_NUMBER $CURRENT_VERSION_NUMBER and FLASK_VERSION_NUMBER $CURRENT_FLASK_VERSION_NUMBER should be the same" + log_and_exit "Check why they are different and fix it before proceeding" + fi +fi + echo "SEMVER_VERSION is valid." echo -e "-------------------" echo "Updating files:" From 5cad6a8d32f32b48d3fd06f03df2174db4815850 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Tue, 10 Jun 2025 17:13:08 +0200 Subject: [PATCH 10/14] chore: control changelog branch already exists on remote --- .github/scripts/create-platform-release-pr.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 3bc36bd5..c842da5f 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -180,9 +180,18 @@ fi # Changelog Branch Setup # --------------------- -echo "Checking out ${CHANGELOG_BRANCH_NAME}" -git checkout -b "${CHANGELOG_BRANCH_NAME}" -echo "Changelog Branch Created" +echo "Checking for existing changelog branch ${CHANGELOG_BRANCH_NAME}" + +# Check if branch exists locally or remotely +if git show-ref --verify --quiet refs/heads/"${CHANGELOG_BRANCH_NAME}" || git ls-remote --heads origin "${CHANGELOG_BRANCH_NAME}" | grep -q "${CHANGELOG_BRANCH_NAME}"; then + echo "Branch ${CHANGELOG_BRANCH_NAME} already exists, checking it out" + git fetch origin "${CHANGELOG_BRANCH_NAME}" + git checkout "${CHANGELOG_BRANCH_NAME}" +else + echo "Creating new branch ${CHANGELOG_BRANCH_NAME}" + git checkout -b "${CHANGELOG_BRANCH_NAME}" +fi +echo "Changelog Branch Ready" # Generate Changelog and Test Plan # ------------------------------ From 7b70c42f10987e9fc76ea9c158f74cff6c035976 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Tue, 10 Jun 2025 18:12:36 +0200 Subject: [PATCH 11/14] chore: more checks --- .github/scripts/create-platform-release-pr.sh | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index c842da5f..97cf344b 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -237,11 +237,17 @@ git push --set-upstream origin "${CHANGELOG_BRANCH_NAME}" # Create Changelog PR # ----------------- echo "Creating changelog PR.." -gh pr create \ - --draft \ - --title "chore: ${CHANGELOG_BRANCH_NAME}" \ - --body "${PR_BODY}" \ - --base "${RELEASE_BRANCH_NAME}" \ - --head "${CHANGELOG_BRANCH_NAME}"; - -echo "Changelog PR Created" +# Check if PR already exists +if gh pr list --search "head:${CHANGELOG_BRANCH_NAME}" --json number --jq 'length' | grep -q "1"; then + echo "Changelog PR for branch ${CHANGELOG_BRANCH_NAME} already exists" +else + gh pr create \ + --draft \ + --title "chore: ${CHANGELOG_BRANCH_NAME}" \ + --body "${PR_BODY}" \ + --base "${RELEASE_BRANCH_NAME}" \ + --head "${CHANGELOG_BRANCH_NAME}" + echo "Changelog PR Created" +fi + +echo "Changelog PR Ready" From 0ce556929121950b6e8bc45dc644cbe768968aaf Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Wed, 11 Jun 2025 10:53:09 +0200 Subject: [PATCH 12/14] chore(inputs): print inputs values --- .github/workflows/create-release-pr.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index 4ddd1742..2fc8309c 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -90,8 +90,27 @@ jobs: with: is-high-risk-environment: true - # Step 4: Execute the script with access to both repositories - - name: Create Release + # Step 4: Print Input Values + - name: Print Input Values + run: | + echo "Input Values:" + echo "-------------" + echo "Platform: ${{ inputs.platform }}" + echo "Base Branch: ${{ inputs.base-branch }}" + echo "Semver Version: ${{ inputs.semver-version }}" + echo "Previous Version Tag: ${{ inputs.previous-version-tag }}" + echo "Test Only Mode: ${{ inputs.test-only }}" + if [[ "${{ inputs.platform }}" == "mobile" ]]; then + echo "Mobile Build Version: ${{ inputs.mobile-build-version }}" + fi + echo "Mobile Template Sheet ID: ${{ inputs.mobile-template-sheet-id }}" + echo "Extension Template Sheet ID: ${{ inputs.extension-template-sheet-id }}" + echo "Release Sheet Google Document ID: ${{ inputs.release-sheet-google-document-id }}" + echo "GitHub Tools Version: ${{ inputs.github-tools-version }}" + echo "-------------" + + # Step 5: Create Release PR + - name: Create Release PR id: create-release-pr shell: bash env: From 0ca933389c599947dfe67e3f3b423d4aadd67872 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Wed, 11 Jun 2025 11:14:08 +0200 Subject: [PATCH 13/14] chore: fix linter and remove unused commented lines --- .github/workflows/create-release-pr.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index 2fc8309c..fec86dcd 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -46,7 +46,6 @@ on: type: string description: 'The platform for which the release PR is being created.' github-tools-version: - required: true type: string description: 'The version of github-tools to use. Defaults to main.' default: 'main' @@ -79,8 +78,6 @@ jobs: uses: actions/checkout@v4 with: repository: MetaMask/github-tools - #ref: main - # ref: ale/unify-create-release-mobile-extension ref: ${{ inputs.github-tools-version }} path: github-tools From cd93a6f6697f7171b5cff3e7fbf62a124337898c Mon Sep 17 00:00:00 2001 From: Ale Som <560018+alucardzom@users.noreply.github.com> Date: Wed, 11 Jun 2025 11:55:17 +0200 Subject: [PATCH 14/14] chore: update .github/scripts/create-platform-release-pr.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/scripts/create-platform-release-pr.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 97cf344b..dc218254 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -167,7 +167,7 @@ fi echo "Creating release PR.." # Check if PR already exists -if gh pr list --search "head:${RELEASE_BRANCH_NAME}" --json number --jq 'length' | grep -q "1"; then +if gh pr list --head "${RELEASE_BRANCH_NAME}" --json number --jq 'length' | grep -q "1"; then echo "PR for branch ${RELEASE_BRANCH_NAME} already exists" else gh pr create \