From d7a11313b581b306c961b506cfc8971208bb03f6 Mon Sep 17 00:00:00 2001 From: priya-kinthali <147703874+priya-kinthali@users.noreply.github.com> Date: Tue, 26 Aug 2025 08:10:12 +0530 Subject: [PATCH 1/3] Enhance caching in setup-node with automatic package manager detection (#1348) * setup node in local * Enhance caching in setup-node with package manager filed detection * updated with array * update the field --- .github/workflows/e2e-cache.yml | 25 +++++++++++++ README.md | 14 +++++++- __tests__/main.test.ts | 64 +++++++++++++++++++++++++++++++++ action.yml | 3 ++ dist/setup/index.js | 30 ++++++++++++++-- src/cache-save.ts | 1 + src/main.ts | 34 +++++++++++++++++- 7 files changed, 167 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-cache.yml b/.github/workflows/e2e-cache.yml index cede9b63..3cbab61e 100644 --- a/.github/workflows/e2e-cache.yml +++ b/.github/workflows/e2e-cache.yml @@ -243,3 +243,28 @@ jobs: cache-dependency-path: | sub2/*.lock sub3/*.lock + + node-npm-package-manager-cache: + name: Test enabling cache if package manager field is present (Node ${{ matrix.node-version }}, ${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest, macos-13] + node-version: [18, 20, 22] + steps: + - uses: actions/checkout@v4 + - name: Create package.json with packageManager field + run: | + echo '{ "name": "test-project", "version": "1.0.0", "packageManager": "npm@8.0.0" }' > package.json + - name: Clean global cache + run: npm cache clean --force + - name: Setup Node with caching enabled + uses: ./ + with: + node-version: ${{ matrix.node-version }} + - name: Install dependencies + run: npm install + - name: Verify node and npm + run: __tests__/verify-node.sh "${{ matrix.node-version }}" + shell: bash diff --git a/README.md b/README.md index 92804e94..1ccefa7f 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,19 @@ It's **always** recommended to commit the lockfile of your package manager for s ## Caching global packages data -The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under the hood for caching global packages data but requires less configuration settings. Supported package managers are `npm`, `yarn`, `pnpm` (v6.10+). The `cache` input is optional, and caching is turned off by default. +The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under the hood for caching global packages data but requires less configuration settings. Supported package managers are `npm`, `yarn`, `pnpm` (v6.10+). The `cache` input is optional. + +Caching is turned on by default when a `packageManager` field is detected in the `package.json` file. The `package-manager-cache` input provides control over this automatic caching behavior. By default, `package-manager-cache` is set to `true`, which enables caching when a valid package manager field is detected in the `package.json` file. To disable this automatic caching, set the `package-manager-cache` input to `false`. + +```yaml +steps: +- uses: actions/checkout@v4 +- uses: actions/setup-node@v4 + with: + package-manager-cache: false +- run: npm ci +``` +> If no valid `packageManager` field is detected in the `package.json` file, caching will remain disabled unless explicitly configured. The action defaults to search for the dependency file (`package-lock.json`, `npm-shrinkwrap.json` or `yarn.lock`) in the repository root, and uses its hash as a part of the cache key. Use `cache-dependency-path` for cases when multiple dependency files are used, or they are located in different subdirectories. diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 501741a6..5af57092 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -20,6 +20,7 @@ describe('main tests', () => { let infoSpy: jest.SpyInstance; let warningSpy: jest.SpyInstance; + let saveStateSpy: jest.SpyInstance; let inSpy: jest.SpyInstance; let setOutputSpy: jest.SpyInstance; let startGroupSpy: jest.SpyInstance; @@ -53,6 +54,8 @@ describe('main tests', () => { setOutputSpy.mockImplementation(() => {}); warningSpy = jest.spyOn(core, 'warning'); warningSpy.mockImplementation(() => {}); + saveStateSpy = jest.spyOn(core, 'saveState'); + saveStateSpy.mockImplementation(() => {}); startGroupSpy = jest.spyOn(core, 'startGroup'); startGroupSpy.mockImplementation(() => {}); endGroupSpy = jest.spyOn(core, 'endGroup'); @@ -280,4 +283,65 @@ describe('main tests', () => { ); }); }); + + describe('cache feature tests', () => { + it('Should enable caching with the resolved package manager from packageManager field in package.json when the cache input is not provided', async () => { + inputs['package-manager-cache'] = 'true'; + inputs['cache'] = ''; // No cache input is provided + + inSpy.mockImplementation(name => inputs[name]); + + const readFileSpy = jest.spyOn(fs, 'readFileSync'); + readFileSpy.mockImplementation(() => + JSON.stringify({ + packageManager: 'yarn@3.2.0' + }) + ); + + await main.run(); + + expect(saveStateSpy).toHaveBeenCalledWith(expect.anything(), 'yarn'); + }); + + it('Should not enable caching if the packageManager field is missing in package.json and the cache input is not provided', async () => { + inputs['package-manager-cache'] = 'true'; + inputs['cache'] = ''; // No cache input is provided + + inSpy.mockImplementation(name => inputs[name]); + + const readFileSpy = jest.spyOn(fs, 'readFileSync'); + readFileSpy.mockImplementation(() => + JSON.stringify({ + //packageManager field is not present + }) + ); + + await main.run(); + + expect(saveStateSpy).not.toHaveBeenCalled(); + }); + + it('Should skip caching when package-manager-cache is false', async () => { + inputs['package-manager-cache'] = 'false'; + inputs['cache'] = ''; // No cache input is provided + + inSpy.mockImplementation(name => inputs[name]); + + await main.run(); + + expect(saveStateSpy).not.toHaveBeenCalled(); + }); + + it('Should enable caching with cache input explicitly provided', async () => { + inputs['package-manager-cache'] = 'true'; + inputs['cache'] = 'npm'; // Explicit cache input provided + + inSpy.mockImplementation(name => inputs[name]); + isCacheActionAvailable.mockReturnValue(true); + + await main.run(); + + expect(saveStateSpy).toHaveBeenCalledWith(expect.anything(), 'npm'); + }); + }); }); diff --git a/action.yml b/action.yml index ef58e699..3fc2e0c2 100644 --- a/action.yml +++ b/action.yml @@ -23,6 +23,9 @@ inputs: default: ${{ github.server_url == 'https://github.com' && github.token || '' }} cache: description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.' + package-manager-cache: + description: 'Set to false to disable automatic caching based on the package manager field in package.json. By default, caching is enabled if the package manager field is present.' + default: true cache-dependency-path: description: 'Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies.' mirror: diff --git a/dist/setup/index.js b/dist/setup/index.js index 390170cc..c6381da6 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -99583,9 +99583,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.run = void 0; +exports.getNameFromPackageManagerField = exports.run = void 0; const core = __importStar(__nccwpck_require__(37484)); const os_1 = __importDefault(__nccwpck_require__(70857)); +const fs_1 = __importDefault(__nccwpck_require__(79896)); const auth = __importStar(__nccwpck_require__(98789)); const path = __importStar(__nccwpck_require__(16928)); const cache_restore_1 = __nccwpck_require__(44326); @@ -99603,6 +99604,8 @@ function run() { const version = resolveVersionInput(); let arch = core.getInput('architecture'); const cache = core.getInput('cache'); + const packagemanagercache = (core.getInput('package-manager-cache') || 'true').toUpperCase() === + 'TRUE'; // if architecture supplied but node-version is not // if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant. if (arch && !version) { @@ -99636,11 +99639,16 @@ function run() { if (registryUrl) { auth.configAuthentication(registryUrl, alwaysAuth); } + const resolvedPackageManager = getNameFromPackageManagerField(); + const cacheDependencyPath = core.getInput('cache-dependency-path'); if (cache && (0, cache_utils_1.isCacheFeatureAvailable)()) { core.saveState(constants_1.State.CachePackageManager, cache); - const cacheDependencyPath = core.getInput('cache-dependency-path'); yield (0, cache_restore_1.restoreCache)(cache, cacheDependencyPath); } + else if (resolvedPackageManager && packagemanagercache) { + core.saveState(constants_1.State.CachePackageManager, resolvedPackageManager); + yield (0, cache_restore_1.restoreCache)(resolvedPackageManager, cacheDependencyPath); + } const matchersPath = path.join(__dirname, '../..', '.github'); core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`); @@ -99674,6 +99682,24 @@ function resolveVersionInput() { } return version; } +function getNameFromPackageManagerField() { + // Check packageManager field in package.json + const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm']; + try { + const packageJson = JSON.parse(fs_1.default.readFileSync(path.join(process.env.GITHUB_WORKSPACE, 'package.json'), 'utf-8')); + const pm = packageJson.packageManager; + if (typeof pm === 'string') { + const regex = new RegExp(`^(?:\\^)?(${SUPPORTED_PACKAGE_MANAGERS.join('|')})@`); + const match = pm.match(regex); + return match ? match[1] : undefined; + } + return undefined; + } + catch (err) { + return undefined; + } +} +exports.getNameFromPackageManagerField = getNameFromPackageManagerField; /***/ }), diff --git a/src/cache-save.ts b/src/cache-save.ts index 2522127a..bbfd2de6 100644 --- a/src/cache-save.ts +++ b/src/cache-save.ts @@ -7,6 +7,7 @@ import {getPackageManagerInfo} from './cache-utils'; // Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in // @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to // throw an uncaught exception. Instead of failing this action, just warn. + process.on('uncaughtException', e => { const warningPrefix = '[warning]'; core.info(`${warningPrefix}${e.message}`); diff --git a/src/main.ts b/src/main.ts index c36d8ec5..f169cef0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,7 @@ import * as core from '@actions/core'; import os from 'os'; +import fs from 'fs'; import * as auth from './authutil'; import * as path from 'path'; @@ -20,6 +21,9 @@ export async function run() { let arch = core.getInput('architecture'); const cache = core.getInput('cache'); + const packagemanagercache = + (core.getInput('package-manager-cache') || 'true').toUpperCase() === + 'TRUE'; // if architecture supplied but node-version is not // if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant. @@ -63,10 +67,14 @@ export async function run() { auth.configAuthentication(registryUrl, alwaysAuth); } + const resolvedPackageManager = getNameFromPackageManagerField(); + const cacheDependencyPath = core.getInput('cache-dependency-path'); if (cache && isCacheFeatureAvailable()) { core.saveState(State.CachePackageManager, cache); - const cacheDependencyPath = core.getInput('cache-dependency-path'); await restoreCache(cache, cacheDependencyPath); + } else if (resolvedPackageManager && packagemanagercache) { + core.saveState(State.CachePackageManager, resolvedPackageManager); + await restoreCache(resolvedPackageManager, cacheDependencyPath); } const matchersPath = path.join(__dirname, '../..', '.github'); @@ -117,3 +125,27 @@ function resolveVersionInput(): string { return version; } + +export function getNameFromPackageManagerField(): string | undefined { + // Check packageManager field in package.json + const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm']; + try { + const packageJson = JSON.parse( + fs.readFileSync( + path.join(process.env.GITHUB_WORKSPACE!, 'package.json'), + 'utf-8' + ) + ); + const pm = packageJson.packageManager; + if (typeof pm === 'string') { + const regex = new RegExp( + `^(?:\\^)?(${SUPPORTED_PACKAGE_MANAGERS.join('|')})@` + ); + const match = pm.match(regex); + return match ? match[1] : undefined; + } + return undefined; + } catch (err) { + return undefined; + } +} From b7234cc9fe124f0f4932554b4e5284543083ae7b Mon Sep 17 00:00:00 2001 From: Salman Chishti Date: Wed, 3 Sep 2025 02:31:16 +0100 Subject: [PATCH 2/3] Upgrade action to use node24 (#1325) * Change Node.js version to 24 Update Node.js version from 20 to 24 in action.yml * update and vulnerability fixes * update node version check * update licences * node version check update * update version for test * node version * update node version to 24.0.0 in tool-versions and package-volta.json * node 24 * update to 24 * update to specify engines * check failures fix * update package-lock.json * licensed update * check failure fix * documentation update --------- Co-authored-by: Aparna Jyothi --- .github/workflows/basic-validation.yml | 2 +- .github/workflows/e2e-cache.yml | 18 +++--- .github/workflows/versions.yml | 10 +-- .licenses/npm/@types/node.dep.yml | Bin 1451 -> 1449 bytes .licenses/npm/undici-types.dep.yml | Bin 1321 -> 1354 bytes README.md | 20 +++--- __tests__/data/.nvmrc | 2 +- __tests__/data/.tool-versions | 2 +- __tests__/data/.tool-versions-node | 2 +- __tests__/data/package-volta.json | 2 +- __tests__/data/package.json | 2 +- __tests__/verify-node.sh | 9 ++- action.yml | 2 +- docs/advanced-usage.md | 82 ++++++++++++------------- package-lock.json | 25 +++++--- package.json | 7 ++- 16 files changed, 99 insertions(+), 86 deletions(-) diff --git a/.github/workflows/basic-validation.yml b/.github/workflows/basic-validation.yml index d2b406f3..4cb6489e 100644 --- a/.github/workflows/basic-validation.yml +++ b/.github/workflows/basic-validation.yml @@ -16,4 +16,4 @@ jobs: name: Basic validation uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main with: - node-version: '20.x' + node-version: '24.x' diff --git a/.github/workflows/e2e-cache.yml b/.github/workflows/e2e-cache.yml index 3cbab61e..1fd6ea0a 100644 --- a/.github/workflows/e2e-cache.yml +++ b/.github/workflows/e2e-cache.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] - node-version: [18, 20, 22] + node-version: [18, 20, 22, 24] steps: - uses: actions/checkout@v4 - name: Clean global cache @@ -42,7 +42,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] - node-version: [18, 20, 22] + node-version: [18, 20, 22, 24] steps: - uses: actions/checkout@v4 - name: Install pnpm @@ -75,13 +75,13 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] - node-version: [18, 20] + node-version: [18, 20, 24] steps: - uses: actions/checkout@v4 - name: Yarn version run: yarn --version - name: Generate yarn file - run: yarn install + run: yarn install --ignore-engines - name: Remove dependencies shell: pwsh run: Remove-Item node_modules -Force -Recurse @@ -107,7 +107,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] - node-version: [18, 20, 22] + node-version: [18, 20, 22, 24] steps: - uses: actions/checkout@v4 - name: Update yarn @@ -139,7 +139,7 @@ jobs: name: Test yarn subprojects strategy: matrix: - node-version: [18, 20, 22] + node-version: [18, 20, 22, 24] runs-on: ubuntu-latest steps: @@ -166,7 +166,7 @@ jobs: name: Test yarn subprojects all locally managed strategy: matrix: - node-version: [18, 20, 22] + node-version: [18, 20, 22, 24] runs-on: ubuntu-latest steps: @@ -193,7 +193,7 @@ jobs: name: Test yarn subprojects some locally managed strategy: matrix: - node-version: [18, 20, 22] + node-version: [18, 20, 22, 24] runs-on: ubuntu-latest steps: @@ -220,7 +220,7 @@ jobs: name: Test yarn subprojects managed by git strategy: matrix: - node-version: [18, 20, 22] + node-version: [18, 20, 22, 24] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index b51ba8b5..eb2a481b 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] - node-version: [18, 20, 22] + node-version: [18, 20, 22, 24] steps: - uses: actions/checkout@v4 - name: Setup Node @@ -139,7 +139,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] - node-version: [18, 20, 22] + node-version: [18, 20, 22, 24] steps: - uses: actions/checkout@v4 - name: Setup Node and check latest @@ -166,7 +166,7 @@ jobs: with: node-version-file: '__tests__/data/${{ matrix.node-version-file }}' - name: Verify node - run: __tests__/verify-node.sh 20 + run: __tests__/verify-node.sh 24 version-file-volta: runs-on: ${{ matrix.os }} @@ -181,7 +181,7 @@ jobs: with: node-version-file: '__tests__/data/package-volta.json' - name: Verify node - run: __tests__/verify-node.sh 20 + run: __tests__/verify-node.sh 24 version-file-volta-extends: runs-on: ${{ matrix.os }} @@ -196,7 +196,7 @@ jobs: with: node-version-file: '__tests__/data/package-volta-extends.json' - name: Verify node - run: __tests__/verify-node.sh 20 + run: __tests__/verify-node.sh 24 node-dist: runs-on: ${{ matrix.os }} diff --git a/.licenses/npm/@types/node.dep.yml b/.licenses/npm/@types/node.dep.yml index 4773dad77312b1e5fd9ea870cc73c2ea07dc0a46..86544f4884d05265162cc1e57c8455680f3febf2 100644 GIT binary patch delta 16 XcmZ3@y^?!^603=xp`O7;%_dd=D1iiY delta 18 ZcmZ36g`UAgwMKRyPiI%ZVAqMq6il4+3o45;(=$pGG?FzHd=pDbQu7s@ n^K)`C^AZ&j^HLN-^HMUCGZm8a^Gb>`lS)hSi;6cs@MHl1bCw+$ delta 56 zcmX@bwUTRs0-LFxk(r+9MAb%l$I_B~-SpJF)S|?a)D#6@&k%*2%;eO(;#7r_)QXac MYZW%LGdi;X00w6gi2wiq diff --git a/README.md b/README.md index 1ccefa7f..e98158c6 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ See [action.yml](action.yml) ```yaml -- uses: actions/setup-node@v4 +- uses: actions/setup-node@v5 with: # Version Spec of the version to use in SemVer notation. # It also admits such aliases as lts/*, latest, nightly and canary builds @@ -98,8 +98,8 @@ See [action.yml](action.yml) ```yaml steps: -- uses: actions/checkout@v4 -- uses: actions/setup-node@v4 +- uses: actions/checkout@v5 +- uses: actions/setup-node@v5 with: node-version: 18 - run: npm ci @@ -159,8 +159,8 @@ See the examples of using cache for `yarn`/`pnpm` and `cache-dependency-path` in ```yaml steps: -- uses: actions/checkout@v4 -- uses: actions/setup-node@v4 +- uses: actions/checkout@v5 +- uses: actions/setup-node@v5 with: node-version: 20 cache: 'npm' @@ -172,8 +172,8 @@ steps: ```yaml steps: -- uses: actions/checkout@v4 -- uses: actions/setup-node@v4 +- uses: actions/checkout@v5 +- uses: actions/setup-node@v5 with: node-version: 20 cache: 'npm' @@ -193,9 +193,9 @@ jobs: node: [ 14, 16, 18 ] name: Node ${{ matrix.node }} sample steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup node - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: node-version: ${{ matrix.node }} - run: npm ci @@ -209,7 +209,7 @@ jobs: To get a higher rate limit, you can [generate a personal access token on github.com](https://github.com/settings/tokens/new) and pass it as the `token` input for the action: ```yaml -uses: actions/setup-node@v4 +uses: actions/setup-node@v5 with: token: ${{ secrets.GH_DOTCOM_TOKEN }} node-version: 20 diff --git a/__tests__/data/.nvmrc b/__tests__/data/.nvmrc index 9a2a0e21..54c65116 100644 --- a/__tests__/data/.nvmrc +++ b/__tests__/data/.nvmrc @@ -1 +1 @@ -v20 +v24 diff --git a/__tests__/data/.tool-versions b/__tests__/data/.tool-versions index 6de89a83..7ca549c1 100644 --- a/__tests__/data/.tool-versions +++ b/__tests__/data/.tool-versions @@ -1 +1 @@ -nodejs 20.0.0 +nodejs 24.0.0 diff --git a/__tests__/data/.tool-versions-node b/__tests__/data/.tool-versions-node index 4d5dd711..9f5de99c 100644 --- a/__tests__/data/.tool-versions-node +++ b/__tests__/data/.tool-versions-node @@ -1 +1 @@ -node 20.0.0 +node 24.0.0 diff --git a/__tests__/data/package-volta.json b/__tests__/data/package-volta.json index 6c9583f1..12b3b6ef 100644 --- a/__tests__/data/package-volta.json +++ b/__tests__/data/package-volta.json @@ -3,6 +3,6 @@ "node": "^14.0.0" }, "volta": { - "node": "20.0.0" + "node": "24.0.0" } } diff --git a/__tests__/data/package.json b/__tests__/data/package.json index 4fb385a2..724da539 100644 --- a/__tests__/data/package.json +++ b/__tests__/data/package.json @@ -1,5 +1,5 @@ { "engines": { - "node": "^20.0.0" + "node": "^24.0.0" } } diff --git a/__tests__/verify-node.sh b/__tests__/verify-node.sh index 797aa789..38a03a4c 100755 --- a/__tests__/verify-node.sh +++ b/__tests__/verify-node.sh @@ -7,8 +7,13 @@ fi node_version="$(node --version)" echo "Found node version '$node_version'" -if [ -z "$(echo $node_version | grep --fixed-strings v$1)" ]; then - echo "Unexpected version" + +# Extract the major version from the node version (remove the 'v' prefix) +actual_major_version=$(echo $node_version | sed -E 's/^v([0-9]+)\..*/\1/') +expected_major_version=$(echo $1 | sed -E 's/^([0-9]+)\..*/\1/') # Extract major version from argument + +if [ "$actual_major_version" != "$expected_major_version" ]; then + echo "Expected Node.js $expected_major_version.x.x but found $node_version" exit 1 fi diff --git a/action.yml b/action.yml index 3fc2e0c2..fbc851b6 100644 --- a/action.yml +++ b/action.yml @@ -40,7 +40,7 @@ outputs: node-version: description: 'The installed node version.' runs: - using: 'node20' + using: 'node24' main: 'dist/setup/index.js' post: 'dist/cache-save/index.js' post-if: success() diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 856c5efa..97f977f7 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -45,8 +45,8 @@ If `check-latest` is set to `true`, the action first checks if the cached versio ```yaml steps: -- uses: actions/checkout@v4 -- uses: actions/setup-node@v4 +- uses: actions/checkout@v5 +- uses: actions/setup-node@v5 with: node-version: '16' check-latest: true @@ -63,8 +63,8 @@ See [supported version syntax](https://github.com/actions/setup-node#supported-v ```yaml steps: -- uses: actions/checkout@v4 -- uses: actions/setup-node@v4 +- uses: actions/checkout@v5 +- uses: actions/setup-node@v5 with: node-version-file: '.nvmrc' - run: npm ci @@ -97,8 +97,8 @@ jobs: runs-on: windows-latest name: Node sample steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 with: node-version: '14' architecture: 'x64' # optional, x64 or x86. If not specified, x64 will be used by default @@ -118,8 +118,8 @@ jobs: runs-on: ubuntu-latest name: Node sample steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 with: node-version: '20.0.0-v8-canary' # it will install the latest v8 canary release for node 20.0.0 - run: npm ci @@ -133,8 +133,8 @@ jobs: runs-on: ubuntu-latest name: Node sample steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 with: node-version: '20-v8-canary' # it will install the latest v8 canary release for node 20 - run: npm ci @@ -149,8 +149,8 @@ jobs: runs-on: ubuntu-latest name: Node sample steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 with: node-version: 'v20.1.1-v8-canary20221103f7e2421e91' - run: npm ci @@ -169,8 +169,8 @@ jobs: runs-on: ubuntu-latest name: Node sample steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 with: node-version: '16-nightly' # it will install the latest nightly release for node 16 - run: npm ci @@ -185,8 +185,8 @@ jobs: runs-on: ubuntu-latest name: Node sample steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 with: node-version: '16.0.0-nightly' # it will install the latest nightly release for node 16.0.0 - run: npm ci @@ -201,8 +201,8 @@ jobs: runs-on: ubuntu-latest name: Node sample steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 with: node-version: '16.0.0-nightly20210420a0261d231c' - run: npm ci @@ -219,8 +219,8 @@ jobs: runs-on: ubuntu-latest name: Node sample steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 with: node-version: '16.0.0-rc.1' - run: npm ci @@ -236,8 +236,8 @@ The action follows [actions/cache](https://github.com/actions/cache/blob/main/ex Yarn caching handles both yarn versions: 1 or 2. ```yaml steps: -- uses: actions/checkout@v4 -- uses: actions/setup-node@v4 +- uses: actions/checkout@v5 +- uses: actions/setup-node@v5 with: node-version: '14' cache: 'yarn' @@ -255,11 +255,11 @@ steps: # NOTE: pnpm caching support requires pnpm version >= 6.10.0 steps: -- uses: actions/checkout@v4 +- uses: actions/checkout@v5 - uses: pnpm/action-setup@v2 with: version: 6.32.9 -- uses: actions/setup-node@v4 +- uses: actions/setup-node@v5 with: node-version: '14' cache: 'pnpm' @@ -274,8 +274,8 @@ steps: **Using wildcard patterns to cache dependencies** ```yaml steps: -- uses: actions/checkout@v4 -- uses: actions/setup-node@v4 +- uses: actions/checkout@v5 +- uses: actions/setup-node@v5 with: node-version: '14' cache: 'npm' @@ -287,8 +287,8 @@ steps: **Using a list of file paths to cache dependencies** ```yaml steps: -- uses: actions/checkout@v4 -- uses: actions/setup-node@v4 +- uses: actions/checkout@v5 +- uses: actions/setup-node@v5 with: node-version: '14' cache: 'npm' @@ -324,9 +324,9 @@ jobs: architecture: x86 name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup node - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: node-version: ${{ matrix.node_version }} architecture: ${{ matrix.architecture }} @@ -337,8 +337,8 @@ jobs: ## Publish to npmjs and GPR with npm ```yaml steps: -- uses: actions/checkout@v4 -- uses: actions/setup-node@v4 +- uses: actions/checkout@v5 +- uses: actions/setup-node@v5 with: node-version: '14.x' registry-url: 'https://registry.npmjs.org' @@ -346,7 +346,7 @@ steps: - run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} -- uses: actions/setup-node@v4 +- uses: actions/setup-node@v5 with: registry-url: 'https://npm.pkg.github.com' - run: npm publish @@ -357,8 +357,8 @@ steps: ## Publish to npmjs and GPR with yarn ```yaml steps: -- uses: actions/checkout@v4 -- uses: actions/setup-node@v4 +- uses: actions/checkout@v5 +- uses: actions/setup-node@v5 with: node-version: '14.x' registry-url: @@ -366,7 +366,7 @@ steps: - run: yarn publish env: NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }} -- uses: actions/setup-node@v4 +- uses: actions/setup-node@v5 with: registry-url: 'https://npm.pkg.github.com' - run: yarn publish @@ -377,8 +377,8 @@ steps: ## Use private packages ```yaml steps: -- uses: actions/checkout@v4 -- uses: actions/setup-node@v4 +- uses: actions/checkout@v5 +- uses: actions/setup-node@v5 with: node-version: '14.x' registry-url: 'https://registry.npmjs.org' @@ -397,8 +397,8 @@ Below you can find a sample "Setup .yarnrc.yml" step, that is going to allow you ```yaml steps: -- uses: actions/checkout@v4 -- uses: actions/setup-node@v4 +- uses: actions/checkout@v5 +- uses: actions/setup-node@v5 with: node-version: '14.x' - name: Setup .yarnrc.yml @@ -427,7 +427,7 @@ It is possible to specify a token to authenticate with the mirror using the `mir The token will be passed as a bearer token in the `Authorization` header. ```yaml -- uses: actions/setup-node@v4 +- uses: actions/setup-node@v5 with: node-version: '14.x' mirror: 'https://nodejs.org/dist' diff --git a/package-lock.json b/package-lock.json index fa0c2eb6..d09bf273 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "setup-node", - "version": "4.0.0", + "version": "5.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "setup-node", - "version": "4.0.0", + "version": "5.0.0", "license": "MIT", "dependencies": { "@actions/cache": "^4.0.3", @@ -22,7 +22,7 @@ }, "devDependencies": { "@types/jest": "^29.5.14", - "@types/node": "^20.11.25", + "@types/node": "^24.1.0", "@types/semver": "^7.5.8", "@typescript-eslint/eslint-plugin": "^5.54.0", "@typescript-eslint/parser": "^5.54.0", @@ -37,6 +37,9 @@ "prettier": "^2.8.4", "ts-jest": "^29.1.2", "typescript": "^5.4.2" + }, + "engines": { + "node": ">=24.0.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -1780,11 +1783,12 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.11.25", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.25.tgz", - "integrity": "sha512-TBHyJxk2b7HceLVGFcpAUjsa5zIdsPWlR6XHfyGzd0SFu+/NFgQgMAl96MSDZgQDvJAvV6BKsFOrt6zIL09JDw==", + "version": "24.1.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.1.0.tgz", + "integrity": "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==", + "license": "MIT", "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~7.8.0" } }, "node_modules/@types/node-fetch": { @@ -5552,9 +5556,10 @@ } }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz", + "integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==", + "license": "MIT" }, "node_modules/universal-user-agent": { "version": "6.0.1", diff --git a/package.json b/package.json index dfa86bf2..3399437a 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,12 @@ { "name": "setup-node", - "version": "4.0.0", + "version": "5.0.0", "private": true, "description": "setup node action", "main": "lib/setup-node.js", + "engines": { + "node": ">=24.0.0" + }, "scripts": { "build": "ncc build -o dist/setup src/setup-node.ts && ncc build -o dist/cache-save src/cache-save.ts", "format": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write \"**/*.{ts,yml,yaml}\"", @@ -38,7 +41,7 @@ }, "devDependencies": { "@types/jest": "^29.5.14", - "@types/node": "^20.11.25", + "@types/node": "^24.1.0", "@types/semver": "^7.5.8", "@typescript-eslint/eslint-plugin": "^5.54.0", "@typescript-eslint/parser": "^5.54.0", From a0853c24544627f65ddf259abe73b1d18a591444 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 12:47:21 -0500 Subject: [PATCH 3/3] Bump actions/checkout from 4 to 5 (#1345) Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/e2e-cache.yml | 18 ++++++------ .github/workflows/proxy.yml | 4 +-- .../workflows/publish-immutable-actions.yml | 2 +- .github/workflows/versions.yml | 28 +++++++++---------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/e2e-cache.yml b/.github/workflows/e2e-cache.yml index 1fd6ea0a..f1c1868b 100644 --- a/.github/workflows/e2e-cache.yml +++ b/.github/workflows/e2e-cache.yml @@ -21,7 +21,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] node-version: [18, 20, 22, 24] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Clean global cache run: npm cache clean --force - name: Setup Node @@ -44,7 +44,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] node-version: [18, 20, 22, 24] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Install pnpm uses: pnpm/action-setup@v4 with: @@ -77,7 +77,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] node-version: [18, 20, 24] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Yarn version run: yarn --version - name: Generate yarn file @@ -109,7 +109,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] node-version: [18, 20, 22, 24] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Update yarn run: yarn set version 3.6.4 - name: Yarn version @@ -143,7 +143,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: prepare sub-projects run: __tests__/prepare-yarn-subprojects.sh yarn1 @@ -170,7 +170,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: prepare sub-projects run: __tests__/prepare-yarn-subprojects.sh keepcache keepcache @@ -197,7 +197,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: prepare sub-projects run: __tests__/prepare-yarn-subprojects.sh global @@ -224,7 +224,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: prepare sub-projects run: /bin/bash __tests__/prepare-yarn-subprojects.sh keepcache @@ -253,7 +253,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] node-version: [18, 20, 22] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Create package.json with packageManager field run: | echo '{ "name": "test-project", "version": "1.0.0", "packageManager": "npm@8.0.0" }' > package.json diff --git a/.github/workflows/proxy.yml b/.github/workflows/proxy.yml index ff29d735..ab52b8fd 100644 --- a/.github/workflows/proxy.yml +++ b/.github/workflows/proxy.yml @@ -25,7 +25,7 @@ jobs: env: https_proxy: http://squid-proxy:3128 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Clear tool cache run: rm -rf $RUNNER_TOOL_CACHE/* - name: Setup node 14 @@ -41,7 +41,7 @@ jobs: https_proxy: http://no-such-proxy:3128 no_proxy: api.github.com,github.com,nodejs.org,registry.npmjs.org,*.s3.amazonaws.com,s3.amazonaws.com steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Clear tool cache run: rm -rf $RUNNER_TOOL_CACHE/* - name: Setup node 11 diff --git a/.github/workflows/publish-immutable-actions.yml b/.github/workflows/publish-immutable-actions.yml index 7c258347..52c7bc00 100644 --- a/.github/workflows/publish-immutable-actions.yml +++ b/.github/workflows/publish-immutable-actions.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Checking out - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Publish id: publish uses: actions/publish-immutable-action@v0.0.4 diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index eb2a481b..ba56f66f 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -20,7 +20,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] node-version: [18, 20, 22, 24] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Node uses: ./ with: @@ -37,7 +37,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-13] node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*, lts/-1] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Node uses: ./ with: @@ -64,7 +64,7 @@ jobs: '20.0.0-v8-canary20221101e50e45c9f8' ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Node uses: ./ with: @@ -84,7 +84,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] node-version: [20-nightly, 21-nightly, 18.0.0-nightly] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Node uses: ./ with: @@ -104,7 +104,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] node-version: [20.0.0-rc.1, 18.0.0-rc.2, 19.0.0-rc.0] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Node uses: ./ with: @@ -124,7 +124,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] node-version: [18.20.0, 20.10.0, 22.0.0] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Node uses: ./ with: @@ -141,7 +141,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] node-version: [18, 20, 22, 24] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Node and check latest uses: ./ with: @@ -160,7 +160,7 @@ jobs: node-version-file: [.nvmrc, .tool-versions, .tool-versions-node, package.json] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup node from node version file uses: ./ with: @@ -175,7 +175,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup node from node version file uses: ./ with: @@ -190,7 +190,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup node from node version file uses: ./ with: @@ -206,7 +206,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] node-version: [17, 19] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Node from dist uses: ./ with: @@ -222,7 +222,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-13] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 # test old versions which didn't have npm and layout different - name: Setup node 0.12.18 from dist uses: ./ @@ -235,7 +235,7 @@ jobs: arch: runs-on: windows-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup node 20 x86 from dist uses: ./ with: @@ -259,7 +259,7 @@ jobs: echo "LATEST_NODE_VERSION=$latestNodeVersion" >> $GITHUB_OUTPUT id: version shell: bash - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Node uses: ./ with: