Skip to content

Commit

Permalink
Retry the entire release process, not just uploading one asset
Browse files Browse the repository at this point in the history
Another attempt to mitigate bytecodealliance#978
  • Loading branch information
alexcrichton committed Feb 26, 2020
1 parent ab21378 commit 7b6bf05
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions .github/actions/github-release/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function sleep(milliseconds) {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}

async function run() {
async function runOnce() {
// Load all our inputs and env vars. Note that `getInput` reads from `INPUT_*`
const files = core.getInput('files');
const name = core.getInput('name');
Expand Down Expand Up @@ -76,28 +76,32 @@ async function run() {
});

// Upload all the relevant assets for this release as just general blobs.
const retries = 10;
for (const file of glob.sync(files)) {
const size = fs.statSync(file).size;
core.info(`upload ${file}`);
for (let i = 0; i < retries; i++) {
try {
await octokit.repos.uploadReleaseAsset({
data: fs.createReadStream(file),
headers: { 'content-length': size, 'content-type': 'application/octet-stream' },
name: path.basename(file),
url: release.data.upload_url,
});
break;
} catch (e) {
if (i === retries - 1)
throw e;
console.log("ERROR: ", JSON.stringify(e, null, 2));
console.log("ERROR: ", e.message);
console.log(e.stack);
console.log("RETRYING after 10s");
await sleep(10000)
}
await octokit.repos.uploadReleaseAsset({
data: fs.createReadStream(file),
headers: { 'content-length': size, 'content-type': 'application/octet-stream' },
name: path.basename(file),
url: release.data.upload_url,
});
}
}

async function run() {
const retries = 10;
for (let i = 0; i < retries; i++) {
try {
runOnce();
break;
} catch (e) {
if (i === retries - 1)
throw e;
console.log("ERROR: ", JSON.stringify(e, null, 2));
console.log("ERROR: ", e.message);
console.log(e.stack);
console.log("RETRYING after 10s");
await sleep(10000)
}
}
}
Expand Down

0 comments on commit 7b6bf05

Please sign in to comment.