From d04e7cfd625fc524ceeee789782698409c7baa68 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Tue, 13 May 2025 14:30:33 +0200 Subject: [PATCH 01/29] feat(gh-action): create workflow for automatize stable-main creation This PR is intended to add as functionality a workflow call that will: - Create a `stable-main-{release}` branch - Run the script that will ensure the branch will from a known good state and will take specific files from the stable branch - Create a PR against `main` --- .github/scripts/stable-sync.js | 125 ++++++++++++++++++++++++++++++ .github/workflows/stable-sync.yml | 100 ++++++++++++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 .github/scripts/stable-sync.js create mode 100644 .github/workflows/stable-sync.yml diff --git a/.github/scripts/stable-sync.js b/.github/scripts/stable-sync.js new file mode 100644 index 00000000..4844cfd2 --- /dev/null +++ b/.github/scripts/stable-sync.js @@ -0,0 +1,125 @@ +#!/usr/bin/env node + +// USAGE: +// This will create/update a local stable-sync branch +// and get it in the state needed for a stable-sync PR +// Once the script successfully completes, you just +// need to push the branch to the remote repo. This will +// likely require a `git push --force` +// +// Usage: node stable-sync.js [branch-name] +// If no branch name is provided, defaults to 'stable-sync' + +const { promisify } = require('util'); +const exec = promisify(require('child_process').exec); + +async function runGitCommands() { + // Get branch name from command line arguments or use default + const branchName = process.argv[2] || 'stable-main'; + + try { + try { + // Check if the branch already exists + const { stdout: branchExists } = await exec( + `git rev-parse --quiet --verify ${branchName}`, + ); + if (branchExists.trim()) { + // Branch exists, so simply check it out + await exec(`git checkout ${branchName}`); + console.log(`Checked out branch: ${branchName}`); + } else { + throw new Error( + 'git rev-parse --quiet --verify failed. Branch hash empty', + ); + } + } catch (error) { + if (error.stdout === '') { + console.warn( + `Branch does not exist, creating new ${branchName} branch.`, + ); + + // Branch does not exist, create and check it out + await exec(`git checkout -b ${branchName}`); + console.log(`Created and checked out branch: ${branchName}`); + } else { + console.error(`Error: ${error.message}`); + process.exit(1); + } + } + + await exec('git fetch'); + console.log('Executed: git fetch'); + + await exec('git reset --hard origin/stable'); + console.log('Executed: git reset --hard origin/stable'); + + try { + await exec('git merge origin/main'); + console.log('Executed: git merge origin/main'); + } catch (error) { + // Handle the error but continue script execution + if ( + error.stdout.includes( + 'Automatic merge failed; fix conflicts and then commit the result.', + ) + ) { + console.warn( + 'Merge conflict encountered. Continuing script execution.', + ); + } else { + console.error(`Error: ${error.message}`); + process.exit(1); + } + } + + await exec('git add .'); + await exec('git restore --source origin/main .'); + console.log('Executed: it restore --source origin/main .'); + + await exec('git checkout origin/main -- .'); + console.log('Executed: git checkout origin/main -- .'); + + await exec('git checkout origin/stable -- CHANGELOG.md'); + console.log('Executed: git checkout origin/stable -- CHANGELOG.md'); + + // Mobile Only + await exec('git checkout origin/stable -- bitrise.yml'); + console.log('Executed: git checkout origin/stable -- bitrise.yml'); + + // Mobile Only + await exec('git checkout origin/stable -- android/app/build.gradle'); + console.log('Executed: git checkout origin/stable -- android/app/build.gradle'); + + // Mobile Only + await exec('git checkout origin/stable -- ios/MetaMask.xcodeproj/project.pbxproj'); + console.log('Executed: git checkout origin/stable -- ios/MetaMask.xcodeproj/project.pbxproj'); + + // Mobile Only + await exec('git checkout origin/stable -- package.json'); + console.log('Executed: git checkout origin/stable -- package.json'); + + // Extension Only + // const { stdout: packageJsonContent } = await exec( + // 'git show origin/master:package.json', + // ); + // const packageJson = JSON.parse(packageJsonContent); + // const packageVersion = packageJson.version; + + // await exec(`yarn version "${packageVersion}"`); + // console.log('Executed: yarn version'); + + await exec('git add .'); + console.log('Executed: git add .'); + + await exec(`git commit -m "Merge origin/main into ${branchName}" --no-verify`); + console.log('Executed: git commit'); + + console.log(`Your local ${branchName} branch is now ready to become a PR.`); + console.log('You likely now need to do `git push --force`'); + } catch (error) { + console.error(`Error: ${error.message}`); + process.exit(1); + } +} + +runGitCommands(); diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml new file mode 100644 index 00000000..4db2bc39 --- /dev/null +++ b/.github/workflows/stable-sync.yml @@ -0,0 +1,100 @@ +name: Stable Sync + +on: + workflow_dispatch: + inputs: + version_type: + description: 'Type of version bump (major, minor, patch)' + required: true + type: choice + options: + - major + - minor + - patch + default: 'patch' + +jobs: + stable-sync: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Get next version from latest tag + id: version + run: | + # Get the latest tag + LATEST_TAG=$(git describe --tags --abbrev=0) + + # Remove 'v' prefix if it exists + LATEST_VERSION=${LATEST_TAG#v} + + # Split version into components + IFS='.' read -r major minor patch <<< "$LATEST_VERSION" + + # Increment version based on input + case "${{ github.event.inputs.version_type }}" in + "major") + major=$((major + 1)) + minor=0 + patch=0 + ;; + "minor") + minor=$((minor + 1)) + patch=0 + ;; + "patch") + patch=$((patch + 1)) + ;; + esac + + # Construct new version + NEW_VERSION="$major.$minor.$patch" + echo "next_version=$NEW_VERSION" >> $GITHUB_OUTPUT + echo "Current version: $LATEST_VERSION" + echo "Next version: $NEW_VERSION" + + - name: Check if PR exists + id: check-pr + uses: actions/github-script@v7 + with: + script: | + const { data: prs } = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + head: `${context.repo.owner}:stable-main-${process.env.NEXT_VERSION}`, + base: 'main' + }); + return prs.length > 0; + env: + NEXT_VERSION: ${{ steps.version.outputs.next_version }} + + - name: Run stable sync + # if: steps.check-pr.outputs.result != 'true' + run: node .github/scripts/stable-sync.js "stable-main-${{ steps.version.outputs.next_version }}" + + - name: Create Pull Request + if: steps.check-pr.outputs.result != 'true' + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "chore: sync stable to main for version ${{ steps.version.outputs.next_version }}" + title: "chore: sync stable to main for version ${{ steps.version.outputs.next_version }}" + body: | + This PR syncs the stable branch to main for version ${{ steps.version.outputs.next_version }}. + + Changes: + - Merged stable into main + - Preserved stable-specific files + - Updated version to ${{ steps.version.outputs.next_version }} + branch: "stable-main-${{ steps.version.outputs.next_version }}" + base: main + labels: | + sync + stable \ No newline at end of file From 70f94aa324b8bff68a8359cff13403a57208a142 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Thu, 15 May 2025 10:36:03 +0200 Subject: [PATCH 02/29] chore: remove unused input --- .github/workflows/stable-sync.yml | 44 ------------------------------- 1 file changed, 44 deletions(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 4db2bc39..900382ce 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -2,16 +2,6 @@ name: Stable Sync on: workflow_dispatch: - inputs: - version_type: - description: 'Type of version bump (major, minor, patch)' - required: true - type: choice - options: - - major - - minor - - patch - default: 'patch' jobs: stable-sync: @@ -26,40 +16,6 @@ jobs: with: node-version: '18' - - name: Get next version from latest tag - id: version - run: | - # Get the latest tag - LATEST_TAG=$(git describe --tags --abbrev=0) - - # Remove 'v' prefix if it exists - LATEST_VERSION=${LATEST_TAG#v} - - # Split version into components - IFS='.' read -r major minor patch <<< "$LATEST_VERSION" - - # Increment version based on input - case "${{ github.event.inputs.version_type }}" in - "major") - major=$((major + 1)) - minor=0 - patch=0 - ;; - "minor") - minor=$((minor + 1)) - patch=0 - ;; - "patch") - patch=$((patch + 1)) - ;; - esac - - # Construct new version - NEW_VERSION="$major.$minor.$patch" - echo "next_version=$NEW_VERSION" >> $GITHUB_OUTPUT - echo "Current version: $LATEST_VERSION" - echo "Next version: $NEW_VERSION" - - name: Check if PR exists id: check-pr uses: actions/github-script@v7 From 9dcf8bd186fd6e3d723607dcbc198836717ea482 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Thu, 15 May 2025 11:24:46 +0200 Subject: [PATCH 03/29] chore: update stable sync To accept as input the semver from the repo --- .github/workflows/stable-sync.yml | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 900382ce..217ca33e 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -2,6 +2,11 @@ name: Stable Sync on: workflow_dispatch: + inputs: + semver-version: + required: true + type: string + description: 'The semantic version to use for the sync (e.g., x.x.x)' jobs: stable-sync: @@ -24,33 +29,33 @@ jobs: const { data: prs } = await github.rest.pulls.list({ owner: context.repo.owner, repo: context.repo.repo, - head: `${context.repo.owner}:stable-main-${process.env.NEXT_VERSION}`, + head: `${context.repo.owner}:stable-main-${process.env.SEMVER_VERSION}`, base: 'main' }); return prs.length > 0; env: - NEXT_VERSION: ${{ steps.version.outputs.next_version }} + SEMVER_VERSION: ${{ inputs.semver-version }} - name: Run stable sync # if: steps.check-pr.outputs.result != 'true' - run: node .github/scripts/stable-sync.js "stable-main-${{ steps.version.outputs.next_version }}" + run: node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" - name: Create Pull Request if: steps.check-pr.outputs.result != 'true' - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.GITHUB_TOKEN }} - commit-message: "chore: sync stable to main for version ${{ steps.version.outputs.next_version }}" - title: "chore: sync stable to main for version ${{ steps.version.outputs.next_version }}" + author: "metamaskbot metamaskbot@users.noreply.github.com" + commit-message: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" + title: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" body: | - This PR syncs the stable branch to main for version ${{ steps.version.outputs.next_version }}. + This PR syncs the stable branch from main prior of version ${{ inputs.semver-version }}. Changes: - - Merged stable into main - - Preserved stable-specific files - - Updated version to ${{ steps.version.outputs.next_version }} - branch: "stable-main-${{ steps.version.outputs.next_version }}" - base: main + - Merged main into stable-main-${{ inputs.semver-version }} + - Preserved stable-specific files from main + - Updated version to ${{ inputs.semver-version }} + branch: "stable-main-${{ inputs.semver-version }}" labels: | sync stable \ No newline at end of file From 6fea9a0361bd392df7b01529adde2427f038ffa3 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Thu, 15 May 2025 11:50:22 +0200 Subject: [PATCH 04/29] chore: added workflow call --- .github/workflows/stable-sync.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 217ca33e..4422816e 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -7,6 +7,12 @@ on: required: true type: string description: 'The semantic version to use for the sync (e.g., x.x.x)' + workflow_call: + inputs: + semver-version: + required: true + type: string + description: 'The semantic version to use for the sync (e.g., x.x.x)' jobs: stable-sync: From 887c99d5c0ebd45555a9151d94e5bd0a7aeb27dd Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Thu, 15 May 2025 11:58:04 +0200 Subject: [PATCH 05/29] chore: pin pr action from v7 to v5 --- .github/workflows/stable-sync.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 4422816e..171c4c36 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -48,7 +48,7 @@ jobs: - name: Create Pull Request if: steps.check-pr.outputs.result != 'true' - uses: peter-evans/create-pull-request@v7 + uses: peter-evans/create-pull-request@v with: token: ${{ secrets.GITHUB_TOKEN }} author: "metamaskbot metamaskbot@users.noreply.github.com" From e7c2d756bb79550af99d50a9a9100092ce72036f Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Thu, 15 May 2025 12:05:01 +0200 Subject: [PATCH 06/29] chore: comment the Create PR step, to test previous one before --- .github/workflows/stable-sync.yml | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 171c4c36..46007fac 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -46,22 +46,22 @@ jobs: # if: steps.check-pr.outputs.result != 'true' run: node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" - - name: Create Pull Request - if: steps.check-pr.outputs.result != 'true' - uses: peter-evans/create-pull-request@v - with: - token: ${{ secrets.GITHUB_TOKEN }} - author: "metamaskbot metamaskbot@users.noreply.github.com" - commit-message: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" - title: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" - body: | - This PR syncs the stable branch from main prior of version ${{ inputs.semver-version }}. + # - name: Create Pull Request + # if: steps.check-pr.outputs.result != 'true' + # uses: peter-evans/create-pull-request@v + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + # author: "metamaskbot metamaskbot@users.noreply.github.com" + # commit-message: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" + # title: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" + # body: | + # This PR syncs the stable branch from main prior of version ${{ inputs.semver-version }}. - Changes: - - Merged main into stable-main-${{ inputs.semver-version }} - - Preserved stable-specific files from main - - Updated version to ${{ inputs.semver-version }} - branch: "stable-main-${{ inputs.semver-version }}" - labels: | - sync - stable \ No newline at end of file + # Changes: + # - Merged main into stable-main-${{ inputs.semver-version }} + # - Preserved stable-specific files from main + # - Updated version to ${{ inputs.semver-version }} + # branch: "stable-main-${{ inputs.semver-version }}" + # labels: | + # sync + # stable \ No newline at end of file From c9473ee5c5832fca74b8cd47abdeead518e9eb44 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Thu, 15 May 2025 12:19:25 +0200 Subject: [PATCH 07/29] chore: set user and email --- .github/workflows/stable-sync.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 46007fac..0113980e 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -41,6 +41,11 @@ jobs: return prs.length > 0; env: SEMVER_VERSION: ${{ inputs.semver-version }} + + - name: Set Git user and email + run: | + git config user.name "metamaskbot" + git config user.email "metamaskbot@users.noreply.github.com" - name: Run stable sync # if: steps.check-pr.outputs.result != 'true' From 51937a5e00e8bc9ae2511273ba90e9c3e608b34a Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Thu, 15 May 2025 12:26:11 +0200 Subject: [PATCH 08/29] chore: added global as well --- .github/workflows/stable-sync.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 0113980e..b914f973 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -44,8 +44,8 @@ jobs: - name: Set Git user and email run: | - git config user.name "metamaskbot" - git config user.email "metamaskbot@users.noreply.github.com" + git config --global user.name "metamaskbot" + git config --global user.email "metamaskbot@users.noreply.github.com" - name: Run stable sync # if: steps.check-pr.outputs.result != 'true' From 373fb6d332a34ce2c3b9f28ec3125ed1170b2708 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 11:35:21 +0200 Subject: [PATCH 09/29] chore: enable create PR on GH toolkit --- .github/workflows/stable-sync.yml | 37 ++++++++++++++++--------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index b914f973..89d843a5 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -48,25 +48,26 @@ jobs: git config --global user.email "metamaskbot@users.noreply.github.com" - name: Run stable sync + id: run-stable-sync # if: steps.check-pr.outputs.result != 'true' run: node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" - # - name: Create Pull Request - # if: steps.check-pr.outputs.result != 'true' - # uses: peter-evans/create-pull-request@v - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - # author: "metamaskbot metamaskbot@users.noreply.github.com" - # commit-message: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" - # title: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" - # body: | - # This PR syncs the stable branch from main prior of version ${{ inputs.semver-version }}. + - name: Create Pull Request + if: steps.check-pr.outputs.result != 'true' && steps.run-stable-sync.outputs.result != 'true' + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + author: "metamaskbot metamaskbot@users.noreply.github.com" + commit-message: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" + title: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" + body: | + This PR syncs the stable branch from main prior of version ${{ inputs.semver-version }}. - # Changes: - # - Merged main into stable-main-${{ inputs.semver-version }} - # - Preserved stable-specific files from main - # - Updated version to ${{ inputs.semver-version }} - # branch: "stable-main-${{ inputs.semver-version }}" - # labels: | - # sync - # stable \ No newline at end of file + Changes: + - Merged main into stable-main-${{ inputs.semver-version }} + - Preserved stable-specific files from main + - Updated version to ${{ inputs.semver-version }} + branch: "stable-main-${{ inputs.semver-version }}" + labels: | + sync + stable \ No newline at end of file From 96649565e72f20237b0dbfd783de223d76fa213d Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 11:47:19 +0200 Subject: [PATCH 10/29] chore: commented peter evans PR create step --- .github/workflows/stable-sync.yml | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 89d843a5..28d2e40a 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -52,22 +52,22 @@ jobs: # if: steps.check-pr.outputs.result != 'true' run: node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" - - name: Create Pull Request - if: steps.check-pr.outputs.result != 'true' && steps.run-stable-sync.outputs.result != 'true' - uses: peter-evans/create-pull-request@v5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - author: "metamaskbot metamaskbot@users.noreply.github.com" - commit-message: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" - title: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" - body: | - This PR syncs the stable branch from main prior of version ${{ inputs.semver-version }}. + # - name: Create Pull Request + # if: steps.check-pr.outputs.result != 'true' && steps.run-stable-sync.outputs.result != 'true' + # uses: peter-evans/create-pull-request@v5 + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + # author: "metamaskbot metamaskbot@users.noreply.github.com" + # commit-message: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" + # title: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" + # body: | + # This PR syncs the stable branch from main prior of version ${{ inputs.semver-version }}. - Changes: - - Merged main into stable-main-${{ inputs.semver-version }} - - Preserved stable-specific files from main - - Updated version to ${{ inputs.semver-version }} - branch: "stable-main-${{ inputs.semver-version }}" - labels: | - sync - stable \ No newline at end of file + # Changes: + # - Merged main into stable-main-${{ inputs.semver-version }} + # - Preserved stable-specific files from main + # - Updated version to ${{ inputs.semver-version }} + # branch: "stable-main-${{ inputs.semver-version }}" + # labels: | + # sync + # stable \ No newline at end of file From a769465d4def677c3cc81c613bc3f9e7411d8347 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 11:48:52 +0200 Subject: [PATCH 11/29] chore: added CREATE_BRANCH env for the sync step --- .github/workflows/stable-sync.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 28d2e40a..b9ef53ed 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -50,7 +50,10 @@ jobs: - name: Run stable sync id: run-stable-sync # if: steps.check-pr.outputs.result != 'true' + env: + CREATE_BRANCH: 'true' run: node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" + # - name: Create Pull Request # if: steps.check-pr.outputs.result != 'true' && steps.run-stable-sync.outputs.result != 'true' From cafe053106a5055918353f623d9dd26fa2c51558 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 11:59:36 +0200 Subject: [PATCH 12/29] chore: improve the template --- .github/workflows/stable-sync.yml | 44 +++++++++++++++---------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index b9ef53ed..4383fc6a 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -49,28 +49,26 @@ jobs: - name: Run stable sync id: run-stable-sync - # if: steps.check-pr.outputs.result != 'true' + if: steps.check-pr.outputs.result != 'true' + run: | + node .github/scripts/stable-sync.js "stable-main-${{ steps.version.outputs.next_version }}" + - name: Create Pull Request + if: steps.check-pr.outputs.result != 'true' env: - CREATE_BRANCH: 'true' - run: node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" - + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH_NAME: stable-main-${{ steps.version.outputs.next_version }} + VERSION: ${{ steps.version.outputs.next_version }} + run: | + # Create PR using GitHub CLI + gh pr create \ + --title "chore: sync stable to main for version $VERSION" \ + --body "This PR syncs the stable branch to main for version $VERSION. - # - name: Create Pull Request - # if: steps.check-pr.outputs.result != 'true' && steps.run-stable-sync.outputs.result != 'true' - # uses: peter-evans/create-pull-request@v5 - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - # author: "metamaskbot metamaskbot@users.noreply.github.com" - # commit-message: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" - # title: "chore: sync stable branch with main for version ${{ inputs.semver-version }}" - # body: | - # This PR syncs the stable branch from main prior of version ${{ inputs.semver-version }}. - - # Changes: - # - Merged main into stable-main-${{ inputs.semver-version }} - # - Preserved stable-specific files from main - # - Updated version to ${{ inputs.semver-version }} - # branch: "stable-main-${{ inputs.semver-version }}" - # labels: | - # sync - # stable \ No newline at end of file + Changes: + - Merged stable into main + - Preserved stable-specific files + - Updated version to $VERSION" \ + --base main \ + --head "$BRANCH_NAME" \ + --label "sync" \ + --label "stable" \ No newline at end of file From 23607c1f9ea0d55bcff5d3931fe5ea290f492aad Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 12:09:30 +0200 Subject: [PATCH 13/29] chore: update adding env var to create branch --- .github/workflows/stable-sync.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 4383fc6a..8fcef678 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -50,14 +50,18 @@ jobs: - name: Run stable sync id: run-stable-sync if: steps.check-pr.outputs.result != 'true' + env: + CREATE_BRANCH: 'true' run: | - node .github/scripts/stable-sync.js "stable-main-${{ steps.version.outputs.next_version }}" + node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" + + - name: Create Pull Request if: steps.check-pr.outputs.result != 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH_NAME: stable-main-${{ steps.version.outputs.next_version }} - VERSION: ${{ steps.version.outputs.next_version }} + BRANCH_NAME: stable-main-${{ inputs.semver-version }} + VERSION: ${{ inputs.semver-version }} run: | # Create PR using GitHub CLI gh pr create \ @@ -69,6 +73,6 @@ jobs: - Preserved stable-specific files - Updated version to $VERSION" \ --base main \ - --head "$BRANCH_NAME" \ - --label "sync" \ - --label "stable" \ No newline at end of file + --head "$BRANCH_NAME" + #--label "sync" \ + #--label "stable" \ No newline at end of file From 3b26c04cb64e350c5d9a6676611aa5de6d3b9565 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 12:13:55 +0200 Subject: [PATCH 14/29] chore: add gh command to push the branch --- .github/workflows/stable-sync.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 8fcef678..5711d412 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -54,7 +54,9 @@ jobs: CREATE_BRANCH: 'true' run: | node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" - + # Push the branch to origin using GitHub CLI + gh auth status + git push --set-upstream origin "stable-main-${{ inputs.semver-version }}" - name: Create Pull Request if: steps.check-pr.outputs.result != 'true' From fcfd2d3b7faeb31b0592c91f7e3c0de5b1666377 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 12:14:37 +0200 Subject: [PATCH 15/29] chore: test create with gh command --- .github/workflows/stable-sync.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 5711d412..3ba7e092 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -51,7 +51,7 @@ jobs: id: run-stable-sync if: steps.check-pr.outputs.result != 'true' env: - CREATE_BRANCH: 'true' + CREATE_BRANCH: 'false' run: | node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" # Push the branch to origin using GitHub CLI From 3a67a8edc009048ad9c2a7afae034a5e7706053d Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 12:16:46 +0200 Subject: [PATCH 16/29] chore: gh auth login --- .github/workflows/stable-sync.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 3ba7e092..3653f1ce 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -55,6 +55,7 @@ jobs: run: | node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" # Push the branch to origin using GitHub CLI + gh auth login gh auth status git push --set-upstream origin "stable-main-${{ inputs.semver-version }}" From 0279f7825ebf6f14df247474715eb804ebdbd2f7 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 12:18:35 +0200 Subject: [PATCH 17/29] chore: test without using gh --- .github/workflows/stable-sync.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 3653f1ce..d6b0f8c5 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -55,8 +55,6 @@ jobs: run: | node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" # Push the branch to origin using GitHub CLI - gh auth login - gh auth status git push --set-upstream origin "stable-main-${{ inputs.semver-version }}" - name: Create Pull Request From 93207bd8afba80c206699ecb9b91055675727296 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 12:31:39 +0200 Subject: [PATCH 18/29] chore: improve body PR --- .github/workflows/stable-sync.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index d6b0f8c5..6b12152a 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -69,10 +69,17 @@ jobs: --title "chore: sync stable to main for version $VERSION" \ --body "This PR syncs the stable branch to main for version $VERSION. - Changes: - - Merged stable into main - - Preserved stable-specific files - - Updated version to $VERSION" \ + + Resets it to match the remote 'stable' branch exactly. + Lates 'main' branch is merged into this branch. + Handles potential merge conflicts. + Then performs a series of careful operations: + - Restores all files from 'main' first (git checkout origin/main -- .) + - Selectively restores specific files from 'stable' that should be preserved: + - CHANGELOG.md + - Mobile-specific files (bitrise.yml, android build files, iOS project files) + - package.json + - Indicates the next version candidate of main to $VERSION" \ --base main \ --head "$BRANCH_NAME" #--label "sync" \ From 34c5d2c030b38d3276f34d2e796262215074ca38 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 12:33:05 +0200 Subject: [PATCH 19/29] chore: update sync script --- .github/scripts/stable-sync.js | 37 +++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/.github/scripts/stable-sync.js b/.github/scripts/stable-sync.js index 4844cfd2..67edfd71 100644 --- a/.github/scripts/stable-sync.js +++ b/.github/scripts/stable-sync.js @@ -9,6 +9,9 @@ // // Usage: node stable-sync.js [branch-name] // If no branch name is provided, defaults to 'stable-sync' +// +// Environment variables: +// CREATE_BRANCH - if set to 'true', will push the branch at the end const { promisify } = require('util'); const exec = promisify(require('child_process').exec); @@ -16,6 +19,9 @@ const exec = promisify(require('child_process').exec); async function runGitCommands() { // Get branch name from command line arguments or use default const branchName = process.argv[2] || 'stable-main'; + + // Check if CREATE_BRANCH environment variable exists and is set to true + const shouldPushBranch = (process.env.CREATE_BRANCH || 'false').toLowerCase() === 'true'; try { try { @@ -111,11 +117,36 @@ async function runGitCommands() { await exec('git add .'); console.log('Executed: git add .'); - await exec(`git commit -m "Merge origin/main into ${branchName}" --no-verify`); - console.log('Executed: git commit'); + try { + // Check if there are any changes to commit + const { stdout: status } = await exec('git status --porcelain'); + if (!status.trim()) { + console.log('No changes to commit, skipping commit step'); + return; + } + + await exec(`git commit -m "Merge origin/main into ${branchName}" --no-verify`); + console.log('Executed: git commit'); + } catch (error) { + console.error(`Error: ${error.message}`); + process.exit(1); + } console.log(`Your local ${branchName} branch is now ready to become a PR.`); - console.log('You likely now need to do `git push --force`'); + + // Push the branch if CREATE_BRANCH is true + if (shouldPushBranch) { + try { + console.log(`Pushing branch ${branchName} to remote...`); + await exec(`git push --set-upstream origin ${branchName}`); + console.log(`Successfully pushed branch ${branchName} to remote`); + } catch (error) { + console.error(`Error pushing branch: ${error.message}`); + process.exit(1); + } + } else { + console.log('You likely now need to do `git push --force`'); + } } catch (error) { console.error(`Error: ${error.message}`); process.exit(1); From 84d60c047b369df04738bfbc54d16437ac1b16a0 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 12:41:14 +0200 Subject: [PATCH 20/29] chore: execute chantes even if the PR exists --- .github/workflows/stable-sync.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 6b12152a..1fb2f3a7 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -49,7 +49,7 @@ jobs: - name: Run stable sync id: run-stable-sync - if: steps.check-pr.outputs.result != 'true' + # if: steps.check-pr.outputs.result != 'true' env: CREATE_BRANCH: 'false' run: | From 85aeea370ea1666d0550400a28742fd74700e58e Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 13:48:28 +0200 Subject: [PATCH 21/29] chore: check for push outside of the box --- .github/workflows/stable-sync.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 1fb2f3a7..9ac5b48d 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -54,8 +54,15 @@ jobs: CREATE_BRANCH: 'false' run: | node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" - # Push the branch to origin using GitHub CLI - git push --set-upstream origin "stable-main-${{ inputs.semver-version }}" + # Check if branch exists remotely + BRANCH_NAME="stable-main-${{ inputs.semver-version }}" + if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then + echo "Branch $BRANCH_NAME exists remotely, pushing normally" + git push origin "$BRANCH_NAME" + else + echo "Branch $BRANCH_NAME doesn't exist remotely, pushing with --set-upstream" + git push --set-upstream origin "$BRANCH_NAME" + fi - name: Create Pull Request if: steps.check-pr.outputs.result != 'true' From fe969ac5d7241e31a1a16e982f23e14e4554baa6 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 13:53:24 +0200 Subject: [PATCH 22/29] chore: added pull before push --- .github/workflows/stable-sync.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 9ac5b48d..108eb054 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -58,7 +58,7 @@ jobs: BRANCH_NAME="stable-main-${{ inputs.semver-version }}" if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then echo "Branch $BRANCH_NAME exists remotely, pushing normally" - git push origin "$BRANCH_NAME" + git pull && git push origin "$BRANCH_NAME" else echo "Branch $BRANCH_NAME doesn't exist remotely, pushing with --set-upstream" git push --set-upstream origin "$BRANCH_NAME" From 805133a51ef3a138b6bb14987bebc451cc587f3e Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 14:01:53 +0200 Subject: [PATCH 23/29] chore: tes new script changes --- .github/workflows/stable-sync.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 108eb054..73d59340 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -58,7 +58,7 @@ jobs: BRANCH_NAME="stable-main-${{ inputs.semver-version }}" if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then echo "Branch $BRANCH_NAME exists remotely, pushing normally" - git pull && git push origin "$BRANCH_NAME" + git push origin "$BRANCH_NAME" --force else echo "Branch $BRANCH_NAME doesn't exist remotely, pushing with --set-upstream" git push --set-upstream origin "$BRANCH_NAME" From 0795ec6f192cebeacc2f849d37c99d7ba89a4df3 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 14:04:37 +0200 Subject: [PATCH 24/29] chore: push --- .github/workflows/stable-sync.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 73d59340..bb30d57e 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -58,7 +58,7 @@ jobs: BRANCH_NAME="stable-main-${{ inputs.semver-version }}" if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then echo "Branch $BRANCH_NAME exists remotely, pushing normally" - git push origin "$BRANCH_NAME" --force + git push origin "$BRANCH_NAME" --rebase else echo "Branch $BRANCH_NAME doesn't exist remotely, pushing with --set-upstream" git push --set-upstream origin "$BRANCH_NAME" From 77524445f7c8d1d0b200d30054414adfefb74532 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 14:07:16 +0200 Subject: [PATCH 25/29] chore: test --- .github/workflows/stable-sync.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index bb30d57e..7299002c 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -57,8 +57,9 @@ jobs: # Check if branch exists remotely BRANCH_NAME="stable-main-${{ inputs.semver-version }}" if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then + git pull --rebase echo "Branch $BRANCH_NAME exists remotely, pushing normally" - git push origin "$BRANCH_NAME" --rebase + git push origin "$BRANCH_NAME" --force else echo "Branch $BRANCH_NAME doesn't exist remotely, pushing with --set-upstream" git push --set-upstream origin "$BRANCH_NAME" From 1cbd044c0f1bdac3c370616f9af8c9733f8ebffa Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 14:25:34 +0200 Subject: [PATCH 26/29] chore: improve script for mobile and extension --- .github/scripts/stable-sync.js | 67 ++++++++++++++++++++----------- .github/workflows/stable-sync.yml | 24 ++++++++--- 2 files changed, 62 insertions(+), 29 deletions(-) diff --git a/.github/scripts/stable-sync.js b/.github/scripts/stable-sync.js index 67edfd71..d85405c6 100644 --- a/.github/scripts/stable-sync.js +++ b/.github/scripts/stable-sync.js @@ -27,11 +27,13 @@ async function runGitCommands() { try { // Check if the branch already exists const { stdout: branchExists } = await exec( - `git rev-parse --quiet --verify ${branchName}`, + //`git rev-parse --quiet --verify ${branchName}`, + `git ls-remote origin ${branchName}`, ); if (branchExists.trim()) { // Branch exists, so simply check it out await exec(`git checkout ${branchName}`); + await exec(`git pull origin ${branchName}`); console.log(`Checked out branch: ${branchName}`); } else { throw new Error( @@ -88,31 +90,39 @@ async function runGitCommands() { await exec('git checkout origin/stable -- CHANGELOG.md'); console.log('Executed: git checkout origin/stable -- CHANGELOG.md'); - // Mobile Only - await exec('git checkout origin/stable -- bitrise.yml'); - console.log('Executed: git checkout origin/stable -- bitrise.yml'); + // Execute mobile-specific commands if REPO is 'mobile' + if (process.env.REPO === 'mobile') { + console.log('Executing mobile-specific commands...'); + + await exec('git checkout origin/stable -- bitrise.yml'); + console.log('Executed: git checkout origin/stable -- bitrise.yml'); - // Mobile Only - await exec('git checkout origin/stable -- android/app/build.gradle'); - console.log('Executed: git checkout origin/stable -- android/app/build.gradle'); + await exec('git checkout origin/stable -- android/app/build.gradle'); + console.log('Executed: git checkout origin/stable -- android/app/build.gradle'); - // Mobile Only - await exec('git checkout origin/stable -- ios/MetaMask.xcodeproj/project.pbxproj'); - console.log('Executed: git checkout origin/stable -- ios/MetaMask.xcodeproj/project.pbxproj'); + await exec('git checkout origin/stable -- ios/MetaMask.xcodeproj/project.pbxproj'); + console.log('Executed: git checkout origin/stable -- ios/MetaMask.xcodeproj/project.pbxproj'); - // Mobile Only - await exec('git checkout origin/stable -- package.json'); - console.log('Executed: git checkout origin/stable -- package.json'); - - // Extension Only - // const { stdout: packageJsonContent } = await exec( - // 'git show origin/master:package.json', - // ); - // const packageJson = JSON.parse(packageJsonContent); - // const packageVersion = packageJson.version; + await exec('git checkout origin/stable -- package.json'); + console.log('Executed: git checkout origin/stable -- package.json'); + } + // Execute extension-specific commands if REPO is 'extension' + else if (process.env.REPO === 'extension') { + console.log('Executing extension-specific commands...'); + + const { stdout: packageJsonContent } = await exec( + 'git show origin/master:package.json', + ); + const packageJson = JSON.parse(packageJsonContent); + const packageVersion = packageJson.version; - // await exec(`yarn version "${packageVersion}"`); - // console.log('Executed: yarn version'); + await exec(`yarn version "${packageVersion}"`); + console.log('Executed: yarn version'); + } + // If REPO is not set or has an invalid value, skip both + else { + console.log('REPO environment variable not set or invalid. Skipping mobile/extension specific commands.'); + } await exec('git add .'); console.log('Executed: git add .'); @@ -137,8 +147,17 @@ async function runGitCommands() { // Push the branch if CREATE_BRANCH is true if (shouldPushBranch) { try { - console.log(`Pushing branch ${branchName} to remote...`); - await exec(`git push --set-upstream origin ${branchName}`); + console.log(`Checking if branch ${branchName} exists remotely...`); + const { stdout: remoteBranches } = await exec('git ls-remote --heads origin'); + const branchExists = remoteBranches.includes(`refs/heads/${branchName}`); + + if (branchExists) { + console.log(`Branch ${branchName} exists remotely, updating...`); + await exec(`git push origin ${branchName}`); + } else { + console.log(`Branch ${branchName} does not exist remotely, creating...`); + await exec(`git push --set-upstream origin ${branchName}`); + } console.log(`Successfully pushed branch ${branchName} to remote`); } catch (error) { console.error(`Error pushing branch: ${error.message}`); diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 7299002c..9e229cb8 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -3,16 +3,29 @@ name: Stable Sync on: workflow_dispatch: inputs: - semver-version: - required: true - type: string - description: 'The semantic version to use for the sync (e.g., x.x.x)' + semver-version: + required: true + type: string + description: 'The semantic version to use for the sync (e.g., x.x.x)' + repo-type: + required: false + type: choice + description: 'Type of repository (mobile or extension)' + options: + - mobile + - extension + default: 'mobile' workflow_call: inputs: semver-version: required: true type: string description: 'The semantic version to use for the sync (e.g., x.x.x)' + repo-type: + required: false + type: string + description: 'Type of repository (mobile or extension)' + default: 'mobile' jobs: stable-sync: @@ -51,7 +64,8 @@ jobs: id: run-stable-sync # if: steps.check-pr.outputs.result != 'true' env: - CREATE_BRANCH: 'false' + CREATE_BRANCH: 'false' # let the script handle the branch creation + REPO: ${{ inputs.repo-type }} # Default to 'mobile' if not specified run: | node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" # Check if branch exists remotely From d543dd06073411e282823246b7262182b65fa8f6 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 14:33:42 +0200 Subject: [PATCH 27/29] chore: clean up body message --- .github/workflows/stable-sync.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 9e229cb8..b70188b7 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -92,16 +92,23 @@ jobs: --body "This PR syncs the stable branch to main for version $VERSION. - Resets it to match the remote 'stable' branch exactly. - Lates 'main' branch is merged into this branch. - Handles potential merge conflicts. - Then performs a series of careful operations: - - Restores all files from 'main' first (git checkout origin/main -- .) - - Selectively restores specific files from 'stable' that should be preserved: + *Synchronization Process:* + + - Fetches the latest changes from the remote repository + - Resets the branch to match the stable branch + - Attempts to merge changes from main into the branch + - Handles merge conflicts if they occur + + *File Preservation:* + + Preserves specific files from the stable branch: - CHANGELOG.md - - Mobile-specific files (bitrise.yml, android build files, iOS project files) + - bitrise.yml + - android/app/build.gradle + - ios/MetaMask.xcodeproj/project.pbxproj - package.json - - Indicates the next version candidate of main to $VERSION" \ + + Indicates the next version candidate of main to $VERSION" \ --base main \ --head "$BRANCH_NAME" #--label "sync" \ From 68cdc5f0515e7f7698cef04ddffcdc81169bff63 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 15:23:39 +0200 Subject: [PATCH 28/29] chore: lint yaml --- .github/workflows/stable-sync.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index b70188b7..b3908b1a 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -91,7 +91,6 @@ jobs: --title "chore: sync stable to main for version $VERSION" \ --body "This PR syncs the stable branch to main for version $VERSION. - *Synchronization Process:* - Fetches the latest changes from the remote repository From 22dc82da2801d94c1f6cc557b348fbc08b53a8b9 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Fri, 16 May 2025 15:26:45 +0200 Subject: [PATCH 29/29] chore: linter passed --- .github/workflows/stable-sync.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index b3908b1a..68fae196 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -34,7 +34,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - + - name: Setup Node.js uses: actions/setup-node@v4 with: @@ -59,13 +59,13 @@ jobs: run: | git config --global user.name "metamaskbot" git config --global user.email "metamaskbot@users.noreply.github.com" - + - name: Run stable sync id: run-stable-sync # if: steps.check-pr.outputs.result != 'true' env: CREATE_BRANCH: 'false' # let the script handle the branch creation - REPO: ${{ inputs.repo-type }} # Default to 'mobile' if not specified + REPO: ${{ inputs.repo-type }} # Default to 'mobile' if not specified run: | node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" # Check if branch exists remotely @@ -111,4 +111,4 @@ jobs: --base main \ --head "$BRANCH_NAME" #--label "sync" \ - #--label "stable" \ No newline at end of file + #--label "stable"