mirror of
https://github.com/mcp-use/mcp-use.git
synced 2026-09-14 18:06:01 +08:00
e649639d5d
- Adjusted the GitHub Actions workflow to conditionally set up pnpm only for pnpm repositories, preventing errors related to multiple version specifications. - Simplified the Node.js setup process by ensuring it is always configured, enhancing the reliability of the CI pipeline.
94 lines
3.1 KiB
YAML
94 lines
3.1 KiB
YAML
name: Bump mcp-use (reusable)
|
|
|
|
on:
|
|
workflow_call:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
bump:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Resolve npm stable mcp-use version
|
|
id: target
|
|
run: |
|
|
TARGET="$(npm view mcp-use version)"
|
|
echo "version=$TARGET" >> "$GITHUB_OUTPUT"
|
|
echo "caret=^${TARGET}" >> "$GITHUB_OUTPUT"
|
|
echo "Target mcp-use: $TARGET (^${TARGET})"
|
|
|
|
- name: Detect package manager
|
|
id: pm
|
|
run: |
|
|
if [ -f pnpm-lock.yaml ] || grep -q '"packageManager".*pnpm' package.json 2>/dev/null; then
|
|
echo "pm=pnpm" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "pm=npm" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
# Only for pnpm repos, and no `version:` on purpose: consumer repos pin
|
|
# pnpm via the `packageManager` field in package.json. Passing `version`
|
|
# too makes pnpm/action-setup@v4 abort with ERR_PNPM_BAD_PM_VERSION
|
|
# ("Multiple versions of pnpm specified") — the failure this fixes. Gating
|
|
# on pm==pnpm also stops the step erroring on npm-only repos (no version
|
|
# and no packageManager to fall back to).
|
|
- name: Setup pnpm
|
|
if: steps.pm.outputs.pm == 'pnpm'
|
|
uses: pnpm/action-setup@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
|
|
- name: Bump, install, and build
|
|
id: bump
|
|
env:
|
|
TARGET: ${{ steps.target.outputs.version }}
|
|
CARET: ${{ steps.target.outputs.caret }}
|
|
run: |
|
|
set -e
|
|
CURRENT="$(node -p "require('./package.json').dependencies?.['mcp-use'] ?? require('./package.json').devDependencies?.['mcp-use'] ?? ''")"
|
|
echo "Current specifier: ${CURRENT:-<none>}"
|
|
|
|
rm -rf node_modules
|
|
node -e "
|
|
const fs = require('fs');
|
|
const p = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
p.dependencies = p.dependencies || {};
|
|
p.dependencies['mcp-use'] = process.env.CARET;
|
|
fs.writeFileSync('package.json', JSON.stringify(p, null, 2) + '\n');
|
|
"
|
|
|
|
if [ "${{ steps.pm.outputs.pm }}" = "pnpm" ]; then
|
|
corepack enable
|
|
pnpm install --no-frozen-lockfile
|
|
pnpm run build
|
|
else
|
|
npm install
|
|
npm run build
|
|
fi
|
|
|
|
INSTALLED="$(node -p "require('./node_modules/mcp-use/package.json').version")"
|
|
echo "Installed mcp-use@${INSTALLED}"
|
|
|
|
- name: Commit and push
|
|
env:
|
|
TARGET: ${{ steps.target.outputs.version }}
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add package.json
|
|
[ -f pnpm-lock.yaml ] && git add pnpm-lock.yaml
|
|
[ -f package-lock.json ] && git add package-lock.json
|
|
if git diff --cached --quiet; then
|
|
echo "No changes to commit (already on mcp-use ${TARGET})."
|
|
exit 0
|
|
fi
|
|
git commit -m "chore(deps): bump mcp-use to ${TARGET}"
|
|
git push
|