1
0
mirror of https://github.com/actions/setup-node.git synced 2026-02-06 00:05:16 +08:00

Compare commits

...

6 Commits

Author SHA1 Message Date
aparnajyothi-y
6044e13b5d Docs: bump actions/checkout from v5 to v6 (#1468)
* Update versions.yml

* Update versions.yml

* doc update

* revert vesrions.yml
2026-01-14 21:04:21 -06:00
Panashe Fundira
8e494633d0 Fix README typo (#1226) 2026-01-14 17:08:53 -06:00
Andreas Deininger
621ac41091 README.md: bump to latest released checkout version v6 (#1446) 2026-01-14 17:06:36 -06:00
Salman Chishti
2951748f4c Bump @actions/cache to v5.0.1 (#1449)
* Bump @actions/cache to v5.0.0

This update removes the punycode deprecation warning by updating to a version of @actions/cache that no longer depends on packages using the deprecated punycode module.

* Update license cache for @actions/cache v5.0.0 dependencies

Regenerated license files to reflect the updated dependency tree after bumping @actions/cache to v5.0.0. This includes license information for new transitive dependencies and removes licenses for dependencies that are no longer used.

* Update license metadata for @actions/http-client

Mark @actions/http-client v2.2.1 and v3.0.0 as MIT license (correctly identified from LICENSE file content)

* prepare release 6.0.1

* Bump version to 6.1.1 in package.json and package-lock.json

* fix: update @actions/cache with storage-blob fix for Node.js 24 punycode deprecation

* fix: update @actions/cache to ^5.0.1 for Node.js 24 punycode fix

Updates @actions/cache to version 5.0.1 which includes the @azure/storage-blob
update that fixes the punycode deprecation warning on Node.js 24.

* fix: update @actions/cache to ^5.0.1 for Node.js 24 punycode fix

Updates @actions/cache to version 5.0.1 which includes the @azure/storage-blob
update that fixes the punycode deprecation warning on Node.js 24.
2026-01-13 17:06:04 -06:00
Mike McCready
21ddc7bc1f Correct mirror option typos (#1442) 2026-01-13 10:46:12 -06:00
mahabaleshwars
65d868f8d4 Update Documentation for Lockfile (#1454)
* update documentation for lockfile

* Update adavance usage in README.md

* Documentation update

* Update lockfile documenation

* fix coplilot suggestion
2025-12-18 10:49:55 -06:00
74 changed files with 95799 additions and 103346 deletions

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/@actions/io-2.0.0.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/debug.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/tslib.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -16,9 +16,9 @@ This action provides the following functionality for GitHub Actions users:
- Caching is now automatically enabled for npm projects when either the `devEngines.packageManager` field or the top-level `packageManager` field in `package.json` is set to `npm`. For other package managers, such as Yarn and pnpm, caching is disabled by default and must be configured manually using the `cache` input.
- The `always-auth` input has been removed, as it is deprecated and will no longer be supported in future npm releases. To ensure your workflows continue to run without warnings or errors, please remove any references to `always-auth` from your configuration.
- The `always-auth` input has been removed, as it is deprecated and will no longer be supported in future npm releases. To ensure your workflows continue to run without warnings or errors, please remove any references to `always-auth` from your configuration.
## Breaking changes in V5
## Breaking changes in V5
- Enabled caching by default with package manager detection if no cache input is provided.
> For workflows with elevated privileges or access to sensitive information, we recommend disabling automatic caching by setting `package-manager-cache: false` when caching is not needed for secure operation.
@@ -42,22 +42,22 @@ See [action.yml](action.yml)
node-version: ''
# File containing the version Spec of the version to use. Examples: package.json, .nvmrc, .node-version, .tool-versions.
# If node-version and node-version-file are both provided the action will use version from node-version.
# If node-version and node-version-file are both provided the action will use version from node-version.
node-version-file: ''
# Set this option if you want the action to check for the latest available version
# Set this option if you want the action to check for the latest available version
# that satisfies the version spec.
# It will only get affect for lts Nodejs versions (12.x, >=10.15.0, lts/Hydrogen).
# It will only get affect for lts Nodejs versions (12.x, >=10.15.0, lts/Hydrogen).
# Default: false
check-latest: false
# Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default.
# Default: ''. The action use system architecture by default
# Default: ''. The action use system architecture by default
architecture: ''
# Used to pull node distributions from https://github.com/actions/node-versions.
# Since there's a default, this is typically not supplied by the user.
# When running this action on github.com, the default value is sufficient.
# Used to pull node distributions from https://github.com/actions/node-versions.
# Since there's a default, this is typically not supplied by the user.
# When running this action on github.com, the default value is sufficient.
# When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.
#
# We recommend using a service account with the least permissions necessary. Also
@@ -78,18 +78,18 @@ See [action.yml](action.yml)
# default: true
package-manager-cache: true
# Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc.
# It will generate hash from the target file for primary key. It works only If cache is specified.
# Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc.
# It will generate hash from the target file for primary key. It works only If cache is specified.
# Supports wildcards or a list of file names for caching multiple dependencies.
# Default: ''
cache-dependency-path: ''
# Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file,
# Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file,
# and set up auth to read in from env.NODE_AUTH_TOKEN.
# Default: ''
registry-url: ''
# Optional scope for authenticating against scoped registries.
# Optional scope for authenticating against scoped registries.
# Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).
# Default: ''
scope: ''
@@ -97,7 +97,7 @@ See [action.yml](action.yml)
# Optional mirror to download binaries from.
# Artifacts need to match the official Node.js
# Example:
# V8 Canaray Build: <mirror_url>/download/v8-canary
# V8 Canary Build: <mirror_url>/download/v8-canary
# RC Build: <mirror_url>/download/rc
# Official: Build <mirror_url>/dist
# Nightly build: <mirror_url>/download/nightly
@@ -115,7 +115,7 @@ See [action.yml](action.yml)
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
@@ -123,7 +123,7 @@ steps:
- run: npm test
```
The `node-version` input is optional. If not supplied, the node version from PATH will be used. However, it is recommended to always specify Node.js version and don't rely on the system one.
The `node-version` input is optional. If not supplied, the node version from PATH will be used. However, it is recommended to always specify Node.js version and not rely on the system one.
The action will first check the local cache for a semver match. If unable to find a specific version in the cache, the action will attempt to download a version of Node.js. It will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/).
@@ -148,7 +148,7 @@ Since it will not be cached always, there is possibility of hitting rate limit w
### Checking in lockfiles
It's **always** recommended to commit the lockfile of your package manager for security and performance reasons. For more information consult the "Working with lockfiles" section of the [Advanced usage](docs/advanced-usage.md#working-with-lockfiles) guide.
It's **strongly recommended** to commit the lockfile of your package manager for security and performance reasons. For more information consult the "Working with lockfiles" section of the [Advanced usage](docs/advanced-usage.md#working-with-lockfiles) guide.
## Caching global packages data
@@ -164,7 +164,7 @@ See the examples of using cache for `yarn`/`pnpm` and `cache-dependency-path` in
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
@@ -177,7 +177,7 @@ steps:
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
@@ -193,7 +193,7 @@ This behavior is controlled by the `package-manager-cache` input, which defaults
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
package-manager-cache: false
@@ -212,7 +212,7 @@ jobs:
node: [ 20, 22, 24 ]
name: Node ${{ matrix.node }} sample
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Setup node
uses: actions/setup-node@v6
with:
@@ -249,6 +249,7 @@ If the runner is not able to access github.com, any Nodejs versions requested du
- [Publishing to npmjs and GPR with npm](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-npm)
- [Publishing to npmjs and GPR with yarn](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-yarn)
- [Using private packages](docs/advanced-usage.md#use-private-packages)
- [Using private mirror](docs/advanced-usage.md#use-private-mirror)
## Recommended permissions

View File

@@ -26,13 +26,13 @@ inputs:
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:
description: 'Used to specify an alternative mirror to downlooad Node.js binaries from'
description: 'Used to specify an alternative mirror to download Node.js binaries from'
mirror-token:
description: 'The token used as Authorization header when fetching from the mirror'
# TODO: add input to control forcing to pull from cloud or dist.
# escape valve for someone having issues or needing the absolute latest which isn't cached yet
outputs:
cache-hit:
cache-hit:
description: 'A boolean value to indicate if a cache was hit.'
node-version:
description: 'The installed node version.'

98771
dist/cache-save/index.js vendored

File diff suppressed because one or more lines are too long

98040
dist/setup/index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -8,7 +8,7 @@ Currently, `actions/setup-node` supports caching dependencies for Npm and Yarn p
For the first iteration, we have decided to not support cases where `package-lock.json` / `yarn.lock` are located outside of repository root.
Current implementation searches the following file patterns in the repository root: `package-lock.json`, `yarn.lock` (in order of resolving priorities)
Obviously, it made build-in caching unusable for mono-repos and repos with complex structure.
Obviously, it made built-in caching unusable for mono-repos and repos with complex structure.
We would like to revisit this decision and add customization for dependencies lock file location.
## Proposal
@@ -24,7 +24,7 @@ The second option looks more generic because it allows to:
## Decision
Add `cache-dependency-path` input that will accept path (relative to repository root) to dependencies lock file.
If provided path contains wildcards, the action will search all maching files and calculate common hash like `${{ hashFiles('**/package-lock.json') }}` YAML construction does.
If provided path contains wildcards, the action will search all matching files and calculate common hash like `${{ hashFiles('**/package-lock.json') }}` YAML construction does.
The hash of provided matched files will be used as a part of cache key.
Yaml examples:

View File

@@ -1,6 +1,6 @@
## Working with lockfiles
All supported package managers recommend that you **always** commit the lockfile, although implementations vary doing so generally provides the following benefits:
Most supported package managers recommend that you **always** commit the lockfile, although implementations vary doing so generally provides the following benefits:
- Enables faster installation for CI and production environments, due to being able to skip package resolution.
- Describes a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies.
@@ -35,6 +35,25 @@ Ensure that `pnpm-lock.yaml` is always committed, when on CI pass `--frozen-lock
- [Working with Git - Lockfiles](https://pnpm.io/git#lockfiles)
- [Documentation of `--frozen-lockfile` option](https://pnpm.io/cli/install#--frozen-lockfile)
### Running without a lockfile
If you choose not to use a lockfile, you must ensure that **caching is disabled**. The `cache` feature relies on the lockfile to generate a unique key for the cache entry.
To run without a lockfile:
1. Do not set the `cache` input.
2. If your `package.json` contains a `packageManager` field set to npm (or devEngines.packageManager), automatic caching is enabled by default. Override this by setting `package-manager-cache: false`.
```yaml
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24'
package-manager-cache: false # Explicitly disable caching if you don't have a lockfile
- run: npm install
- run: npm test
```
## Check latest version
The `check-latest` flag defaults to `false`. When set to `false`, the action will first check the local cache for a semver match. If unable to find a specific version in the cache, the action will attempt to download a version of Node.js. It will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/). Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific version of Node.js is always used.
@@ -45,7 +64,7 @@ If `check-latest` is set to `true`, the action first checks if the cached versio
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24'
@@ -63,7 +82,7 @@ See [supported version syntax](https://github.com/actions/setup-node#supported-v
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
@@ -97,7 +116,7 @@ jobs:
runs-on: windows-latest
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24'
@@ -118,7 +137,7 @@ jobs:
runs-on: ubuntu-latest
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24.0.0-v8-canary' # it will install the latest v8 canary release for node 24.0.0
@@ -133,7 +152,7 @@ jobs:
runs-on: ubuntu-latest
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24-v8-canary' # it will install the latest v8 canary release for node 24
@@ -149,7 +168,7 @@ jobs:
runs-on: ubuntu-latest
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 'v24.0.0-v8-canary2025030537242e55ac'
@@ -169,7 +188,7 @@ jobs:
runs-on: ubuntu-latest
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24-nightly' # it will install the latest nightly release for node 24
@@ -185,7 +204,7 @@ jobs:
runs-on: ubuntu-latest
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24.0.0-nightly' # it will install the latest nightly release for node 24.0.0
@@ -201,7 +220,7 @@ jobs:
runs-on: ubuntu-latest
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24.0.0-nightly202505066102159fa1'
@@ -219,7 +238,7 @@ jobs:
runs-on: ubuntu-latest
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24.0.0-rc.4'
@@ -237,7 +256,7 @@ Yarn caching handles both Yarn Classic (v1) and Yarn Berry (v2, v3, v4+).
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24'
@@ -256,7 +275,7 @@ steps:
# NOTE: pnpm caching support requires pnpm version >= 6.10.0
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
with:
version: 10
@@ -275,7 +294,7 @@ steps:
**Using wildcard patterns to cache dependencies**
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24'
@@ -288,7 +307,7 @@ steps:
**Using a list of file paths to cache dependencies**
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24'
@@ -308,10 +327,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
# Restore Node.js modules cache (restore-only)
- name: Restore Node modules cache
uses: actions/cache@v4
uses: actions/cache@v5
id: cache-node-modules
with:
path: ~/.npm
@@ -354,7 +373,7 @@ jobs:
architecture: x86
name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Setup node
uses: actions/setup-node@v6
with:
@@ -367,7 +386,7 @@ jobs:
## Publish to npmjs and GPR with npm
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24.x'
@@ -387,7 +406,7 @@ steps:
## Publish to npmjs and GPR with yarn
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24.x'
@@ -407,7 +426,7 @@ steps:
## Use private packages
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24.x'
@@ -427,7 +446,7 @@ Below you can find a sample "Setup .yarnrc.yml" step, that is going to allow you
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24.x'

2214
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "setup-node",
"version": "6.0.0",
"version": "6.2.0",
"private": true,
"description": "setup node action",
"main": "lib/setup-node.js",
@@ -28,7 +28,7 @@
"author": "GitHub",
"license": "MIT",
"dependencies": {
"@actions/cache": "^4.1.0",
"@actions/cache": "^5.0.1",
"@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1",
"@actions/github": "^6.0.1",

View File

@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"target": "ES2022", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */