ci: handle packageManager field in plugin-ci to avoid pnpm version conflict
pnpm/action-setup@v4 errors when both the `version` input and a `packageManager` field in package.json are specified. Detect the packageManager field during the package-manager detection step and conditionally omit `version: latest` when it is present. Fixes CI failures on repos using Corepack-style pnpm version pinning (e.g. headlamp-polaris-plugin PR #103). Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -23,12 +23,24 @@ jobs:
|
||||
run: |
|
||||
if [ -f "pnpm-lock.yaml" ]; then
|
||||
echo "manager=pnpm" >> $GITHUB_OUTPUT
|
||||
# Check for packageManager field in package.json (Corepack pinning).
|
||||
# pnpm/action-setup@v4 errors if both `version` input and `packageManager`
|
||||
# are set, so we detect here and use two conditional steps below.
|
||||
PM=$(node -e "try{const p=require('./package.json');const v=p.packageManager||'';console.log(v.startsWith('pnpm@')?'true':'false')}catch(e){console.log('false')}" 2>/dev/null || echo "false")
|
||||
echo "has_package_manager=$PM" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "manager=npm" >> $GITHUB_OUTPUT
|
||||
echo "has_package_manager=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Setup pnpm
|
||||
if: steps.pkg-manager.outputs.manager == 'pnpm'
|
||||
- name: Setup pnpm (version from packageManager field)
|
||||
if: steps.pkg-manager.outputs.manager == 'pnpm' && steps.pkg-manager.outputs.has_package_manager == 'true'
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
run_install: false
|
||||
|
||||
- name: Setup pnpm (version latest)
|
||||
if: steps.pkg-manager.outputs.manager == 'pnpm' && steps.pkg-manager.outputs.has_package_manager == 'false'
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
run_install: false
|
||||
|
||||
Reference in New Issue
Block a user