Always delete previous releases, not only for dev (#1001)

This will delete a same-name of a previous release for all tags, not
just the dev tag. That way if we need to retry a tagged release we'll
delete it and recreate it as usual.

Closes #978
This commit is contained in:
Alex Crichton
2020-02-26 17:09:49 -06:00
committed by GitHub
parent 76e08d60d4
commit ead53b3f23

View File

@@ -24,17 +24,12 @@ async function runOnce() {
const octokit = new github.GitHub(token);
// If this is a `dev` release then we need to actually delete the previous
// release since we can't overwrite a new one. We also need to update the
// `dev` tag while we're at it. So here you'll see:
//
// * Look for the `dev` release, then delete it if it exists
// * Update the `dev` release to our current sha, or create one if it doesn't
// exist
if (name == 'dev') {
// Delete the previous release since we can't overwrite one. This may happen
// due to retrying an upload or it may happen because we're doing the dev
// release.
const releases = await octokit.paginate("GET /repos/:owner/:repo/releases", { owner, repo });
for (const release of releases) {
if (release.tag_name !== 'dev') {
if (release.tag_name !== name) {
continue;
}
const release_id = release.id;
@@ -42,6 +37,8 @@ async function runOnce() {
await octokit.repos.deleteRelease({ owner, repo, release_id });
}
// We also need to update the `dev` tag while we're at it on the `dev` branch.
if (name == 'dev') {
try {
core.info(`updating dev tag`);
await octokit.git.updateRef({