Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build",
"version": "0.9.1",
"version": "0.9.2",
"description": "Shared build/test/release pipeline for the purview-dev organisation, packaged as a pinned .NET tool with a GitHub composite action and reusable workflows.",
"license": "MIT",
"author": {
Expand Down
31 changes: 28 additions & 3 deletions src/src/Build/Modules/CreateGitHubReleaseModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ CancellationToken cancellationToken
// latest stable release.
var isPrerelease = releaseSettings.Value.ShouldMarkPrerelease(unit.Version);

// GitHub accepts release assets only while the release is still a draft. A
// published release is immutable in a repository that enables release
// immutability, and the asset endpoint then rejects the upload outright
// ("Cannot upload assets to an immutable release"). A release that carries
// artifacts is therefore created as a draft, filled, and published once the
// artifacts are attached; a release with nothing to attach is published in
// one call, exactly as before.
var uploadArtifacts = releaseSettings.Value.UploadArtifacts;

var release = await context
.GitHub()
.Client.Repository.Release.Create(
Expand All @@ -98,18 +107,34 @@ CancellationToken cancellationToken
Name = unit.Tag,
GenerateReleaseNotes = true,
Prerelease = isPrerelease,
Draft = uploadArtifacts,
}
);

context.Logger.LogInformation(
"Created GitHub release {Tag}{Prerelease}.",
"Created GitHub release {Tag}{Prerelease}{Draft}.",
unit.Tag,
isPrerelease ? " as a prerelease" : string.Empty
isPrerelease ? " as a prerelease" : string.Empty,
uploadArtifacts ? " as a draft" : string.Empty
);

if (releaseSettings.Value.UploadArtifacts)
if (uploadArtifacts)
{
await UploadArtifactsAsync(context, release, cancellationToken);

// Publishing is the last step, so a release is never observable without
// its artifacts.
release = await context
.GitHub()
.Client.Repository.Release.Edit(
repositoryId,
release.Id,
new ReleaseUpdate { Draft = false }
);

context.Logger.LogInformation("Published GitHub release {Tag}.", unit.Tag);
}

return release;
}

Expand Down
Loading