Skip to content

Commit

Permalink
fix: wait for github release to be fetchable after creating one
Browse files Browse the repository at this point in the history
  • Loading branch information
dgellow committed Sep 12, 2023
1 parent 8c1a45c commit afc3455
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2221,6 +2221,29 @@ export class GitHub {
});
}
}

async waitForRelease({url, id}: GitHubRelease) {
for (let i = 0; i < 10; i++) {
try {
this.logger.debug(
`Checking if release ${url} is fetchable (attempt ${i + 1})...`
);
await this.octokit.repos.getRelease({
owner: this.repository.owner,
repo: this.repository.repo,
release_id: id,
});
this.logger.debug(`Release found`);
return;
} catch (err: unknown) {
if (!isOctokitRequestError(err) || err.status !== 404) {
throw err;
}
}
}

this.logger.debug(`Release ${url} not found`);
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,8 @@ export class Manifest {
prerelease: release.prerelease,
});

await this.github.waitForRelease(githubRelease);

// comment on pull request
const comment = `:robot: Release is at ${githubRelease.url} :sunflower:`;
await this.github.commentOnIssue(comment, release.pullRequest.number);
Expand Down

0 comments on commit afc3455

Please sign in to comment.