Skip to content

Commit

Permalink
Recreate the release every time
Browse files Browse the repository at this point in the history
To ensure people who watch the repo for release notifications actually get a
notification.
  • Loading branch information
bjorn3 committed Mar 25, 2023
1 parent cc570ae commit aab1526
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions .github/actions/github-release/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,28 @@ async function runOnce() {
}
}

// Try to load the release for this tag, and if it doesn't exist then make a
// new one. We might race with other builders on creation, though, so if the
// creation fails try again to get the release by the tag.
let release = null;
// Delete a previous release
try {
core.info(`fetching release`);
release = await octokit.rest.repos.getReleaseByTag({ owner, repo, tag: name });
let release = await octokit.rest.repos.getReleaseByTag({ owner, repo, tag: name });
console.log("found release: ", JSON.stringify(release.data, null, 2));
await octokit.rest.repos.deleteRelease({
owner,
repo,
release_id: release.data.id,
});
console.log("deleted release");
} catch (e) {
console.log("ERROR: ", JSON.stringify(e, null, 2));
core.info(`creating a release`);
try {
release = await octokit.rest.repos.createRelease({
owner,
repo,
tag_name: name,
prerelease: name === 'dev',
});
} catch (e) {
console.log("ERROR: ", JSON.stringify(e, null, 2));
core.info(`fetching one more time`);
release = await octokit.rest.repos.getReleaseByTag({ owner, repo, tag: name });
}
}
console.log("found release: ", JSON.stringify(release.data, null, 2));

console.log("creating a release");
let release = await octokit.rest.repos.createRelease({
owner,
repo,
tag_name: name,
prerelease: name === 'dev',
});

// Delete all assets from a previous run
for (const asset of release.data.assets) {
Expand Down

0 comments on commit aab1526

Please sign in to comment.