Limit automatic caching to npm, update workflows and documentation (#1374)

* default to auto-caching only for npm package manager and documentation update

* refactor: enhance package manager detection for auto-caching

* add devEngines.packageManager detection logic for npm auto-caching

* chore: bump version to 6.0.0 and update documentation

* docs: update README and action.yml for npm caching logic clarification

* chore: update Node.js version in workflows

* chore: update Node.js versions in versions.yml

* chore: update rc Node.js version in versions.yml

* chore: switch macos-13 runner to macos-latest-large in workflow

* docs: update README and advanced usage documentation
This commit is contained in:
Priya Gupta
2025-10-14 08:07:06 +05:30
committed by GitHub
parent 13427813f7
commit 2028fbc5c2
12 changed files with 331 additions and 180 deletions

View File

@@ -46,9 +46,9 @@ If `check-latest` is set to `true`, the action first checks if the cached versio
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '16'
node-version: '24'
check-latest: true
- run: npm ci
- run: npm test
@@ -64,7 +64,7 @@ See [supported version syntax](https://github.com/actions/setup-node#supported-v
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
- run: npm ci
@@ -98,9 +98,9 @@ jobs:
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '14'
node-version: '24'
architecture: 'x64' # optional, x64 or x86. If not specified, x64 will be used by default
- run: npm ci
- run: npm test
@@ -119,9 +119,9 @@ jobs:
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '20.0.0-v8-canary' # it will install the latest v8 canary release for node 20.0.0
node-version: '24.0.0-v8-canary' # it will install the latest v8 canary release for node 24.0.0
- run: npm ci
- run: npm test
```
@@ -134,9 +134,9 @@ jobs:
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '20-v8-canary' # it will install the latest v8 canary release for node 20
node-version: '24-v8-canary' # it will install the latest v8 canary release for node 24
- run: npm ci
- run: npm test
```
@@ -150,9 +150,9 @@ jobs:
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: 'v20.1.1-v8-canary20221103f7e2421e91'
node-version: 'v24.0.0-v8-canary2025030537242e55ac'
- run: npm ci
- run: npm test
```
@@ -170,9 +170,9 @@ jobs:
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '16-nightly' # it will install the latest nightly release for node 16
node-version: '24-nightly' # it will install the latest nightly release for node 24
- run: npm ci
- run: npm test
```
@@ -186,9 +186,9 @@ jobs:
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '16.0.0-nightly' # it will install the latest nightly release for node 16.0.0
node-version: '24.0.0-nightly' # it will install the latest nightly release for node 24.0.0
- run: npm ci
- run: npm test
```
@@ -202,9 +202,9 @@ jobs:
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '16.0.0-nightly20210420a0261d231c'
node-version: '24.0.0-nightly202505066102159fa1'
- run: npm ci
- run: npm test
```
@@ -220,26 +220,27 @@ jobs:
name: Node sample
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '16.0.0-rc.1'
node-version: '24.0.0-rc.4'
- run: npm ci
- run: npm test
```
**Note:** Unlike nightly versions, which support version range specifiers, you must specify the exact version for a release candidate: `16.0.0-rc.1`.
**Note:** Unlike nightly versions, which support version range specifiers, you must specify the exact version for a release candidate: `24.0.0-rc.4`.
## Caching packages data
The action follows [actions/cache](https://github.com/actions/cache/blob/main/examples.md#node---npm) guidelines, and caches global cache on the machine instead of `node_modules`, so cache can be reused between different Node.js versions.
**Caching yarn dependencies:**
Yarn caching handles both yarn versions: 1 or 2.
Yarn caching handles both Yarn Classic (v1) and Yarn Berry (v2, v3, v4+).
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '14'
node-version: '24'
cache: 'yarn'
- run: yarn install --frozen-lockfile # optional, --immutable
- run: yarn test
@@ -256,12 +257,12 @@ steps:
steps:
- uses: actions/checkout@v5
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v4
with:
version: 6.32.9
- uses: actions/setup-node@v5
version: 10
- uses: actions/setup-node@v6
with:
node-version: '14'
node-version: '24'
cache: 'pnpm'
- run: pnpm install
- run: pnpm test
@@ -275,9 +276,9 @@ steps:
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '14'
node-version: '24'
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- run: npm ci
@@ -288,9 +289,9 @@ steps:
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '14'
node-version: '24'
cache: 'npm'
cache-dependency-path: |
server/app/package-lock.json
@@ -312,21 +313,21 @@ jobs:
- macos-latest
- windows-latest
node_version:
- 12
- 14
- 16
- 20
- 22
- 24
architecture:
- x64
# an extra windows-x86 run:
include:
- os: windows-2016
node_version: 12
- os: windows-latest
node_version: 24
architecture: x86
name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- name: Setup node
uses: actions/setup-node@v5
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node_version }}
architecture: ${{ matrix.architecture }}
@@ -338,15 +339,15 @@ jobs:
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '14.x'
node-version: '24.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
registry-url: 'https://npm.pkg.github.com'
- run: npm publish
@@ -358,15 +359,15 @@ steps:
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '14.x'
node-version: '24.x'
registry-url: <registry url>
- run: yarn install --frozen-lockfile
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
registry-url: 'https://npm.pkg.github.com'
- run: yarn publish
@@ -378,9 +379,9 @@ steps:
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '14.x'
node-version: '24.x'
registry-url: 'https://registry.npmjs.org'
# Skip post-install scripts here, as a malicious
# script could steal NODE_AUTH_TOKEN.
@@ -398,9 +399,9 @@ Below you can find a sample "Setup .yarnrc.yml" step, that is going to allow you
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v6
with:
node-version: '14.x'
node-version: '24.x'
- name: Setup .yarnrc.yml
run: |
yarn config set npmScopes.my-org.npmRegistryServer "https://npm.pkg.github.com"
@@ -427,9 +428,9 @@ 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@v5
- uses: actions/setup-node@v6
with:
node-version: '14.x'
node-version: '24.x'
mirror: 'https://nodejs.org/dist'
mirror-token: 'your-mirror-token'
```