Skip to content

Commit 22b496f

Browse files
authored
Merge pull request #184 from opt-nc/refresh-dist
chore: update dist directory
2 parents 95d2ed7 + 7da6355 commit 22b496f

File tree

2 files changed

+50
-11
lines changed

2 files changed

+50
-11
lines changed

dist/index.js

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,64 @@ const core = __nccwpck_require__(7484);
88
const { exec } = __nccwpck_require__(5317);
99
const axios = __nccwpck_require__(7269);
1010

11+
const maxAttempts = 3; // Maximum number of attempts for retries
12+
const waitingTime = 1000; // Initial waiting time in milliseconds
13+
14+
1115
module.exports = async function () {
1216
try {
1317
const inputVersion = core.getInput('version');
1418
let latestVersion;
1519
let selectedVersion;
1620

17-
core.debug(`🔍 looking for the latest DuckDB version.`);
21+
core.debug(`🔍 Looking for the latest DuckDB version...`);
1822
const headers = {'Accept': 'application/vnd.github+json', 'X-GitHub-Api-Version': '2022-11-28'}
19-
const res = await axios.get('https://api.github.com/repos/duckdb/duckdb/releases/latest', {headers: headers});
20-
if (res.status != 200) {
21-
core.error(`❌ Failed to get latest DuckDB version`);
22-
core.setFailed(res.statusText);
23-
} else {
24-
core.debug(`✔️ Latest DuckDB version found is ${res.data.tag_name}.`);
25-
latestVersion = res.data.tag_name;
23+
// Retry logic for axios.get (up to 3 attempts)
24+
let res;
25+
let attempt = 1;
26+
let success = false;
27+
core.info(`🔁 Attempting to get the latest DuckDB version (max attempts: ${maxAttempts})`);
28+
while (attempt < maxAttempts && !success) {
29+
core.info(`🔁 Attempt ${attempt}/${maxAttempts} to get the latest DuckDB version...`);
30+
try {
31+
core.info(`🔍 Attempting to fetch latest DuckDB version from GitHub API...`);
32+
res = await axios.get('https://api.github.com/repos/duckdb/duckdb/releases/latest', {headers: headers});
33+
if (res.status === 200) {
34+
success = true;
35+
core.info(`ℹ️ Latest DuckDB version found is ${res.data.tag_name}.`);
36+
latestVersion = res.data.tag_name;
37+
} else {
38+
if (attempt < maxAttempts) {
39+
core.warning(`⚠️ Failed to get latest DuckDB version (status ${res.status}), attempt ${attempt} of ${maxAttempts}`);
40+
} else {
41+
core.error(`❌ Failed to get latest DuckDB version (status ${res.status}), last attempt (${attempt})`);
42+
}
43+
attempt++;
44+
if (attempt < maxAttempts) {
45+
core.info(`🔁 Retry attempt ${attempt}...`);
46+
await new Promise(r => setTimeout(r, waitingTime * attempt));
47+
}
48+
}
49+
} catch (err) {
50+
if (attempt < maxAttempts) {
51+
core.warning(`⚠️ Attempt ${attempt} failed: ${err.message}`);
52+
} else {
53+
core.error(`❌ Attempt ${attempt} failed: ${err.message}`);
54+
}
55+
attempt++;
56+
if (attempt < maxAttempts) {
57+
core.info(`🔁 Retry attempt ${attempt}...`);
58+
await new Promise(r => setTimeout(r, waitingTime * attempt));
59+
}
60+
}
61+
}
62+
if (!success) {
63+
core.setFailed(`❌ Failed to get latest DuckDB version after ${maxAttempts} attempts.`);
64+
return;
2665
}
2766

2867
if (inputVersion === 'latest') {
29-
core.info(`📦 DuckDb latest version requested : ${latestVersion} will be installed.`);
68+
core.info(`ℹ️ DuckDb latest version requested : ${latestVersion} will be installed.`);
3069
selectedVersion = latestVersion;
3170
}
3271
else {
@@ -59,7 +98,7 @@ module.exports = async function () {
5998
if (stderr) {
6099
core.debug(stderr);
61100
}
62-
core.info(`🚀 DuckDB ${selectedVersion} successfully installed.`);
101+
core.info(`✔️ DuckDB ${selectedVersion} successfully installed.`);
63102
});
64103
} catch (error) {
65104
core.setFailed(error.message);

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)