Skip to content

Commit 6bf95c1

Browse files
committed
refactor: packer
1 parent 2c30075 commit 6bf95c1

18 files changed

Lines changed: 144 additions & 1673 deletions

File tree

.github/workflows/dev.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,22 @@ jobs:
7070
- name: Install dependencies
7171
run: pnpm i --frozen-lockfile
7272
- name: Get snapshot version
73+
uses: FirefoxBar/extension-packer@action
74+
with:
75+
script: ${{ github.workspace }}/scripts/get-snapshot-version.mjs
7376
env:
7477
TOKEN: ${{ secrets.ORG_EXT_API_TOKEN }}
7578
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76-
run: node ./scripts/get-snapshot-version.mjs
7779
- name: Build
7880
uses: ./.github/actions/build
7981
- name: Publish snapshot
82+
uses: FirefoxBar/extension-packer@action
83+
with:
84+
script: ${{ github.workspace }}/scripts/pack.mjs
8085
env:
8186
AMO_KEY: ${{ secrets.ORG_AMO_KEY }}
8287
AMO_SECRET: ${{ secrets.ORG_AMO_SECRET }}
8388
PACK_PLATFORM: xpi
84-
run: npm run pack
8589
- name: Upload snapshot release
8690
uses: actions/upload-artifact@v4
8791
with:

.github/workflows/release.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ jobs:
4646
- name: Build
4747
uses: ./.github/actions/build
4848
- name: Pack
49+
uses: FirefoxBar/extension-packer@action
50+
with:
51+
script: ${{ github.workspace }}/scripts/pack.mjs
4952
env:
5053
AMO_KEY: ${{ secrets.ORG_AMO_KEY }}
5154
AMO_SECRET: ${{ secrets.ORG_AMO_SECRET }}
@@ -54,8 +57,6 @@ jobs:
5457
CWS_TOKEN: ${{ secrets.ORG_CWS_TOKEN }}
5558
MS_CLIENT_ID: ${{ secrets.ORG_MS_CLIENT_ID }}
5659
MS_API_KEY: ${{ secrets.ORG_MS_API_KEY }}
57-
DEBUG: '*'
58-
run: npm run pack
5960
- name: Upload release
6061
uses: actions/upload-artifact@v4
6162
with:
@@ -64,8 +65,10 @@ jobs:
6465
path: temp/release
6566
- name: Release
6667
if: ${{ github.ref_type == 'tag' || github.event.inputs.release_tag != '' }}
68+
uses: FirefoxBar/extension-packer@action
69+
with:
70+
script: ${{ github.workspace }}/scripts/release.mjs
6771
env:
6872
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6973
TOKEN: ${{ secrets.ORG_EXT_API_TOKEN }}
7074
INPUT_RELEASE_TAG: ${{ github.event.inputs.release_tag }}
71-
run: npm run release

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 & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"@douyinfe/semi-icons": "^2.91.0",
2828
"@douyinfe/semi-ui": "^2.91.0",
2929
"acorn": "^8.14.0",
30-
"acron": "^1.0.5",
3130
"ahooks": "^3.7.5",
3231
"dayjs": "^1.9.5",
3332
"dayjs-plugin-lunar": "^1.4.1",
@@ -44,8 +43,6 @@
4443
"devDependencies": {
4544
"@biomejs/biome": "^2.1.2",
4645
"@modern-js/tsconfig": "^2.68.5",
47-
"@plasmohq/chrome-webstore-api": "^2.11.0",
48-
"@plasmohq/edge-addons-api": "^2.0.0",
4946
"@rsbuild/core": "^1.4.11",
5047
"@rsbuild/plugin-less": "^1.6.0",
5148
"@rsbuild/plugin-react": "^1.3.4",
@@ -55,13 +52,9 @@
5552
"@types/node": "^18.15.5",
5653
"@types/react": "^18.3.1",
5754
"@types/react-dom": "^18.3.1",
58-
"amo-upload": "^1.1.0",
59-
"axios": "^1.7.2",
60-
"cpr": "^3.0.1",
6155
"cross-env": "^7.0.3",
6256
"lint-staged": "^13.2.2",
6357
"lodash": "^4.17.21",
64-
"rimraf": "^6.0.1",
6558
"simple-git-hooks": "^2.13.0",
6659
"typescript": "^5.7.3"
6760
},

0 commit comments

Comments
 (0)