feat: add deno-version-file

This commit is contained in:
Solomon Victorino 2024-01-14 12:03:41 -07:00
parent 0df5d9c641
commit b98e162ce4
3 changed files with 17 additions and 3 deletions

View File

@ -4,6 +4,14 @@ Set up your GitHub Actions workflow with a specific version of Deno.
## Usage ## Usage
### Version from file
```yaml
- uses: denoland/setup-deno@v1
with:
deno-version-file: .dvmrc
```
### Latest stable for a major ### Latest stable for a major
```yaml ```yaml

View File

@ -6,8 +6,9 @@ branding:
color: "gray-dark" color: "gray-dark"
inputs: inputs:
deno-version: deno-version:
description: The Deno version to install. Can be a semver version of a stable release, "canary" for the latest canary, or the Git hash of a specific canary release. description: The Deno version to install. Can be a semver version of a stable release, "canary" for the latest canary, or the Git hash of a specific canary release. Defaults to "1.x".
default: "1.x" deno-version-file:
description: File containing the Deno version to install. Overridden by deno-version.
outputs: outputs:
deno-version: deno-version:
description: "The Deno version that was installed." description: "The Deno version that was installed."

View File

@ -1,3 +1,4 @@
const fs = require("fs");
const process = require("process"); const process = require("process");
const core = require("@actions/core"); const core = require("@actions/core");
@ -15,7 +16,11 @@ function exit(message) {
async function main() { async function main() {
try { try {
const range = parseVersionRange(core.getInput("deno-version")); const denoVersionFile = core.getInput("deno-version-file");
const range = parseVersionRange(
core.getInput("deno-version") ||
(denoVersionFile ? fs.readFileSync(denoVersionFile, "utf8") : "1.x"),
);
if (range === null) { if (range === null) {
exit("The passed version range is not valid."); exit("The passed version range is not valid.");
} }