From f1e8278b456922c49c55a93e1a8e6aa258b671fa Mon Sep 17 00:00:00 2001 From: Vlad Durnea Date: Sat, 31 Oct 2026 08:51:21 +0200 Subject: [PATCH] better-setup-node v1: pinned musl node + corepack pnpm --- README.md | 11 +++++++++++ action.yml | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 README.md create mode 100644 action.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..4237672 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# better-setup-node + +Fork of the setup-node recipe for git.madapes.com runners. The runner images are musl-based, +so the official (glibc) Node builds fail with `no such file or directory` on exec — this +installs the pinned musl build from the official unofficial-builds mirror. When +`pnpm-version` is set, corepack (bundled with Node) activates that exact pnpm. + +```yaml +- uses: https://git.madapes.com/actions/better-setup-node@v1 + with: { node-version: "22.14.0", pnpm-version: "10.33.0" } +``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..86c3684 --- /dev/null +++ b/action.yml @@ -0,0 +1,36 @@ +name: better-setup-node +description: Install a pinned musl Node from the official unofficial-builds (glibc builds cannot exec on musl runners) and optionally activate a pinned pnpm via 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 + corepack enable + corepack prepare "pnpm@${pv}" --activate + pnpm --version + fi