Skip to content

Commit 0920175

Browse files
committed
refactor: use workflow packer
1 parent 1488fa2 commit 0920175

20 files changed

Lines changed: 136 additions & 1628 deletions

File tree

.github/workflows/dev.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ jobs:
6262
echo "INPUT_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
6363
- uses: pnpm/action-setup@v6
6464
with:
65-
cache: true
6665
version: 11
6766
- name: Setup Node.js
6867
uses: actions/setup-node@v6
@@ -72,20 +71,23 @@ jobs:
7271
- name: Install dependencies
7372
run: pnpm i --frozen-lockfile
7473
- name: Get snapshot version
74+
uses: FirefoxBar/extension-packer@action
75+
with:
76+
script: ${{ github.workspace }}/scripts/get-snapshot-version.mjs
7577
env:
7678
TOKEN: ${{ secrets.SNAPSHOT_TOKEN }}
7779
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78-
run: node ./scripts/get-snapshot-version.mjs
7980
- name: Build And Test
8081
uses: ./.github/actions/build-and-test
8182
- name: Publish snapshot
83+
uses: FirefoxBar/extension-packer@action
84+
with:
85+
script: ${{ github.workspace }}/scripts/pack.mjs
8286
env:
8387
AMO_KEY: ${{ secrets.ORG_AMO_KEY }}
8488
AMO_SECRET: ${{ secrets.ORG_AMO_SECRET }}
8589
CRX_PRIV_KEY: ${{ secrets.CRX_PRIV_KEY }}
8690
PACK_PLATFORM: xpi,crx
87-
DEBUG: '*'
88-
run: npm run pack
8991
- name: Upload snapshot release
9092
uses: actions/upload-artifact@v4
9193
with:
@@ -121,7 +123,6 @@ jobs:
121123
- uses: actions/checkout@v6
122124
- uses: pnpm/action-setup@v6
123125
with:
124-
cache: true
125126
version: 11
126127
- name: Setup Node.js
127128
uses: actions/setup-node@v6

.github/workflows/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ jobs:
3434
- uses: actions/checkout@v6
3535
- uses: pnpm/action-setup@v6
3636
with:
37-
cache: true
3837
version: 11
3938
- name: Setup Node.js
4039
uses: actions/setup-node@v6

.github/workflows/release.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ jobs:
3535
echo "INPUT_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
3636
- uses: pnpm/action-setup@v6
3737
with:
38-
cache: true
3938
version: 11
4039
- name: Setup Node.js
4140
uses: actions/setup-node@v6
@@ -47,6 +46,9 @@ jobs:
4746
- name: Build And Test
4847
uses: ./.github/actions/build-and-test
4948
- name: Pack
49+
uses: FirefoxBar/extension-packer@action
50+
with:
51+
script: ${{ github.workspace }}/scripts/pack.mjs
5052
env:
5153
AMO_KEY: ${{ secrets.ORG_AMO_KEY }}
5254
AMO_SECRET: ${{ secrets.ORG_AMO_SECRET }}
@@ -57,8 +59,6 @@ jobs:
5759
CWS_TOKEN: ${{ secrets.ORG_CWS_TOKEN }}
5860
MS_CLIENT_ID: ${{ secrets.ORG_MS_CLIENT_ID }}
5961
MS_API_KEY: ${{ secrets.ORG_MS_API_KEY }}
60-
DEBUG: '*'
61-
run: npm run pack
6262
- name: Upload release
6363
uses: actions/upload-artifact@v4
6464
with:
@@ -67,8 +67,10 @@ jobs:
6767
path: temp/release
6868
- name: Release
6969
if: ${{ github.ref_type == 'tag' || github.event.inputs.release_tag != '' }}
70+
uses: FirefoxBar/extension-packer@action
71+
with:
72+
script: ${{ github.workspace }}/scripts/release.mjs
7073
env:
7174
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7275
TOKEN: ${{ secrets.SNAPSHOT_TOKEN }}
7376
INPUT_RELEASE_TAG: ${{ github.event.inputs.release_tag }}
74-
run: npm run release

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ Please note that some languages (such as zh-Hans) will not be translated on tran
7474
#### Development
7575

7676
* Modify `start` command's `TARGET_BROWSER` to the version you want to build
77-
7877
* Run `npm run start`
79-
8078
* Open browser, load extension from `/dist_*` directory or `/dist_*/manifest.json`
8179

8280
## Licenses

locale/create-pr.js

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,49 @@
1-
const axios = require('axios');
2-
3-
const token = process.env.GITHUB_TOKEN;
4-
5-
const baseURL =
6-
process.env.GITHUB_API_URL + '/repos/' + process.env.GITHUB_REPOSITORY;
7-
const request = axios.create({
8-
baseURL: baseURL,
9-
validateStatus: () => true,
10-
});
11-
12-
request.defaults.headers.common['Accept'] = 'application/vnd.github+json';
13-
request.defaults.headers.common['Authorization'] = 'Bearer ' + token;
14-
request.defaults.headers.common['X-GitHub-Api-Version'] = '2022-11-28';
15-
161
async function main() {
17-
if (!token) {
18-
console.log('No token');
2+
if (!process.env.GITHUB_TOKEN) {
3+
console.log('No GITHUB_TOKEN');
194
return;
205
}
216

7+
const baseURL = `${process.env.GITHUB_API_URL}/repos/${process.env.GITHUB_REPOSITORY}`;
8+
9+
const apiHeader = {
10+
Accept: 'application/vnd.github+json',
11+
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
12+
'X-GitHub-Api-Version': '2022-11-28',
13+
'Content-Type': 'application/json',
14+
};
15+
2216
console.log('baseURL: ' + baseURL);
2317

24-
const pulls = await request.get('/pulls', {
25-
params: {
26-
state: 'open',
27-
head: 'dev-locale',
28-
base: 'dev',
18+
const pulls = await fetch(
19+
`${baseURL}/pulls?state=open&head=dev-locale&base=dev`,
20+
{
21+
headers: apiHeader,
2922
},
30-
});
23+
);
3124

32-
if (pulls.data.length > 0) {
25+
const data = await pulls.json();
26+
if (data.length > 0) {
3327
// already has PR
34-
const item = pulls.data[0];
28+
const item = data[0];
3529
console.log('PR already exists: ' + item.html_url);
3630
return;
3731
}
3832

3933
// Create new PR
40-
const create = await request.post(
41-
'/pulls',
42-
JSON.stringify({
34+
const create = await fetch(`${baseURL}/pulls`, {
35+
method: 'POST',
36+
body: JSON.stringify({
4337
title: 'locale: update locales',
4438
body: '',
4539
head: 'dev-locale',
4640
base: 'dev',
4741
}),
48-
);
42+
headers: apiHeader,
43+
});
4944

5045
if (create.status === 201) {
51-
console.log('PR created: ' + create.data.html_url);
46+
console.log(`PR created: ${(await create.json()).html_url}`);
5247
} else {
5348
console.log('PR created failed: ' + create.status);
5449
}

package.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
"build:chrome_v3": "cross-env TARGET_BROWSER=chrome_v3 rsbuild build",
1818
"check": "biome check --write",
1919
"format": "biome format --write",
20-
"release": "node ./scripts/release.mjs",
21-
"pack": "node ./scripts/pack.mjs",
2220
"run-test-server": "php -S 0.0.0.0:8899 -t tests/simple-server",
2321
"test:e2e": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx mocha --config ./tests/e2e/.mocharc.json"
2422
},
@@ -43,8 +41,6 @@
4341
"devDependencies": {
4442
"@biomejs/biome": "^2.1.2",
4543
"@modern-js/tsconfig": "^2.68.5",
46-
"@plasmohq/chrome-webstore-api": "^2.11.0",
47-
"@plasmohq/edge-addons-api": "^2.0.0",
4844
"@rsbuild/core": "^1.4.11",
4945
"@rsbuild/plugin-react": "^1.3.4",
5046
"@swc/plugin-emotion": "^11.0.0",
@@ -54,11 +50,7 @@
5450
"@types/react": "^18.3.1",
5551
"@types/react-dom": "^18.3.1",
5652
"@types/webextension-polyfill": "^0.12.3",
57-
"amo-upload": "^1.1.0",
58-
"axios": "^1.7.2",
59-
"cpr": "^3.0.1",
6053
"cross-env": "^7.0.3",
61-
"crx": "^5.0.1",
6254
"get-port": "^7.1.0",
6355
"lint-staged": "^13.2.2",
6456
"lodash": "^4.17.21",

0 commit comments

Comments
 (0)