From 7b83ebe59d89a32ee535d4c60fede01f7306174d Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Wed, 11 Jun 2025 15:04:03 +0200 Subject: [PATCH 01/11] feat(stable-sync): improve the script for extension pipeline Metamask Extension doesn't have yet a stable branch, and also we're preparing it for current release and future release branch naming, so we're testing the retro compatibility and make sure it works. --- .github/scripts/stable-sync.js | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/.github/scripts/stable-sync.js b/.github/scripts/stable-sync.js index d85405c6..2fdf53a5 100644 --- a/.github/scripts/stable-sync.js +++ b/.github/scripts/stable-sync.js @@ -26,33 +26,22 @@ async function runGitCommands() { try { try { // Check if the branch already exists - const { stdout: branchExists } = await exec( - //`git rev-parse --quiet --verify ${branchName}`, - `git ls-remote origin ${branchName}`, - ); + const { stdout: branchExists } = await exec(`git ls-remote origin ${branchName}`); if (branchExists.trim()) { - // Branch exists, so simply check it out + // Branch exists, check it out await exec(`git checkout ${branchName}`); await exec(`git pull origin ${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 + // Branch doesn't exist, create it + console.warn(`Branch does not exist, creating new ${branchName} branch.`); await exec(`git checkout -b ${branchName}`); console.log(`Created and checked out branch: ${branchName}`); - } else { - console.error(`Error: ${error.message}`); - process.exit(1); } + } catch (error) { + // Handle actual git command errors + console.error(`Error: ${error.message}`); + process.exit(1); } await exec('git fetch'); From fcf084863bd0763016f3b68930eb75aa8124ffb1 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Wed, 11 Jun 2025 15:18:49 +0200 Subject: [PATCH 02/11] chore: test specific branch --- .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 68fae196..014eef6c 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -34,6 +34,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ale/improve-stable-sync-pipeline-process - name: Setup Node.js uses: actions/setup-node@v4 From 032941ac264be6cc0f06956e39b86ebf2af34ffe Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Wed, 11 Jun 2025 15:24:42 +0200 Subject: [PATCH 03/11] chore: remove reference to a branch --- .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 014eef6c..68fae196 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -34,7 +34,6 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ale/improve-stable-sync-pipeline-process - name: Setup Node.js uses: actions/setup-node@v4 From 441f7d8d3b9c31e916eabf63be2bdf6fadee4a58 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Wed, 11 Jun 2025 16:22:34 +0200 Subject: [PATCH 04/11] chore: add step to pfix packagemanger issue --- .github/workflows/stable-sync.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 68fae196..5c8a435f 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -40,6 +40,10 @@ jobs: with: node-version: '18' + - name: Prepare Yarn + if: ${{ inputs.repo-type == 'extension' }} + run: corepack prepare yarn@4.5.1 --activate + - name: Check if PR exists id: check-pr uses: actions/github-script@v7 From 228d0f21fed33a786c7b5de37e201e572e4fe4a5 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Wed, 11 Jun 2025 16:47:53 +0200 Subject: [PATCH 05/11] chore: set up different node version for extension --- .github/workflows/stable-sync.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 5c8a435f..bc2b5a8a 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -35,11 +35,18 @@ jobs: with: fetch-depth: 0 - - name: Setup Node.js + - name: Setup Node.js Mobile + if: ${{ inputs.repo-type == 'mobile' }} uses: actions/setup-node@v4 with: node-version: '18' + - name: Setup Node.js Extension + if: ${{ inputs.repo-type == 'extension' }} + uses: actions/setup-node@v4 + with: + node-version: '16' + - name: Prepare Yarn if: ${{ inputs.repo-type == 'extension' }} run: corepack prepare yarn@4.5.1 --activate From 8bd1eff9b9cbd7ffe31449230c4c9b3a468d3c1b Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Wed, 11 Jun 2025 16:50:50 +0200 Subject: [PATCH 06/11] chore: test other version --- .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 bc2b5a8a..86dfe3bc 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -45,7 +45,7 @@ jobs: if: ${{ inputs.repo-type == 'extension' }} uses: actions/setup-node@v4 with: - node-version: '16' + node-version: '16.9.0' - name: Prepare Yarn if: ${{ inputs.repo-type == 'extension' }} From 39e3e577bf25837e21e69435141af7c0d1027dd6 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Wed, 11 Jun 2025 17:08:49 +0200 Subject: [PATCH 07/11] chore: test --- .github/workflows/stable-sync.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 86dfe3bc..650dd06e 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -45,12 +45,16 @@ jobs: if: ${{ inputs.repo-type == 'extension' }} uses: actions/setup-node@v4 with: - node-version: '16.9.0' + node-version: '22.15' - name: Prepare Yarn if: ${{ inputs.repo-type == 'extension' }} run: corepack prepare yarn@4.5.1 --activate + - name: Prepare Yarn - Enable corepack + if: ${{ inputs.repo-type == 'extension' }} + run: corepack + - name: Check if PR exists id: check-pr uses: actions/github-script@v7 From ed0e80554f99271cd729fd20b38a6efd7855dc7e Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Wed, 11 Jun 2025 17:12:01 +0200 Subject: [PATCH 08/11] chore: add codepack enable --- .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 650dd06e..17566e20 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -53,7 +53,7 @@ jobs: - name: Prepare Yarn - Enable corepack if: ${{ inputs.repo-type == 'extension' }} - run: corepack + run: corepack enable - name: Check if PR exists id: check-pr From e62212d82db0ff5972cc6d33a5a1300a5de2ff2d Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Thu, 12 Jun 2025 11:39:19 +0200 Subject: [PATCH 09/11] chore: add stable branch-name input var --- .github/workflows/stable-sync.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/stable-sync.yml b/.github/workflows/stable-sync.yml index 17566e20..d81dee76 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -15,6 +15,11 @@ on: - mobile - extension default: 'mobile' + stable-branch-name: + required: false + type: string + description: 'The name of the stable branch to sync to (e.g., stable, master, main)' + default: 'stable' workflow_call: inputs: semver-version: @@ -26,6 +31,11 @@ on: type: string description: 'Type of repository (mobile or extension)' default: 'mobile' + stable-branch-name: + required: false + type: string + description: 'The name of the stable branch to sync to (e.g., stable, master, main)' + default: 'stable' jobs: stable-sync: @@ -81,6 +91,7 @@ jobs: env: CREATE_BRANCH: 'false' # let the script handle the branch creation REPO: ${{ inputs.repo-type }} # Default to 'mobile' if not specified + BASE_BRANCH: ${{ inputs.stable-branch-name }} run: | node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}" # Check if branch exists remotely From d388a9b207ac60f9cef34ad333d6b5495962b8b7 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Thu, 12 Jun 2025 11:56:48 +0200 Subject: [PATCH 10/11] chore: linter - prettier --- .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 d81dee76..555f5ef6 100644 --- a/.github/workflows/stable-sync.yml +++ b/.github/workflows/stable-sync.yml @@ -64,7 +64,7 @@ jobs: - name: Prepare Yarn - Enable corepack if: ${{ inputs.repo-type == 'extension' }} run: corepack enable - + - name: Check if PR exists id: check-pr uses: actions/github-script@v7 From f0bde473a392b1fec2af19f5fa980c97b1fed027 Mon Sep 17 00:00:00 2001 From: Alejandro Som <560018+alucardzom@users.noreply.github.com> Date: Thu, 12 Jun 2025 11:58:53 +0200 Subject: [PATCH 11/11] chore: keep stable sync script updated --- .github/scripts/stable-sync.js | 46 ++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/.github/scripts/stable-sync.js b/.github/scripts/stable-sync.js index 2fdf53a5..26a9341f 100644 --- a/.github/scripts/stable-sync.js +++ b/.github/scripts/stable-sync.js @@ -9,7 +9,7 @@ // // 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 @@ -19,29 +19,43 @@ 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'; - + + // Get base stable branch from environment variable (defaults to 'master' for backward compatibility of extension) + const baseBranch = process.env.BASE_BRANCH || 'master'; + // Check if CREATE_BRANCH environment variable exists and is set to true const shouldPushBranch = (process.env.CREATE_BRANCH || 'false').toLowerCase() === 'true'; try { try { // Check if the branch already exists - const { stdout: branchExists } = await exec(`git ls-remote origin ${branchName}`); + const { stdout: branchExists } = await exec( + //`git rev-parse --quiet --verify ${branchName}`, + `git ls-remote origin ${branchName}`, + ); if (branchExists.trim()) { - // Branch exists, check it out + // 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 { - // Branch doesn't exist, create it - console.warn(`Branch does not exist, creating new ${branchName} branch.`); + 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); } - } catch (error) { - // Handle actual git command errors - console.error(`Error: ${error.message}`); - process.exit(1); } await exec('git fetch'); @@ -71,7 +85,7 @@ async function runGitCommands() { await exec('git add .'); await exec('git restore --source origin/main .'); - console.log('Executed: it restore --source origin/main .'); + console.log('Executed: git restore --source origin/main .'); await exec('git checkout origin/main -- .'); console.log('Executed: git checkout origin/main -- .'); @@ -82,7 +96,7 @@ async function runGitCommands() { // 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'); @@ -98,9 +112,9 @@ async function runGitCommands() { // 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', + 'git show origin/main:package.json', ); const packageJson = JSON.parse(packageJsonContent); const packageVersion = packageJson.version; @@ -132,7 +146,7 @@ async function runGitCommands() { } console.log(`Your local ${branchName} branch is now ready to become a PR.`); - + // Push the branch if CREATE_BRANCH is true if (shouldPushBranch) { try { @@ -161,4 +175,4 @@ async function runGitCommands() { } } -runGitCommands(); +runGitCommands(); \ No newline at end of file