feat(node): let a caller pin the pnpm version

A repo with no packageManager field got the newest pnpm through Corepack.
Several repos pin pnpm in their own workflows instead. Add a pnpm-version
input to node-pr and renovate-autoupdate and activate it with corepack.
This commit is contained in:
2026-10-03 21:05:05 +01:00
parent b06a5bb1b1
commit f854725a97
3 changed files with 20 additions and 0 deletions
+9
View File
@@ -21,6 +21,11 @@ on:
required: false
type: string
default: "lint,typecheck,test,build"
pnpm-version:
description: "pnpm version to use, for a repo whose package.json has no packageManager field. Empty uses the packageManager field, or the newest pnpm."
required: false
type: string
default: ""
require-tests:
description: "Fail when package.json has no test script"
required: false
@@ -119,6 +124,7 @@ jobs:
working-directory: ${{ inputs.working-directory }}
env:
PM: ${{ steps.detect.outputs.pm }}
PNPM_VERSION: ${{ inputs.pnpm-version }}
run: |
# Install without updating the lockfile, so a lockfile that does not match package.json fails.
case "$PM" in
@@ -127,6 +133,9 @@ jobs:
corepack enable "$PM"
;;
esac
if [ "$PM" = pnpm ] && [ -n "$PNPM_VERSION" ]; then
corepack prepare "pnpm@$PNPM_VERSION" --activate
fi
case "$PM" in
pnpm) pnpm install --frozen-lockfile ;;
yarn) yarn install --immutable ;;
@@ -43,6 +43,11 @@ on:
required: false
type: string
default: "lint,typecheck,test,build"
pnpm-version:
description: "pnpm version to use, for a repo whose package.json has no packageManager field. Empty uses the packageManager field, or the newest pnpm."
required: false
type: string
default: ""
require-node-tests:
description: "Fail when a Node project has no test script, so an untested update never merges"
required: false
@@ -331,6 +336,7 @@ jobs:
working-directory: ${{ inputs.node-working-directory }}
env:
PM: ${{ steps.detect.outputs.pm }}
PNPM_VERSION: ${{ inputs.pnpm-version }}
run: |
set -o pipefail
{
@@ -341,6 +347,9 @@ jobs:
corepack enable "$PM"
;;
esac
if [ "$PM" = pnpm ] && [ -n "$PNPM_VERSION" ]; then
corepack prepare "pnpm@$PNPM_VERSION" --activate
fi
case "$PM" in
pnpm) pnpm install --frozen-lockfile ;;
yarn) yarn install --immutable ;;