Retry the entire release process, not just uploading one asset (#989)

Another attempt to mitigate #978
This commit is contained in:
Alex Crichton
2020-02-25 19:46:41 -06:00
committed by GitHub
parent ab213780cd
commit 4b2c56e655

View File

@@ -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');
@@ -76,18 +76,23 @@ 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,
});
}
}
async function run() {
const retries = 10;
for (let i = 0; i < retries; i++) {
try {
runOnce();
break;
} catch (e) {
if (i === retries - 1)
@@ -100,7 +105,6 @@ async function run() {
}
}
}
}
run().catch(err => {
console.log("ERROR: ", JSON.stringify(err, null, 2));