118 lines
3.9 KiB
YAML
118 lines
3.9 KiB
YAML
name: 'Setup Node.js, pnpm, Bun via mise'
|
|
description: 'Sets up Node.js, pnpm, and Bun from mise.toml unless explicit matrix overrides are provided'
|
|
|
|
inputs:
|
|
node-version:
|
|
description: 'Node.js version to use. Defaults to mise.toml'
|
|
required: false
|
|
default: ''
|
|
bun-version:
|
|
description: 'Bun version to use. Defaults to mise.toml'
|
|
required: false
|
|
default: ''
|
|
enable-caching:
|
|
description: 'Enable pnpm/tool cache'
|
|
required: false
|
|
default: 'true'
|
|
enable-turbo-cache:
|
|
description: 'Cache .turbo build outputs'
|
|
required: false
|
|
default: 'false'
|
|
|
|
outputs:
|
|
node-version:
|
|
description: 'The installed Node.js version'
|
|
value: ${{ steps.versions.outputs.node }}
|
|
bun-version:
|
|
description: 'The installed Bun version'
|
|
value: ${{ steps.versions.outputs.bun }}
|
|
pnpm-version:
|
|
description: 'The installed pnpm version'
|
|
value: ${{ steps.versions.outputs.pnpm }}
|
|
|
|
runs:
|
|
using: 'composite'
|
|
steps:
|
|
- name: Setup mise
|
|
uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1
|
|
with:
|
|
version: 2026.5.18
|
|
install: false
|
|
cache: ${{ inputs.enable-caching }}
|
|
|
|
- name: Install mise-managed Node.js and Bun
|
|
shell: bash
|
|
env:
|
|
NODE_VERSION: ${{ inputs.node-version }}
|
|
BUN_VERSION: ${{ inputs.bun-version }}
|
|
run: |
|
|
tools=()
|
|
if [ -z "$NODE_VERSION" ]; then
|
|
tools+=(node)
|
|
fi
|
|
if [ -z "$BUN_VERSION" ]; then
|
|
tools+=(bun)
|
|
fi
|
|
if [ "${#tools[@]}" -gt 0 ]; then
|
|
mise install "${tools[@]}"
|
|
fi
|
|
|
|
- name: Setup Node.js override
|
|
if: inputs.node-version != ''
|
|
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
|
with:
|
|
node-version: ${{ inputs.node-version }}
|
|
|
|
- name: Setup Bun override
|
|
if: inputs.bun-version != ''
|
|
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
|
with:
|
|
bun-version: ${{ inputs.bun-version }}
|
|
|
|
- name: Install mise-managed pnpm
|
|
shell: bash
|
|
run: mise install npm:pnpm
|
|
|
|
- name: Prefer mise-managed pnpm
|
|
shell: bash
|
|
run: |
|
|
# Node.js distributions can expose their own pnpm. Keep mise.toml's
|
|
# npm:pnpm pin ahead of the Node install, especially for Node overrides.
|
|
echo "$(mise where npm:pnpm)/bin" >> "$GITHUB_PATH"
|
|
|
|
- name: Resolve pnpm store path and Node version
|
|
if: inputs.enable-caching == 'true'
|
|
id: pnpm-store
|
|
shell: bash
|
|
run: |
|
|
echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
|
|
echo "NODE_VERSION=$(node --version | sed 's/^v//')" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Cache pnpm store
|
|
if: inputs.enable-caching == 'true'
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: ${{ steps.pnpm-store.outputs.STORE_PATH }}
|
|
key: ${{ runner.os }}-node${{ steps.pnpm-store.outputs.NODE_VERSION }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node${{ steps.pnpm-store.outputs.NODE_VERSION }}-pnpm-store-
|
|
|
|
- name: Cache turbo build outputs
|
|
if: inputs.enable-caching == 'true' && inputs.enable-turbo-cache == 'true'
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: .turbo/cache
|
|
# Keyed per job: concurrent jobs save different task graphs under the
|
|
# same commit, and actions/cache is first-writer-wins on exact keys.
|
|
key: ${{ runner.os }}-turbo-${{ github.job }}-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-turbo-${{ github.job }}-
|
|
|
|
- name: Report versions
|
|
id: versions
|
|
shell: bash
|
|
run: |
|
|
echo "node=$(node --version | sed 's/^v//')" >> "$GITHUB_OUTPUT"
|
|
echo "bun=$(bun --version)" >> "$GITHUB_OUTPUT"
|
|
echo "pnpm=$(pnpm --version)" >> "$GITHUB_OUTPUT"
|