Skip to content

Commit f506b7a

Browse files
committed
refactor(workflows): 优化构建流程和脚本命令
简化构建步骤,移除冗余操作,将cli命令从node执行改为tsx执行 分离lib和app的构建任务,并添加构建产物上传功能
1 parent 86180e7 commit f506b7a

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

.github/workflows/auto-update.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,24 @@ jobs:
7070
# echo "skip=false" >> $GITHUB_OUTPUT
7171
# fi
7272
73-
- name: Build project
73+
- name: Build Lib
7474
if: steps.check-update.outputs.skip != 'true'
75-
run: pnpm run build
75+
run: pnpm run build:lib
76+
77+
- name: Build UI
78+
if: steps.check-update.outputs.skip != 'true'
79+
run: pnpm run build:app --outDir dist/ui
80+
81+
- name: Upload build artifacts
82+
if: steps.check-update.outputs.skip != 'true'
83+
uses: actions/upload-artifact@v4
84+
with:
85+
name: usb-ids-build-${{ github.run_number }}
86+
path: |
87+
dist/
88+
usb.ids.json
89+
usb.ids.version.json
90+
retention-days: 30
7691

7792
- name: Update package.json version
7893
if: steps.check-update.outputs.skip != 'true'

.github/workflows/github-pages.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,14 @@ jobs:
4242
- name: Install dependencies
4343
run: pnpm install
4444

45-
- name: Generate USB.IDS data
46-
run: |
47-
pnpm run build
48-
node bin/cli.cjs update
45+
- name: Fetch USB IDs
46+
run: pnpm run fetch-usb-ids
4947

50-
- name: Build
51-
run: pnpm run build
48+
- name: Build Web App
49+
run: pnpm run build:app
5250
env:
5351
VITE_BASE_PATH: /usb.ids/
5452

55-
- name: Copy USB.IDS files to dist
56-
run: |
57-
cp usb.ids.json dist/usb.ids.json
58-
cp usb.ids.version.json dist/usb.ids.version.json
59-
cp usb.ids dist/usb.ids
60-
6153
- name: Setup Pages
6254
uses: actions/configure-pages@v5
6355
- name: Upload artifact

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@
4242
"scripts": {
4343
"preinstall": "npx only-allow pnpm",
4444
"dev:app": "vite",
45-
"build:app": "vite build --outDir dist/ui",
45+
"build:app": "vite build",
4646
"dev:lib": "tsdown --watch",
4747
"build:lib": "tsdown",
4848
"lint": "eslint",
4949
"lint:fix": "eslint --fix",
50-
"fetch-usb-ids": "node ./bin/cli.cjs fetch",
51-
"version-info": "node ./bin/cli.cjs version",
52-
"check-update": "node ./bin/cli.cjs check",
53-
"ui": "tsx src/cli.ts ui",
50+
"fetch-usb-ids": "tsx src/cli.ts fetch",
51+
"dev:ui": "tsx src/cli.ts ui",
5452
"release": "bumpp && pnpm publish",
5553
"start": "tsx src/index.ts",
5654
"test": "vitest run",

0 commit comments

Comments
 (0)