fix(ci): resolve pnpm version conflict in version bump workflow

Remove hardcoded version: 10 from pnpm/action-setup which conflicts
with packageManager in package.json on main. Instead, inject the
packageManager field into package.json when absent (legacy core/*
branches) so the action can resolve the version from it.

Fixes the 'Multiple versions of pnpm specified' error on main while
maintaining compatibility with older branches that lack packageManager.
This commit is contained in:
bymyself
2026-04-08 14:29:04 -07:00
parent 2189172f15
commit 160ef312d8

View File

@@ -142,10 +142,22 @@ jobs:
fi
echo "✅ Branch '$BRANCH' exists"
- name: Ensure packageManager field exists
run: |
if ! grep -q '"packageManager"' package.json; then
# Old branches (e.g. core/1.42) predate the packageManager field.
# Inject it so pnpm/action-setup can resolve the version.
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json','utf8'));
pkg.packageManager = 'pnpm@10.33.0';
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
echo "Injected packageManager into package.json for legacy branch"
fi
- name: Install pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v6