action-setup/README.md

132 lines
3.3 KiB
Markdown
Raw Normal View History

2021-03-27 19:45:01 +08:00
# Setup pnpm
2020-05-08 15:44:30 +08:00
2021-03-27 19:45:01 +08:00
Install pnpm package manager.
2020-05-08 15:44:30 +08:00
## Inputs
### `version`
2021-09-04 06:53:31 +08:00
Can either specifiy a specific version of pnpm to install (e.g. "6.14.6") or can
specifiy a version range (in the [semver range
format](https://github.com/npm/node-semver#ranges)). The latest version to
match the range is used and if the input version is not specified, the latest
overall version is used. Version ranges are only supported for versions
starting at 6.13.0 and higher, because that is the first version of pnpm to be
published to github releases.
2020-05-08 15:44:30 +08:00
### `dest`
2021-09-04 06:53:31 +08:00
This option is obsolete. It is only used when a specific version of pnpm which
is 6.12 or lower is specified. For these old versions of pnpm, the `dest` input
is where to store pnpm files.
2020-05-08 15:44:30 +08:00
2020-05-09 20:13:46 +08:00
### `run_install`
2021-09-04 06:53:31 +08:00
If specified, run `pnpm install`.
2020-05-09 20:13:46 +08:00
2021-09-04 06:53:31 +08:00
If `run_install` is either `null` (the default) or `false`, pnpm will not install any npm package.
2020-05-10 13:08:45 +08:00
If `run_install` is `true`, pnpm will install dependencies recursively.
2020-05-10 13:14:27 +08:00
If `run_install` is a YAML string representation of either an object or an array, pnpm will execute every install commands.
2020-05-10 13:08:45 +08:00
#### `run_install.recursive`
2021-09-04 06:53:31 +08:00
(_type:_ `boolean`, _default:_ `false`) Whether to use `pnpm recursive install`.
2020-05-10 13:08:45 +08:00
#### `run_install.cwd`
2021-09-04 06:53:31 +08:00
(_type:_ `string`) Working directory when run `pnpm [recursive] install`.
2020-05-10 13:08:45 +08:00
#### `run_install.args`
2021-09-04 06:53:31 +08:00
(_type:_ `string[]`) Additional arguments after `pnpm [recursive] install`, e.g. `[--frozen-lockfile, --strict-peer-dependencies]`.
2020-05-10 13:08:45 +08:00
2020-05-08 15:44:30 +08:00
## Outputs
2021-09-04 06:53:31 +08:00
### `bin_dest`
2020-05-08 15:44:30 +08:00
2021-09-04 06:53:31 +08:00
Folder containing the `pnpm` executable.
2020-05-08 15:44:30 +08:00
2021-09-04 06:53:31 +08:00
### `dest`
2020-05-08 15:44:30 +08:00
2021-09-04 06:53:31 +08:00
Expanded path of inputs#dest, only set if a version before "6.14.6" is specified.
2020-05-08 15:44:30 +08:00
## Usage example
2021-09-04 06:53:31 +08:00
### Install latest pnpm and cache store
The following yaml will first install the latest version of pnpm, install node,
and setup caching of the pnpm store.
[actions/setup-node](https://github.com/actions/setup-node) has support for
caching the pnpm store, as long as pnpm is installed first.
2020-05-10 13:14:27 +08:00
```yaml
2021-09-04 06:53:31 +08:00
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.0.1
- uses: actions/setup-node@v2
with:
node-version: "16"
cache: "pnpm"
- run: pnpm install --frozen-lockfile
2020-05-10 13:14:27 +08:00
2021-09-04 06:53:31 +08:00
# more build/run commands ...
2020-05-10 13:14:27 +08:00
2021-09-04 06:53:31 +08:00
- run: pnpm store prune
2020-05-10 13:14:27 +08:00
```
2021-09-04 06:53:31 +08:00
### Install specific range of pnpm
2020-05-10 13:14:27 +08:00
2020-05-08 15:44:30 +08:00
```yaml
2021-09-04 06:53:31 +08:00
steps:
- uses: actions/checkout@v2
2020-05-08 15:44:30 +08:00
2021-09-04 06:53:31 +08:00
- uses: pnpm/action-setup@v2.0.1
with:
version: "^6.14.6"
2021-09-04 06:53:31 +08:00
- uses: actions/setup-node@v2
with:
node-version: "16"
cache: "pnpm"
- run: pnpm install --frozen-lockfile
# more build/run commands ...
- run: pnpm store prune
```
2021-09-04 06:53:31 +08:00
### Install pnpm and a few npm packages
2021-09-04 06:53:31 +08:00
Unfortunately, using `run_install` does not work together with the caching
in `actions/setup-node`. The caching in `actions/setup-node` requires pnpm
to be installed before node, while the `run_install` option
requires node to be installed first. In this situation, you will need to setup
the caching yourself.
2020-05-08 15:44:30 +08:00
2021-09-04 06:53:31 +08:00
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "16"
- uses: pnpm/action-setup@v2.0.1
with:
version: "6.*"
run_install: |
- recursive: true
args: [--frozen-lockfile, --strict-peer-dependencies]
- args: [--global, gulp, prettier, typescript]
# Setup caching here using actions/cache
```
2020-05-08 15:44:30 +08:00
## License
[MIT](https://git.io/JfclH) © [Hoàng Văn Khải](https://github.com/KSXGitHub/)