Skip to content

Commit 47395bf

Browse files
authored
chore: New upstream fetch script, p=#11253, c=workflows, scripts
* chore: New upstream fetch script, b=no-bug, c=workflows, scripts Signed-off-by: mr. m <[email protected]> --------- Signed-off-by: mr. m <[email protected]>
1 parent 5bd0a01 commit 47395bf

File tree

5 files changed

+97
-13
lines changed

5 files changed

+97
-13
lines changed

.github/workflows/check-candidate-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
steps:
1616
- name: Check out repository
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v3
1818

1919
- name: Check for any updates
2020
env:

.github/workflows/pr-test.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@ jobs:
2121
with:
2222
node-version-file: '.nvmrc'
2323

24-
- name: Install Surfer
25-
run: npm i -g @zen-browser/surfer
26-
2724
- name: Install dependencies
2825
run: npm ci
2926

3027
- name: Download Firefox and dependencies
31-
run: surfer download
28+
run: npm run download
3229

3330
- name: Import patches
34-
run: surfer i
31+
run: npm run import
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Sync Upstream Firefox Releases
2+
3+
on:
4+
schedule:
5+
- cron: '59 4 * * 2'
6+
workflow_dispatch:
7+
inputs:
8+
release_candidate:
9+
description: 'Set to true to sync release candidates'
10+
required: false
11+
default: 'false'
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
check_candidates:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Check out repository
22+
uses: actions/checkout@v3
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version-file: '.nvmrc'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Sync Upstream Releases
33+
run: |
34+
if [ "${{ github.event.inputs.release_candidate }}" = "true" ]; then
35+
npm run sync:rc
36+
else
37+
npm run sync
38+
fi
39+
40+
- name: Check if any files changed
41+
id: git-check
42+
run: |
43+
if [ -n "$(git status --porcelain)" ]; then
44+
echo "files_changed=true" >> $GITHUB_OUTPUT
45+
else
46+
echo "files_changed=false" >> $GITHUB_OUTPUT
47+
fi
48+
49+
- name: Get Firefox Version
50+
id: build-data
51+
if: steps.git-check.outputs.files_changed == 'true'
52+
run: |
53+
if [ "${{ github.event.inputs.release_candidate }}" = "true" ]; then
54+
VERSION=$(node -pe "require('./surfer.json').version.candidate")
55+
else
56+
VERSION=$(node -pe "require('./surfer.json').version.version")
57+
fi
58+
echo "version=$VERSION" >> $GITHUB_OUTPUT
59+
60+
- name: Check if patches got applied
61+
if: steps.git-check.outputs.files_changed == 'true'
62+
id: check-patches
63+
continue-on-error: true
64+
run: |
65+
echo "Checking if patches apply cleanly..."
66+
npm run import
67+
68+
- name: Create pull request
69+
uses: peter-evans/create-pull-request@v7
70+
if: steps.git-check.outputs.files_changed == 'true'
71+
env:
72+
GIT_TRACE: 1
73+
GIT_CURL_VERBOSE: 1
74+
with:
75+
token: ${{ secrets.DEPLOY_KEY }}
76+
commit-message: 'chore: Sync upstream to `Firefox ${{ steps.build-data.outputs.version }}`'
77+
branch: 'chore/sync-upstream-${{ steps.build-data.outputs.version }}'
78+
title: 'Sync upstream Firefox to version ${{ steps.build-data.outputs.version }}'
79+
body: |
80+
This PR syncs the upstream Firefox to version ${{ steps.build-data.outputs.version }}.
81+
82+
* ${{ steps.check-patches.outcome == 'failure' && '⚠️ Some patches did not apply cleanly. Please review them carefully.' || '✅ All patches applied cleanly.' }}
83+
84+
@${{ github.actor }} please review and merge this PR.
85+
base: dev
86+
git-token: ${{ secrets.DEPLOY_KEY }}
87+
delete-branch: true

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"download": "surfer download",
1717
"bootstrap": "surfer bootstrap",
1818
"package": "surfer package",
19-
"update-ff": "python3 scripts/update_ff.py",
20-
"update-ff:raw": "surfer update",
21-
"update-ff:rc": "python3 scripts/update_ff.py --rc",
22-
"update-ff:l10n": "python3 scripts/update_ff.py --just-l10n",
19+
"sync": "python3 scripts/update_ff.py",
20+
"sync:raw": "surfer update",
21+
"sync:rc": "python3 scripts/update_ff.py --rc",
22+
"sync:l10n": "python3 scripts/update_ff.py --just-l10n",
2323
"pretty": "prettier . --write --cache && autopep8 -r --in-place scripts/ src/",
2424
"lint": "npx eslint src/ && prettier . --check --cache",
2525
"lint:fix": "npm run pretty && npx eslint src/ --fix",

scripts/update_ff.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ def update_rc(last_version: str):
2929

3030

3131
def update_ff(is_rc: bool = False, last_version: str = ""):
32-
"""Runs the npm command to update the 'ff' component."""
32+
"""Runs the npm command to sync Firefox."""
3333
if is_rc:
3434
return update_rc(last_version)
35-
result = os.system("npm run update-ff:raw")
35+
result = os.system("npm run sync:raw")
3636
if result != 0:
37-
raise RuntimeError("Failed to update 'ff' component.")
37+
raise RuntimeError("Failed to sync Firefox.")
3838

3939

4040
def get_version_from_file(filename, is_rc):

0 commit comments

Comments
 (0)