7 Commits

Author SHA1 Message Date
Yoshiya Hinosawa
041b854f97 1.1.4 (#57) 2024-01-29 13:20:15 +09:00
ctdeakin
ef28d469f1 chore: update node.js version from 16 to 20 (#56) 2024-01-28 21:01:15 +09:00
David Sherret
0df5d9c641 1.1.3 (#50) 2023-09-27 18:27:29 -04:00
David Sherret
85bf53342c feat: fetch versions with retries (#46) 2023-05-30 18:18:39 -04:00
crowlkats
61fe2df320 1.1.2 2023-05-03 12:06:57 +02:00
Leo Kettmeir
b41525049b refactor: use versions.js from deno.com instead of github (#45) 2023-05-01 14:14:43 +02:00
Eliaz Bobadilla
d114c5eb74 chore: bump actions/checkout (#30) 2023-01-12 22:57:40 +01:00
6 changed files with 38 additions and 16 deletions

View File

@@ -13,10 +13,10 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
deno:
[1.x, "1.8.2", canary, ~1.7, e7b7129b7a92b7500ded88f8f5baa25a7f59e56e]
[1.x, "1.33.1", canary, ~1.32, b31cf9fde6ad5398c20370c136695db77df6beeb]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Deno
uses: ./
@@ -24,12 +24,12 @@ jobs:
deno-version: ${{ matrix.deno }}
- name: Test Deno
run: deno run https://deno.land/std/examples/welcome.ts
run: deno run https://deno.land/std@0.198.0/examples/welcome.ts
- name: Test `deno install`
run: |
deno install --allow-net -n deno_curl https://deno.land/std/examples/curl.ts
deno_curl https://deno.land/std/examples/curl.ts
deno install --allow-net -n deno_curl https://deno.land/std@0.198.0/examples/curl.ts
deno_curl https://deno.land/std@0.198.0/examples/curl.ts
- name: Format
if: runner.os == 'Linux' && matrix.deno == 'canary'

View File

@@ -14,5 +14,5 @@ outputs:
is-canary:
description: "If the installed Deno version was a canary version."
runs:
using: "node16"
using: "node20"
main: "main.js"

4
node_modules/.package-lock.json generated vendored
View File

@@ -1,7 +1,7 @@
{
"name": "setup-deno",
"version": "1.1.0",
"lockfileVersion": 2,
"version": "1.1.4",
"lockfileVersion": 3,
"requires": true,
"packages": {
"node_modules/@actions/core": {

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "setup-deno",
"version": "1.1.0",
"version": "1.1.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "setup-deno",
"version": "1.1.0",
"version": "1.1.4",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.0",

View File

@@ -1,7 +1,7 @@
{
"name": "setup-deno",
"description": "Set up Deno easially in GitHub Actions",
"version": "1.1.1",
"version": "1.1.4",
"author": "Deno Land Inc",
"license": "MIT",
"scripts": {

View File

@@ -48,7 +48,9 @@ function parseVersionRange(version) {
async function resolveVersion({ range, isCanary }) {
if (isCanary) {
if (range === "latest") {
const res = await fetch("https://dl.deno.land/canary-latest.txt");
const res = await fetchWithRetries(
"https://dl.deno.land/canary-latest.txt",
);
if (res.status !== 200) {
throw new Error(
"Failed to fetch canary version info from dl.deno.land. Please try again later.",
@@ -60,12 +62,10 @@ async function resolveVersion({ range, isCanary }) {
return { version: range, isCanary: true };
}
const res = await fetch(
"https://raw.githubusercontent.com/denoland/dotland/main/versions.json",
);
const res = await fetchWithRetries("https://deno.com/versions.json");
if (res.status !== 200) {
throw new Error(
"Failed to fetch stable version info from raw.githubusercontent.com. Please try again later.",
"Failed to fetch stable version info from deno.com/versions.json. Please try again later.",
);
}
const versionJson = await res.json();
@@ -90,6 +90,28 @@ async function resolveVersion({ range, isCanary }) {
return { version, isCanary: false };
}
/** @param {string} url */
async function fetchWithRetries(url, maxRetries = 5) {
let sleepMs = 250;
let iterationCount = 0;
while (true) {
iterationCount++;
try {
const res = await fetch(url);
if (res.status === 200 || iterationCount > maxRetries) {
return res;
}
} catch (err) {
if (iterationCount > maxRetries) {
throw err;
}
}
console.warn(`Failed fetching. Retrying in ${sleepMs}ms...`);
await new Promise((resolve) => setTimeout(resolve, sleepMs));
sleepMs = Math.min(sleepMs * 2, 10_000);
}
}
module.exports = {
parseVersionRange,
resolveVersion,