mirror of
https://gitea.com/actions/setup-node.git
synced 2025-09-10 10:19:48 +08:00
Compare commits
4 Commits
main
...
8b6276bb7f
Author | SHA1 | Date | |
---|---|---|---|
|
8b6276bb7f | ||
|
7076b64b61 | ||
|
590e8bb34a | ||
|
0ded3caa7a |
18
.github/workflows/e2e-cache.yml
vendored
18
.github/workflows/e2e-cache.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
node-version: [18, 20, 22, 24]
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: prepare sub-projects
|
||||
run: __tests__/prepare-yarn-subprojects.sh yarn1
|
||||
@@ -170,7 +170,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: prepare sub-projects
|
||||
run: __tests__/prepare-yarn-subprojects.sh global
|
||||
@@ -224,7 +224,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- 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@v5
|
||||
- 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
|
||||
|
4
.github/workflows/proxy.yml
vendored
4
.github/workflows/proxy.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
||||
env:
|
||||
https_proxy: http://squid-proxy:3128
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- name: Clear tool cache
|
||||
run: rm -rf $RUNNER_TOOL_CACHE/*
|
||||
- name: Setup node 11
|
||||
|
@@ -14,7 +14,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checking out
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
- name: Publish
|
||||
id: publish
|
||||
uses: actions/publish-immutable-action@v0.0.4
|
||||
|
28
.github/workflows/versions.yml
vendored
28
.github/workflows/versions.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
node-version: [18, 20, 22, 24]
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Node
|
||||
uses: ./
|
||||
with:
|
||||
@@ -64,7 +64,7 @@ jobs:
|
||||
'20.0.0-v8-canary20221101e50e45c9f8'
|
||||
]
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Node from dist
|
||||
uses: ./
|
||||
with:
|
||||
@@ -222,7 +222,7 @@ jobs:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-13]
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
# 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- 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@v5
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Node
|
||||
uses: ./
|
||||
with:
|
||||
|
27
README.md
27
README.md
@@ -14,13 +14,15 @@ This action provides the following functionality for GitHub Actions users:
|
||||
|
||||
## 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.
|
||||
- Enhance caching in setup-node with automatic package manager detection in [#1348](https://github.com/actions/setup-node/pull/1348)
|
||||
|
||||
- Upgrade action to use node24 by @salmanmkc in https://github.com/actions/setup-node/pull/1325
|
||||
Make sure your runner is on version v2.327.1 or later to ensure compatibility with this release. [See Release Notes](https://github.com/actions/runner/releases/tag/v2.327.1)
|
||||
|
||||
For more detailed release notes with documntation updates and dependency upgrades, please track [release notes](https://github.com/actions/setup-node/releases/edit/v5.0.0)
|
||||
|
||||
|
||||
- Upgraded action from node20 to node24.
|
||||
> Make sure your runner is on version v2.327.1 or later to ensure compatibility with this release. [See Release Notes](https://github.com/actions/runner/releases/tag/v2.327.1)
|
||||
|
||||
For more details, see the full release notes on the [releases page](https://github.com/actions/setup-node/releases/v5.0.0)
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -67,14 +69,14 @@ See [action.yml](action.yml)
|
||||
# Default: ''
|
||||
cache: ''
|
||||
|
||||
# Used 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 and no cache input is provided'
|
||||
# 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.
|
||||
# Supports wildcards or a list of file names for caching multiple dependencies.
|
||||
# Default: ''
|
||||
package-manager-cache: false
|
||||
|
||||
# Used 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: ''
|
||||
|
||||
# Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file,
|
||||
@@ -161,7 +163,7 @@ steps:
|
||||
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. 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.
|
||||
> 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.
|
||||
|
||||
@@ -264,4 +266,7 @@ Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
:wave: Be nice. See [our code of conduct](CODE_OF_CONDUCT.md)
|
||||
:wave: Be nice. See [our code of conduct](CODE_OF_CONDUCT.md)
|
||||
|
||||
|
||||
[def]: https://github.com/actions/runner/releases/tag/v2.327.1
|
3
dist/setup/index.js
vendored
3
dist/setup/index.js
vendored
@@ -99793,9 +99793,6 @@ function run() {
|
||||
yield (0, cache_restore_1.restoreCache)(cache, cacheDependencyPath);
|
||||
}
|
||||
else if (resolvedPackageManager && packagemanagercache) {
|
||||
core.info("Detected package manager from package.json's packageManager field: " +
|
||||
resolvedPackageManager +
|
||||
'. Auto caching has been enabled for it. If you want to disable it, set package-manager-cache input to false');
|
||||
core.saveState(constants_1.State.CachePackageManager, resolvedPackageManager);
|
||||
yield (0, cache_restore_1.restoreCache)(resolvedPackageManager, cacheDependencyPath);
|
||||
}
|
||||
|
@@ -73,11 +73,6 @@ export async function run() {
|
||||
core.saveState(State.CachePackageManager, cache);
|
||||
await restoreCache(cache, cacheDependencyPath);
|
||||
} else if (resolvedPackageManager && packagemanagercache) {
|
||||
core.info(
|
||||
"Detected package manager from package.json's packageManager field: " +
|
||||
resolvedPackageManager +
|
||||
'. Auto caching has been enabled for it. If you want to disable it, set package-manager-cache input to false'
|
||||
);
|
||||
core.saveState(State.CachePackageManager, resolvedPackageManager);
|
||||
await restoreCache(resolvedPackageManager, cacheDependencyPath);
|
||||
}
|
||||
|
Reference in New Issue
Block a user