Skip to content

Commit e1eda4b

Browse files
authored
feat(stable-sync): improve the script for extension pipeline (#75)
* 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. * chore: test specific branch * chore: remove reference to a branch * chore: add step to pfix packagemanger issue * chore: set up different node version for extension * chore: test other version * chore: test * chore: add codepack enable * chore: add stable branch-name input var * chore: linter - prettier * chore: keep stable sync script updated
1 parent 437da63 commit e1eda4b

2 files changed

Lines changed: 38 additions & 9 deletions

File tree

.github/scripts/stable-sync.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010
// Usage: node stable-sync.js [branch-name]
1111
// If no branch name is provided, defaults to 'stable-sync'
12-
//
12+
//
1313
// Environment variables:
1414
// CREATE_BRANCH - if set to 'true', will push the branch at the end
1515

@@ -19,7 +19,10 @@ const exec = promisify(require('child_process').exec);
1919
async function runGitCommands() {
2020
// Get branch name from command line arguments or use default
2121
const branchName = process.argv[2] || 'stable-main';
22-
22+
23+
// Get base stable branch from environment variable (defaults to 'master' for backward compatibility of extension)
24+
const baseBranch = process.env.BASE_BRANCH || 'master';
25+
2326
// Check if CREATE_BRANCH environment variable exists and is set to true
2427
const shouldPushBranch = (process.env.CREATE_BRANCH || 'false').toLowerCase() === 'true';
2528

@@ -82,7 +85,7 @@ async function runGitCommands() {
8285

8386
await exec('git add .');
8487
await exec('git restore --source origin/main .');
85-
console.log('Executed: it restore --source origin/main .');
88+
console.log('Executed: git restore --source origin/main .');
8689

8790
await exec('git checkout origin/main -- .');
8891
console.log('Executed: git checkout origin/main -- .');
@@ -93,7 +96,7 @@ async function runGitCommands() {
9396
// Execute mobile-specific commands if REPO is 'mobile'
9497
if (process.env.REPO === 'mobile') {
9598
console.log('Executing mobile-specific commands...');
96-
99+
97100
await exec('git checkout origin/stable -- bitrise.yml');
98101
console.log('Executed: git checkout origin/stable -- bitrise.yml');
99102

@@ -109,9 +112,9 @@ async function runGitCommands() {
109112
// Execute extension-specific commands if REPO is 'extension'
110113
else if (process.env.REPO === 'extension') {
111114
console.log('Executing extension-specific commands...');
112-
115+
113116
const { stdout: packageJsonContent } = await exec(
114-
'git show origin/master:package.json',
117+
'git show origin/main:package.json',
115118
);
116119
const packageJson = JSON.parse(packageJsonContent);
117120
const packageVersion = packageJson.version;
@@ -143,7 +146,7 @@ async function runGitCommands() {
143146
}
144147

145148
console.log(`Your local ${branchName} branch is now ready to become a PR.`);
146-
149+
147150
// Push the branch if CREATE_BRANCH is true
148151
if (shouldPushBranch) {
149152
try {
@@ -172,4 +175,4 @@ async function runGitCommands() {
172175
}
173176
}
174177

175-
runGitCommands();
178+
runGitCommands();

.github/workflows/stable-sync.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ on:
1515
- mobile
1616
- extension
1717
default: 'mobile'
18+
stable-branch-name:
19+
required: false
20+
type: string
21+
description: 'The name of the stable branch to sync to (e.g., stable, master, main)'
22+
default: 'stable'
1823
workflow_call:
1924
inputs:
2025
semver-version:
@@ -26,6 +31,11 @@ on:
2631
type: string
2732
description: 'Type of repository (mobile or extension)'
2833
default: 'mobile'
34+
stable-branch-name:
35+
required: false
36+
type: string
37+
description: 'The name of the stable branch to sync to (e.g., stable, master, main)'
38+
default: 'stable'
2939

3040
jobs:
3141
stable-sync:
@@ -35,11 +45,26 @@ jobs:
3545
with:
3646
fetch-depth: 0
3747

38-
- name: Setup Node.js
48+
- name: Setup Node.js Mobile
49+
if: ${{ inputs.repo-type == 'mobile' }}
3950
uses: actions/setup-node@v4
4051
with:
4152
node-version: '18'
4253

54+
- name: Setup Node.js Extension
55+
if: ${{ inputs.repo-type == 'extension' }}
56+
uses: actions/setup-node@v4
57+
with:
58+
node-version: '22.15'
59+
60+
- name: Prepare Yarn
61+
if: ${{ inputs.repo-type == 'extension' }}
62+
run: corepack prepare yarn@4.5.1 --activate
63+
64+
- name: Prepare Yarn - Enable corepack
65+
if: ${{ inputs.repo-type == 'extension' }}
66+
run: corepack enable
67+
4368
- name: Check if PR exists
4469
id: check-pr
4570
uses: actions/github-script@v7
@@ -66,6 +91,7 @@ jobs:
6691
env:
6792
CREATE_BRANCH: 'false' # let the script handle the branch creation
6893
REPO: ${{ inputs.repo-type }} # Default to 'mobile' if not specified
94+
BASE_BRANCH: ${{ inputs.stable-branch-name }}
6995
run: |
7096
node .github/scripts/stable-sync.js "stable-main-${{ inputs.semver-version }}"
7197
# Check if branch exists remotely

0 commit comments

Comments
 (0)