From 8b162a57558484446e77e82149e9864b23fb72d3 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Fri, 13 Sep 2024 17:32:16 +0200 Subject: [PATCH] chore: improve readme (#74) --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- src/version.mjs | 12 ++++++------ 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7871d8e..ad24fef 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Targets the latest major, minor and patch version of Deno. deno-version: e7b7129b7a92b7500ded88f8f5baa25a7f59e56e ``` -### Release candidate +### Latest release candidate ```yaml - uses: denoland/setup-deno@v1 @@ -62,6 +62,14 @@ Targets the latest major, minor and patch version of Deno. deno-version: rc ``` +### Specific release candidate + +```yaml +- uses: denoland/setup-deno@v1 + with: + deno-version: 2.0.0-rc.1 +``` + ### Version from file The extension can also automatically read the version file from @@ -84,8 +92,44 @@ The extension can also automatically read the file from ### Specifying binary name +This is useful when you want to install different versions of Deno side by side. + ```yaml - uses: denoland/setup-deno@v1 with: - deno-binary-name: deno_latest + 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`, `canary` and `rc`. + +```yaml +- uses: denoland/setup-deno@v1 + 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@v1 + id: deno + with: + deno-version: canary + +- run: echo "Deno version is ${{ steps.deno.outputs.deno-version }}" ``` diff --git a/src/version.mjs b/src/version.mjs index 5a940d3..8f5f8f8 100644 --- a/src/version.mjs +++ b/src/version.mjs @@ -7,13 +7,13 @@ const GIT_HASH_RE = /^[0-9a-fA-F]{40}$/; /** * @typedef VersionRange * @property {string} range - * @property {"canary" | "rc" | "release"} kind + * @property {"canary" | "rc" | "stable"} kind */ /** * @typedef Version * @property {string} version - * @property {"canary" | "rc" | "release"} kind + * @property {"canary" | "rc" | "stable"} kind */ /** @@ -35,7 +35,7 @@ export function parseVersionRange(version) { } if (version === "latest") { - return { range: "latest", kind: "release" }; + return { range: "latest", kind: "stable" }; } if (GIT_HASH_RE.test(version)) { @@ -44,7 +44,7 @@ export function parseVersionRange(version) { const range = semver.validRange(version); if (range !== null) { - return { range, kind: "release" }; + return { range, kind: "stable" }; } return null; @@ -154,7 +154,7 @@ async function resolveRelease(range) { if (version === null) { throw new Error("Failed to parse release version."); } - return { version, kind: "release" }; + return { version, kind: "stable" }; } else { const res = await fetchWithRetries("https://deno.com/versions.json"); if (res.status !== 200) { @@ -182,7 +182,7 @@ async function resolveRelease(range) { version = semver.clean(version); if (version === null) throw new Error("UNREACHABLE"); - return { version, kind: "release" }; + return { version, kind: version.includes("-rc.") ? "rc" : "stable" }; } }