mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-19 05:05:44 +08:00
Refactor build and release workflows, update dependencies
Switch build scripts and workflows from npm to pnpm, update build and artifact paths, and simplify release workflow by removing version detection and changelog steps. Add new dependencies (silk-wasm, express, ws, node-pty-prebuilt-multiarch), update exports in package.json files, and add vite config for napcat-framework. Also, rename manifest.json for framework package and fix static asset copying in shell build config.
This commit is contained in:
parent
c9c6942564
commit
7c8e825eba
23
.github/workflows/build.yml
vendored
23
.github/workflows/build.yml
vendored
@ -1,6 +1,9 @@
|
|||||||
name: "Build Action"
|
name: "Build Action"
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
|
|
||||||
@ -16,14 +19,16 @@ jobs:
|
|||||||
node-version: 20.x
|
node-version: 20.x
|
||||||
- name: Build NapCat.Framework
|
- name: Build NapCat.Framework
|
||||||
run: |
|
run: |
|
||||||
npm i && cd napcat.webui && npm i && cd .. || exit 1
|
pnpm i
|
||||||
npm run build:framework && npm run depend || exit 1
|
pnpm --filter napcat-webui-frontend run build || exit 1
|
||||||
rm package-lock.json
|
pnpm run build:framework
|
||||||
|
cd packages/napcat-framework/dist
|
||||||
|
pnpm install --production
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: NapCat.Framework
|
name: NapCat.Framework
|
||||||
path: dist
|
path: packages/napcat-framework/dist
|
||||||
Build-Shell:
|
Build-Shell:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@ -35,11 +40,13 @@ jobs:
|
|||||||
node-version: 20.x
|
node-version: 20.x
|
||||||
- name: Build NapCat.Shell
|
- name: Build NapCat.Shell
|
||||||
run: |
|
run: |
|
||||||
npm i && cd napcat.webui && npm i && cd .. || exit 1
|
pnpm i
|
||||||
npm run build:shell && npm run depend || exit 1
|
pnpm --filter napcat-webui-frontend run build || exit 1
|
||||||
rm package-lock.json
|
pnpm run build:shell
|
||||||
|
cd packages/napcat-shell/dist
|
||||||
|
pnpm install --production
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: NapCat.Shell
|
name: NapCat.Shell
|
||||||
path: dist
|
path: packages/napcat-shell/dist
|
||||||
|
|||||||
109
.github/workflows/release.yml
vendored
109
.github/workflows/release.yml
vendored
@ -1,113 +1,59 @@
|
|||||||
name: "Build Release"
|
name: "Build Release"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_dispatch:
|
||||||
tags:
|
|
||||||
- "v*"
|
|
||||||
|
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-version:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Clone Repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: main
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Extract version from tag
|
|
||||||
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Use Node.js 20.X
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20.x
|
|
||||||
|
|
||||||
- name: Check Version
|
|
||||||
run: |
|
|
||||||
ls
|
|
||||||
node ./script/checkVersion.cjs
|
|
||||||
sh ./checkVersion.sh
|
|
||||||
Build-LiteLoader:
|
Build-LiteLoader:
|
||||||
needs: [check-version]
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Clone Main Repository
|
- name: Clone Main Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
repository: 'NapNeko/NapCatQQ'
|
|
||||||
submodules: true
|
|
||||||
ref: main
|
|
||||||
token: ${{ secrets.NAPCAT_BUILD }}
|
|
||||||
- name: Use Node.js 20.X
|
- name: Use Node.js 20.X
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 20.x
|
||||||
|
- name: Build NapCat.Framework
|
||||||
- name: Build NuCat Framework
|
|
||||||
run: |
|
run: |
|
||||||
npm i
|
pnpm i
|
||||||
cd napcat.webui
|
pnpm --filter napcat-webui-frontend run build || exit 1
|
||||||
npm i
|
pnpm run build:framework
|
||||||
cd ..
|
cd packages/napcat-framework/dist
|
||||||
npm run build:framework
|
pnpm install --production
|
||||||
cd dist
|
|
||||||
npm i --omit=dev
|
|
||||||
cd ..
|
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: NapCat.Framework
|
name: NapCat.Framework
|
||||||
path: dist
|
path: packages/napcat-framework/dist
|
||||||
|
|
||||||
Build-Shell:
|
Build-Shell:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [check-version]
|
|
||||||
steps:
|
steps:
|
||||||
- name: Clone Main Repository
|
- name: Clone Main Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
repository: 'NapNeko/NapCatQQ'
|
|
||||||
submodules: true
|
|
||||||
ref: main
|
|
||||||
token: ${{ secrets.NAPCAT_BUILD }}
|
|
||||||
|
|
||||||
- name: Use Node.js 20.X
|
- name: Use Node.js 20.X
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 20.x
|
||||||
|
- name: Build NapCat.Shell
|
||||||
- name: Build NuCat Shell
|
|
||||||
run: |
|
run: |
|
||||||
npm i
|
pnpm i
|
||||||
cd napcat.webui
|
pnpm --filter napcat-webui-frontend run build || exit 1
|
||||||
npm i
|
pnpm run build:shell
|
||||||
cd ..
|
cd packages/napcat-shell/dist
|
||||||
npm run build:shell
|
pnpm install --production
|
||||||
cd dist
|
|
||||||
npm i --omit=dev
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: NapCat.Shell
|
name: NapCat.Shell
|
||||||
path: dist
|
path: packages/napcat-shell/dist
|
||||||
|
|
||||||
release-napcat:
|
release-napcat:
|
||||||
needs: [Build-LiteLoader,Build-Shell]
|
needs: [Build-LiteLoader, Build-Shell]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Clone Main Repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: 'NapNeko/NapCatQQ'
|
|
||||||
submodules: true
|
|
||||||
ref: main
|
|
||||||
token: ${{ secrets.NAPCAT_BUILD }}
|
|
||||||
|
|
||||||
- name: Download All Artifact
|
- name: Download All Artifact
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
|
|
||||||
@ -123,31 +69,14 @@ jobs:
|
|||||||
rm ./NapCat.Framework.zip -rf
|
rm ./NapCat.Framework.zip -rf
|
||||||
mv ./NapCat.Shell/NapCat.Shell.zip ./
|
mv ./NapCat.Shell/NapCat.Shell.zip ./
|
||||||
mv ./NapCat.Framework/NapCat.Framework.zip ./
|
mv ./NapCat.Framework/NapCat.Framework.zip ./
|
||||||
- name: Extract version from tag
|
|
||||||
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Clone Changes Log
|
|
||||||
run: curl -o CHANGELOG.md https://fastly.jsdelivr.net/gh/NapNeko/NapCatQQ@main/docs/changelogs/CHANGELOG.v${{ env.VERSION }}.md
|
|
||||||
|
|
||||||
- name: Create Release Draft and Upload Artifacts
|
- name: Create Release Draft and Upload Artifacts
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
name: NapCat V${{ env.VERSION }}
|
name: NapCat
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
body_path: CHANGELOG.md
|
body: Automated release artifact (no version detection)
|
||||||
files: |
|
files: |
|
||||||
NapCat.Framework.zip
|
NapCat.Framework.zip
|
||||||
NapCat.Shell.zip
|
NapCat.Shell.zip
|
||||||
draft: true
|
draft: true
|
||||||
|
|
||||||
build-docker:
|
|
||||||
needs: release-napcat
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Dispatch Docker Build
|
|
||||||
run: |
|
|
||||||
curl -X POST \
|
|
||||||
-H "Authorization: Bearer ${{ secrets.NAPCAT_BUILD }}" \
|
|
||||||
-H "Accept: application/vnd.github.v3+json" \
|
|
||||||
https://api.github.com/repos/NapNeko/NapCat-Docker/actions/workflows/docker-publish.yml/dispatches \
|
|
||||||
-d '{"ref": "main"}'
|
|
||||||
|
|||||||
@ -5,7 +5,8 @@
|
|||||||
"version": "4.9.42",
|
"version": "4.9.42",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:shell": "pnpm --filter napcat-shell run build || exit 1",
|
"build:shell": "pnpm --filter napcat-shell run build || exit 1",
|
||||||
"build:webui": "pnpm --filter napcat-webui-frontend run build"
|
"build:framework": "pnpm --filter napcat-framework run build || exit 1",
|
||||||
|
"build:webui": "pnpm --filter napcat-webui-frontend run build || exit 1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-node-resolve": "^16.0.3",
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
||||||
@ -13,6 +14,8 @@
|
|||||||
"vite-plugin-cp": "^6.0.3"
|
"vite-plugin-cp": "^6.0.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@protobuf-ts/runtime": "^2.11.1"
|
"silk-wasm": "^3.6.1",
|
||||||
|
"express": "^5.0.0",
|
||||||
|
"ws": "^8.18.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,11 +4,14 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "index.ts",
|
"main": "index.ts",
|
||||||
|
"scripts": {
|
||||||
|
"build": "vite build"
|
||||||
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"import": "./index.ts"
|
"import": "./index.ts"
|
||||||
},
|
},
|
||||||
"./src/*": {
|
"./*": {
|
||||||
"import": "./*"
|
"import": "./*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
68
packages/napcat-framework/vite.config.ts
Normal file
68
packages/napcat-framework/vite.config.ts
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import cp from 'vite-plugin-cp';
|
||||||
|
import { defineConfig, PluginOption, UserConfig } from 'vite';
|
||||||
|
import path, { resolve } from 'path';
|
||||||
|
import nodeResolve from '@rollup/plugin-node-resolve';
|
||||||
|
import { builtinModules } from 'module';
|
||||||
|
//依赖排除
|
||||||
|
const external = [
|
||||||
|
'silk-wasm',
|
||||||
|
'ws',
|
||||||
|
'express'
|
||||||
|
];
|
||||||
|
const nodeModules = [...builtinModules, builtinModules.map((m) => `node:${m}`)].flat();
|
||||||
|
const FrameworkBaseConfigPlugin: PluginOption[] = [
|
||||||
|
cp({
|
||||||
|
targets: [
|
||||||
|
{ src: '../napcat-napi-loader/', dest: 'dist', flatten: true },
|
||||||
|
{ src: '../napcat-native/', dest: 'dist/native', flatten: false },
|
||||||
|
{ src: './manifest.json', dest: 'dist' },
|
||||||
|
{ src: '../napcat-core/external/napcat.json', dest: 'dist/config/' },
|
||||||
|
{ src: '../napcat-webui-frontend/dist/', dest: 'dist/static/', flatten: false },
|
||||||
|
{ src: './liteloader.cjs', dest: 'dist' },
|
||||||
|
{ src: './napcat.cjs', dest: 'dist' },
|
||||||
|
{ src: './nativeLoader.cjs', dest: 'dist' },
|
||||||
|
{ src: './preload.cjs', dest: 'dist' },
|
||||||
|
{ src: './renderer.js', dest: 'dist' },
|
||||||
|
{ src: '../../package.json', dest: 'dist' },
|
||||||
|
{ src: '../../logo.png', dest: 'dist' },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
nodeResolve(),
|
||||||
|
];
|
||||||
|
const FrameworkBaseConfig = () =>
|
||||||
|
defineConfig({
|
||||||
|
resolve: {
|
||||||
|
conditions: ['node', 'default'],
|
||||||
|
alias: {
|
||||||
|
'@/napcat-core': resolve(__dirname, '../napcat-core'),
|
||||||
|
'@/napcat-common': resolve(__dirname, '../napcat-common/src'),
|
||||||
|
'@/napcat-onebot': resolve(__dirname, '../napcat-onebot'),
|
||||||
|
'@/napcat-pty': resolve(__dirname, '../napcat-pty'),
|
||||||
|
'@/napcat-webui-backend': resolve(__dirname, '../napcat-webui-backend/src'),
|
||||||
|
'@/image-size': resolve(__dirname, '../image-size'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
build: {
|
||||||
|
sourcemap: false,
|
||||||
|
target: 'esnext',
|
||||||
|
minify: false,
|
||||||
|
lib: {
|
||||||
|
entry: {
|
||||||
|
napcat: path.resolve(__dirname, 'napcat.ts'),
|
||||||
|
'audio-worker': path.resolve(__dirname, '../napcat-common/src/audio-worker.ts'),
|
||||||
|
'worker/conoutSocketWorker': path.resolve(__dirname, '../napcat-pty/worker/conoutSocketWorker.ts'),
|
||||||
|
},
|
||||||
|
formats: ['es'],
|
||||||
|
fileName: (_, entryName) => `${entryName}.mjs`,
|
||||||
|
},
|
||||||
|
rollupOptions: {
|
||||||
|
external: [...nodeModules, ...external],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
export default defineConfig((): UserConfig => {
|
||||||
|
return {
|
||||||
|
...FrameworkBaseConfig(),
|
||||||
|
plugins: [...FrameworkBaseConfigPlugin],
|
||||||
|
};
|
||||||
|
});
|
||||||
@ -13,6 +13,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@homebridge/node-pty-prebuilt-multiarch":"^0.12.0",
|
||||||
"napcat-core": "workspace:*",
|
"napcat-core": "workspace:*",
|
||||||
"napcat-common": "workspace:*",
|
"napcat-common": "workspace:*",
|
||||||
"napcat-onebot": "workspace:*",
|
"napcat-onebot": "workspace:*",
|
||||||
|
|||||||
@ -7,6 +7,14 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "vite build"
|
"build": "vite build"
|
||||||
},
|
},
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"import": "./index.ts"
|
||||||
|
},
|
||||||
|
"./*": {
|
||||||
|
"import": "./*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"napcat-core": "workspace:*",
|
"napcat-core": "workspace:*",
|
||||||
"napcat-common": "workspace:*",
|
"napcat-common": "workspace:*",
|
||||||
|
|||||||
@ -16,7 +16,7 @@ const ShellBaseConfigPlugin: PluginOption[] = [
|
|||||||
{ src: '../napcat-native/', dest: 'dist/native', flatten: false },
|
{ src: '../napcat-native/', dest: 'dist/native', flatten: false },
|
||||||
{ src: '../napcat-webui-frontend/dist/', dest: 'dist/static/', flatten: false },
|
{ src: '../napcat-webui-frontend/dist/', dest: 'dist/static/', flatten: false },
|
||||||
{ src: '../napcat-core/external/napcat.json', dest: 'dist/config/' },
|
{ src: '../napcat-core/external/napcat.json', dest: 'dist/config/' },
|
||||||
{ src: './package.json', dest: 'dist' },
|
{ src: '../../package.json', dest: 'dist' },
|
||||||
{ src: '../napcat-shell-loader', dest: 'dist' }
|
{ src: '../napcat-shell-loader', dest: 'dist' }
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user