mirror of
https://gitea.com/actions/setup-deno.git
synced 2025-12-10 18:36:42 +00:00
149 lines
3.6 KiB
Markdown
149 lines
3.6 KiB
Markdown
# setup-deno
|
|
|
|
Set up your GitHub Actions workflow with a specific version of Deno.
|
|
|
|
## Usage
|
|
|
|
The installed version is `v2.x` by default.
|
|
|
|
```yaml
|
|
- uses: denoland/setup-deno@v2
|
|
```
|
|
|
|
### Version from input
|
|
|
|
To pick the latest version of specific release channel, set `deno-version` to
|
|
one of the following:
|
|
|
|
| Channel | Description |
|
|
| -------- | -------------------------------- |
|
|
| `stable` | Latest Stable release version |
|
|
| `lts` | Latest Long-Term-Support version |
|
|
| `rc` | Latest Release-Candidate version |
|
|
| `canary` | Latest Canary release version |
|
|
|
|
```yaml
|
|
- uses: denoland/setup-deno@v2
|
|
with:
|
|
deno-version: lts
|
|
```
|
|
|
|
A version can also be selected by providing a valid [Semver][sv] range or commit
|
|
hash.
|
|
|
|
**Examples**
|
|
|
|
- Specific versions: `"1.8.2"`, `2.0.0-rc.1`
|
|
- Semver range: `"^2"`, `"~1.7"`, `v2.1.x`, `vx.x.x`
|
|
- Commit hash: `e7b7129b7a92b7500ded88f8f5baa25a7f59e56e`
|
|
|
|
```yaml
|
|
- uses: denoland/setup-deno@v2
|
|
with:
|
|
deno-version: v2.1.x
|
|
```
|
|
|
|
[sv]: https://devhints.io/semver
|
|
|
|
### Version from file
|
|
|
|
The extension can also automatically read the version file from
|
|
[`.tool-versions`](https://asdf-vm.com/manage/configuration.html#tool-versions)
|
|
|
|
```yaml
|
|
- uses: denoland/setup-deno@v2
|
|
with:
|
|
deno-version-file: .tool-versions
|
|
```
|
|
|
|
The extension can also automatically read the file from
|
|
[`dvm`](https://github.com/justjavac/dvm).
|
|
|
|
```yaml
|
|
- uses: denoland/setup-deno@v2
|
|
with:
|
|
deno-version-file: .dvmrc
|
|
```
|
|
|
|
### Specifying binary name
|
|
|
|
This is useful when you want to install different versions of Deno side by side.
|
|
|
|
```yaml
|
|
- uses: denoland/setup-deno@v2
|
|
with:
|
|
deno-version: canary
|
|
deno-binary-name: deno_canary
|
|
```
|
|
|
|
### Determining the release channel
|
|
|
|
You can determine the release channel reading back the `release-channel` output.
|
|
|
|
Valid values are `stable`, `lts`, `canary` and `rc`.
|
|
|
|
```yaml
|
|
- uses: denoland/setup-deno@v2
|
|
id: deno
|
|
with:
|
|
deno-version: canary
|
|
|
|
- run: echo "Deno release channel is ${{ steps.deno.outputs.release-channel }}"
|
|
```
|
|
|
|
### Determining the installed version
|
|
|
|
You can determine the installed version reading back the `deno-version` output.
|
|
|
|
For canary versions, the output will be in the form `0.0.0-GIT_HASH`.
|
|
|
|
For stable and rc versions, the output will be the regular semver version
|
|
number.
|
|
|
|
```yaml
|
|
- uses: denoland/setup-deno@v2
|
|
id: deno
|
|
with:
|
|
deno-version: canary
|
|
|
|
- run: echo "Deno version is ${{ steps.deno.outputs.deno-version }}"
|
|
```
|
|
|
|
### Caching dependencies downloaded by Deno automatically
|
|
|
|
Dependencies installed by Deno can be cached automatically between workflow
|
|
runs. This helps make your GH action run faster by not repeating caching work
|
|
and network requests done by a previous run.
|
|
|
|
To enable the cache, use `cache: true`.
|
|
|
|
```yaml
|
|
- uses: denoland/setup-deno@v2
|
|
with:
|
|
cache: true
|
|
```
|
|
|
|
> [!WARNING]
|
|
> If an environment variable `DENO_DIR` is set for steps that run/download
|
|
> dependencies, then `DENO_DIR` must also be set for the `denoland/setup-deno`
|
|
> action, for the caching to work as intended.
|
|
|
|
By default, the cache is automatically keyed by:
|
|
|
|
- the github
|
|
[job_id](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_id)
|
|
- the runner os and architecture
|
|
- a hash of the `deno.lock` files in the project
|
|
|
|
It is possible to customize the default hash
|
|
(`${{ hashFiles('**/deno.lock') }}`) used as part of the cache key via the
|
|
`cache-hash` input.
|
|
|
|
```yaml
|
|
- uses: denoland/setup-deno@v2
|
|
with:
|
|
# setting `cache-hash` implies `cache: true` and will replace
|
|
# the default cache-hash of `${{ hashFiles('**/deno.lock') }}`
|
|
cache-hash: ${{ hashFiles('**/deno.json') }}
|
|
```
|