Files
better-setup-node/action.yml
T

37 lines
1.4 KiB
YAML

name: better-setup-node
description: Install a pinned musl Node from the official unofficial-builds (glibc builds cannot exec on musl runners) and optionally install a pinned pnpm via npm (Node 25 dropped bundled corepack).
inputs:
node-version:
description: Exact Node version to install (e.g. 22.14.0).
required: true
pnpm-version:
description: Optional exact pnpm version to activate via corepack.
required: false
default: ""
runs:
using: composite
steps:
- shell: bash
run: |
set -euo pipefail
nv="${{ inputs.node-version }}"
pv="${{ inputs.pnpm-version }}"
need_install=0
node --version 2>/dev/null | grep -q "^v${nv%%.*}\." || need_install=1
[ "$need_install" = 0 ] && [ -n "$pv" ] && command -v corepack >/dev/null || need_install=1
if [ "$need_install" = 1 ]; then
case "$(uname -m)" in
x86_64|amd64) musl=x64-musl ;;
aarch64|arm64) musl=arm64-musl ;;
*) echo "better-setup-node: unsupported arch $(uname -m)" >&2; exit 1 ;;
esac
curl -fsSL "https://unofficial-builds.nodejs.org/download/release/v${nv}/node-v${nv}-linux-${musl}.tar.gz" \
| tar -xz -C /usr/local --strip-components=1
fi
node --version
if [ -n "$pv" ]; then
# Node 25 dropped bundled corepack; npm ships with every distribution.
npm install -g "pnpm@${pv}"
pnpm --version
fi