Skip to content

Commit 515b956

Browse files
committed
Create non-draft releases with updated body for draft releases
Turns out that editing a release body does not nofity mentioned sponsors when the edit happens. So we introduce a new conventional approach: we will create releases as draft, that will invoke the hook and cause the draft to be deleted entirely and recreated as a non-draft with the new updated body. According to a Grok search, this will properly notify mentioned users, and it's apparently by design to avoid spamming mentioned users on multiple edits of the same release (which sort of makes sense).
1 parent 1b7e84b commit 515b956

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/Web/Webhook.cs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,30 @@ protected override async ValueTask ProcessReleaseWebhookAsync(WebhookHeaders hea
117117

118118
if (!string.Equals(newBody, body, StringComparison.Ordinal))
119119
{
120-
// Update release body via GitHub API
121120
var repo = payload.Repository;
122121
if (repo is not null)
123122
{
124-
var update = new ReleaseUpdate
123+
if (payload.Release.Draft)
125124
{
126-
Body = newBody
127-
};
128-
129-
await github.Repository.Release.Edit(repo.Owner.Login, repo.Name, payload.Release.Id, update);
125+
await github.Repository.Release.Delete(repo.Owner.Login, repo.Name, payload.Release.Id);
126+
await github.Repository.Release.Create(repo.Owner.Login, repo.Name,
127+
new NewRelease(payload.Release.TagName)
128+
{
129+
Name = payload.Release.Name,
130+
Body = newBody,
131+
Draft = false,
132+
Prerelease = payload.Release.Prerelease,
133+
TargetCommitish = payload.Release.TargetCommitish
134+
});
135+
}
136+
else
137+
{
138+
await github.Repository.Release.Edit(repo.Owner.Login, repo.Name, payload.Release.Id,
139+
new ReleaseUpdate
140+
{
141+
Body = newBody
142+
});
143+
}
130144
}
131145
}
132146
}

0 commit comments

Comments
 (0)