Skip to content

Commit

Permalink
Always delete previous releases, not only for dev (#1001)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alexcrichton authored Feb 26, 2020
1 parent 76e08d6 commit ead53b3
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions .github/actions/github-release/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,21 @@ 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') {
const releases = await octokit.paginate("GET /repos/:owner/:repo/releases", { owner, repo });
for (const release of releases) {
if (release.tag_name !== 'dev') {
continue;
}
const release_id = release.id;
core.info(`deleting release ${release_id}`);
await octokit.repos.deleteRelease({ owner, repo, release_id });
// 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 !== name) {
continue;
}
const release_id = release.id;
core.info(`deleting release ${release_id}`);
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({
Expand Down

0 comments on commit ead53b3

Please sign in to comment.