From a5c19aae8d1034f49cf26fdd06ee8a513919cb27 Mon Sep 17 00:00:00 2001 From: Hugh Hackman Date: Sun, 22 Mar 2026 05:41:30 +0000 Subject: [PATCH] fix(ci): use Corepack for pnpm setup when packageManager field is set pnpm/action-setup@v4 errors with "Multiple versions of pnpm specified" even when no explicit version input is provided, if the repo has a packageManager field in package.json. Switch to Corepack for repos that pin their pnpm version via the packageManager field. Corepack reads the version from package.json directly and installs it without conflicting with pnpm/action-setup. Repos without a packageManager field continue using pnpm/action-setup@v4 with version: latest (unchanged behavior). Unblocks headlamp-polaris-plugin PR #103 (ci/pin-pnpm-version). Co-Authored-By: Paperclip --- .github/workflows/plugin-ci.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/plugin-ci.yaml b/.github/workflows/plugin-ci.yaml index 8cbe837..07013b4 100644 --- a/.github/workflows/plugin-ci.yaml +++ b/.github/workflows/plugin-ci.yaml @@ -24,8 +24,8 @@ jobs: 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. + # pnpm/action-setup@v4 errors when `packageManager` is set (even without + # a `version` input), so we use Corepack directly for those repos. 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 @@ -33,11 +33,11 @@ jobs: echo "has_package_manager=false" >> $GITHUB_OUTPUT fi - - name: Setup pnpm (version from packageManager field) + - name: Setup pnpm (via Corepack, reads 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 + run: | + corepack enable pnpm + corepack install - name: Setup pnpm (version latest) if: steps.pkg-manager.outputs.manager == 'pnpm' && steps.pkg-manager.outputs.has_package_manager == 'false'