fix: workflow artifacts upload skipped if retryAttempts == 0 (#1206)

This commit is contained in:
Fabian-Lars
2025-11-22 13:43:40 +01:00
committed by GitHub
parent eb340419f7
commit 4b9065fb22
4 changed files with 22 additions and 10 deletions

15
dist/index.js vendored
View File

@@ -84654,7 +84654,7 @@ class Runner {
args.push('--');
}
args.push(...commandOptions);
return (0,utils/* retry */.L5)(() => (0,utils/* execCommand */.NK)(this.bin, args, { cwd }, env), retryAttempts + 1);
return (0,utils/* retry */.L5)(() => (0,utils/* execCommand */.NK)(this.bin, args, { cwd }, env), retryAttempts);
}
}
async function getRunner() {
@@ -85579,7 +85579,7 @@ async function uploadAssets(releaseId, assets, retryAttempts) {
owner: _inputs__WEBPACK_IMPORTED_MODULE_3__/* .owner */ .eC,
repo: _inputs__WEBPACK_IMPORTED_MODULE_3__/* .repo */ .LB,
release_id: releaseId,
}), retryAttempts + 1);
}), retryAttempts);
console.log(`${assetName} successfully uploaded.`);
}
}
@@ -96615,15 +96615,20 @@ function getTargetInfo(targetPath) {
}
return { arch, platform };
}
async function retry(fn, attempts) {
/// Will run provided fn at least once plus the provided attempts on failures
/// Examples
/// - retry(fn, 0) = run fn once then return no matter the success status
/// - retry(fn, 3) = if all tries fail, fn will be executed 4 times
async function retry(fn, additionalAttempts) {
const attempts = additionalAttempts + 1;
for (let attempt = 1; attempt <= attempts; attempt++) {
try {
return await fn();
}
catch (error) {
if (attempt === attempts)
if (attempt >= attempts)
throw error;
console.log(`Attempt ${attempt} failed, retrying...`);
console.log(`Attempt ${attempt} failed. ${attempts - attempt} tries left.`);
}
}
}

View File

@@ -38,7 +38,7 @@ class Runner {
return retry(
() => execCommand(this.bin, args, { cwd }, env),
retryAttempts + 1,
retryAttempts,
) as Promise<void>;
}
}

View File

@@ -90,7 +90,7 @@ export async function uploadAssets(
repo,
release_id: releaseId,
}),
retryAttempts + 1,
retryAttempts,
);
console.log(`${assetName} successfully uploaded.`);

View File

@@ -578,16 +578,23 @@ export function getTargetInfo(targetPath?: string): TargetInfo {
return { arch, platform };
}
/// Will run provided fn at least once plus the provided attempts on failures
/// Examples
/// - retry(fn, 0) = run fn once then return no matter the success status
/// - retry(fn, 3) = if all tries fail, fn will be executed 4 times
export async function retry(
fn: () => Promise<unknown>,
attempts: number,
additionalAttempts: number,
): Promise<unknown> {
const attempts = additionalAttempts + 1;
for (let attempt = 1; attempt <= attempts; attempt++) {
try {
return await fn();
} catch (error) {
if (attempt === attempts) throw error;
console.log(`Attempt ${attempt} failed, retrying...`);
if (attempt >= attempts) throw error;
console.log(
`Attempt ${attempt} failed. ${attempts - attempt} tries left.`,
);
}
}
}