feat(cli): add dbx node packages

This commit is contained in:
t8y2
2026-05-18 00:53:06 +08:00
parent 19f7cbd2ba
commit 1917c0855b
47 changed files with 2643 additions and 4959 deletions
+14 -8
View File
@@ -15,15 +15,20 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22.13.0
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
version: 10.27.0
- name: Install system dependencies (Linux)
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libssl-dev libsecret-1-dev
- name: Install frontend dependencies
run: pnpm install
run: pnpm install --frozen-lockfile
- name: Frontend format check
run: npx oxfmt --check "src/**/*.{ts,vue}"
@@ -34,6 +39,12 @@ jobs:
- name: Frontend tests
run: pnpm test:coverage
- name: Node package tests
run: pnpm test:packages
- name: Node package publish dry run
run: pnpm publish:dry-run
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
@@ -56,11 +67,6 @@ jobs:
workspaces: './ -> target'
shared-key: ci-x86_64-unknown-linux-gnu
- name: Install system dependencies (Linux)
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libssl-dev
- name: Cargo fmt check
run: cargo fmt --check
+67 -85
View File
@@ -1,18 +1,11 @@
name: MCP Release
name: Node Packages Release
on:
workflow_dispatch:
push:
branches: [main]
paths:
- 'mcp/src/**'
- 'mcp/tests/**'
- 'mcp/package.json'
- 'mcp/package-lock.json'
- 'mcp/pnpm-lock.yaml'
- 'mcp/pnpm-workspace.yaml'
- 'mcp/tsconfig.json'
- 'mcp/server.json'
inputs:
version:
description: "Package version to publish, for example 0.4.3"
required: true
permissions:
contents: write
@@ -20,9 +13,8 @@ permissions:
jobs:
publish:
name: Bump patch and publish MCP server
name: Publish CLI and MCP packages
runs-on: ubuntu-latest
if: github.actor != 'github-actions[bot]' && (github.event_name == 'workflow_dispatch' || !contains(github.event.head_commit.message, '[skip mcp-release]'))
steps:
- uses: actions/checkout@v4
@@ -32,31 +24,22 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
version: 10.27.0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
node-version: 22.13.0
registry-url: https://registry.npmjs.org
cache: pnpm
cache-dependency-path: mcp/pnpm-lock.yaml
cache-dependency-path: pnpm-lock.yaml
- name: Check npm token
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
if [ -z "${NODE_AUTH_TOKEN}" ]; then
echo "::error::NPM_TOKEN secret is required to publish @dbx-app/mcp-server."
exit 1
fi
- name: Check release token
env:
RELEASE_TOKEN: ${{ secrets.MCP_RELEASE_TOKEN }}
run: |
if [ -z "${RELEASE_TOKEN}" ]; then
echo "::error::MCP_RELEASE_TOKEN secret is required to push the MCP release commit and tag."
echo "::error::NPM_TOKEN secret is required to publish DBX Node packages."
exit 1
fi
@@ -66,99 +49,98 @@ jobs:
sudo apt-get install -y libsecret-1-dev
- name: Install dependencies
working-directory: mcp
run: pnpm install --frozen-lockfile
- name: Run MCP tests
working-directory: mcp
run: pnpm test
- name: Build MCP server
working-directory: mcp
run: pnpm build
- name: Bump MCP patch version
- name: Set package versions
id: version
env:
VERSION: ${{ github.event.inputs.version }}
run: |
node <<'NODE'
const fs = require('fs');
const fs = require("fs");
const readJson = (path) => JSON.parse(fs.readFileSync(path, 'utf8'));
const writeJson = (path, data) => {
fs.writeFileSync(path, `${JSON.stringify(data, null, 2)}\n`);
};
const packagePath = 'mcp/package.json';
const packageLockPath = 'mcp/package-lock.json';
const serverPath = 'mcp/server.json';
const pkg = readJson(packagePath);
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(pkg.version);
if (!match) {
throw new Error(`Unsupported MCP package version: ${pkg.version}`);
const version = process.env.VERSION.trim();
if (!/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/.test(version)) {
throw new Error(`Invalid semver version: ${version}`);
}
const nextVersion = `${match[1]}.${match[2]}.${Number(match[3]) + 1}`;
pkg.version = nextVersion;
writeJson(packagePath, pkg);
const readJson = (path) => JSON.parse(fs.readFileSync(path, "utf8"));
const writeJson = (path, data) => fs.writeFileSync(path, `${JSON.stringify(data, null, 2)}\n`);
if (fs.existsSync(packageLockPath)) {
const packageLock = readJson(packageLockPath);
packageLock.version = nextVersion;
if (packageLock.packages?.['']) {
packageLock.packages[''].version = nextVersion;
}
writeJson(packageLockPath, packageLock);
for (const path of [
"packages/node-core/package.json",
"packages/cli/package.json",
"packages/mcp-server/package.json",
]) {
const pkg = readJson(path);
pkg.version = version;
writeJson(path, pkg);
}
const serverPath = "packages/mcp-server/server.json";
const server = readJson(serverPath);
server.version = nextVersion;
server.version = version;
for (const packageInfo of server.packages ?? []) {
if (packageInfo.registryType === 'npm' && packageInfo.identifier === pkg.name) {
packageInfo.version = nextVersion;
if (packageInfo.registryType === "npm" && packageInfo.identifier === "@dbx-app/mcp-server") {
packageInfo.version = version;
}
}
writeJson(serverPath, server);
fs.appendFileSync(process.env.GITHUB_OUTPUT, `version=${nextVersion}\n`);
fs.appendFileSync(process.env.GITHUB_OUTPUT, `version=${version}\n`);
NODE
- name: Check npm version is new
working-directory: mcp
- name: Check npm versions are new
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
VERSION="${{ steps.version.outputs.version }}"
if npm view "@dbx-app/mcp-server@${VERSION}" version >/dev/null 2>&1; then
echo "::error::@dbx-app/mcp-server@${VERSION} already exists on npm."
exit 1
fi
for PACKAGE in @dbx-app/node-core @dbx-app/cli @dbx-app/mcp-server; do
if npm view "${PACKAGE}@${VERSION}" version >/dev/null 2>&1; then
echo "::error::${PACKAGE}@${VERSION} already exists on npm."
exit 1
fi
done
- name: Pack MCP package
working-directory: mcp
run: npm pack --dry-run
- name: Run package tests
run: pnpm test:packages
- name: Build and pack packages
run: pnpm publish:dry-run
- name: Configure git author
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Commit MCP release version
- name: Commit package release version
run: |
VERSION="${{ steps.version.outputs.version }}"
git add mcp/package.json mcp/package-lock.json mcp/server.json
git commit -m "chore(mcp): release ${VERSION} [skip mcp-release]"
git tag "mcp-v${VERSION}"
git add packages/node-core/package.json packages/cli/package.json packages/mcp-server/package.json packages/mcp-server/server.json
git commit -m "chore(packages): release ${VERSION} [skip node-packages-release]"
git tag "packages-v${VERSION}"
- name: Push MCP release commit and tag
- name: Push package release commit and tag
env:
RELEASE_TOKEN: ${{ secrets.MCP_RELEASE_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
git remote set-url origin "https://x-access-token:${RELEASE_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
if [ -n "${RELEASE_TOKEN}" ]; then
git remote set-url origin "https://x-access-token:${RELEASE_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
fi
git push origin HEAD:main
git push origin "mcp-v${VERSION}"
git push origin "packages-v${VERSION}"
- name: Publish MCP package to npm
working-directory: mcp
- name: Publish Node core
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public --provenance
run: pnpm --filter @dbx-app/node-core publish --access public --provenance --no-git-checks
- name: Publish CLI
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm --filter @dbx-app/cli publish --access public --provenance --no-git-checks
- name: Publish MCP server
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm --filter @dbx-app/mcp-server publish --access public --provenance --no-git-checks