chore: improve readme (#74)

This commit is contained in:
Luca Casonato
2024-09-13 17:32:16 +02:00
committed by GitHub
parent f1ac2c87b8
commit 8b162a5755
2 changed files with 52 additions and 8 deletions

View File

@@ -54,7 +54,7 @@ Targets the latest major, minor and patch version of Deno.
deno-version: e7b7129b7a92b7500ded88f8f5baa25a7f59e56e deno-version: e7b7129b7a92b7500ded88f8f5baa25a7f59e56e
``` ```
### Release candidate ### Latest release candidate
```yaml ```yaml
- uses: denoland/setup-deno@v1 - uses: denoland/setup-deno@v1
@@ -62,6 +62,14 @@ Targets the latest major, minor and patch version of Deno.
deno-version: rc deno-version: rc
``` ```
### Specific release candidate
```yaml
- uses: denoland/setup-deno@v1
with:
deno-version: 2.0.0-rc.1
```
### Version from file ### Version from file
The extension can also automatically read the version file from 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 ### Specifying binary name
This is useful when you want to install different versions of Deno side by side.
```yaml ```yaml
- uses: denoland/setup-deno@v1 - uses: denoland/setup-deno@v1
with: 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 }}"
``` ```

View File

@@ -7,13 +7,13 @@ const GIT_HASH_RE = /^[0-9a-fA-F]{40}$/;
/** /**
* @typedef VersionRange * @typedef VersionRange
* @property {string} range * @property {string} range
* @property {"canary" | "rc" | "release"} kind * @property {"canary" | "rc" | "stable"} kind
*/ */
/** /**
* @typedef Version * @typedef Version
* @property {string} 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") { if (version === "latest") {
return { range: "latest", kind: "release" }; return { range: "latest", kind: "stable" };
} }
if (GIT_HASH_RE.test(version)) { if (GIT_HASH_RE.test(version)) {
@@ -44,7 +44,7 @@ export function parseVersionRange(version) {
const range = semver.validRange(version); const range = semver.validRange(version);
if (range !== null) { if (range !== null) {
return { range, kind: "release" }; return { range, kind: "stable" };
} }
return null; return null;
@@ -154,7 +154,7 @@ async function resolveRelease(range) {
if (version === null) { if (version === null) {
throw new Error("Failed to parse release version."); throw new Error("Failed to parse release version.");
} }
return { version, kind: "release" }; return { version, kind: "stable" };
} else { } else {
const res = await fetchWithRetries("https://deno.com/versions.json"); const res = await fetchWithRetries("https://deno.com/versions.json");
if (res.status !== 200) { if (res.status !== 200) {
@@ -182,7 +182,7 @@ async function resolveRelease(range) {
version = semver.clean(version); version = semver.clean(version);
if (version === null) throw new Error("UNREACHABLE"); if (version === null) throw new Error("UNREACHABLE");
return { version, kind: "release" }; return { version, kind: version.includes("-rc.") ? "rc" : "stable" };
} }
} }