Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NewRelease.GenerateReleaseNotes property #2596

Merged
merged 2 commits into from
Oct 18, 2022
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
15 changes: 13 additions & 2 deletions Octokit/Models/Request/NewRelease.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Octokit
/// Used to create a new release.
/// </summary>
/// <remarks>
/// API: https://developer.github.com/v3/repos/releases/#create-a-release
/// API: https://docs.github.com/rest/releases/releases#create-a-release
/// </remarks>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class NewRelease
Expand Down Expand Up @@ -73,6 +73,17 @@ public NewRelease(string tagName)
/// </value>
public bool Prerelease { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to automatically generate the name and body for this release.
/// If <see cref="Name">name</see> is specified, the specified name will be used; otherwise, a name will
/// be automatically generated. If <see cref="Body">body</see> is specified, the body will be pre-pended to the
/// automatically generated notes.
/// </summary>
/// <value>
/// <c>true</c> to generate release notes; otherwise, <c>false</c>.
/// </value>
public bool GenerateReleaseNotes { get; set; }

internal string DebuggerDisplay
{
get
Expand All @@ -81,4 +92,4 @@ internal string DebuggerDisplay
}
}
}
}
}
6 changes: 3 additions & 3 deletions Octokit/Models/Request/ReleaseUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Octokit
/// Used to update a release.
/// </summary>
/// <remarks>
/// API: https://developer.github.com/v3/repos/releases/#create-a-release
/// API: https://docs.github.com/rest/releases/releases#update-a-release
/// </remarks>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class ReleaseUpdate
Expand Down Expand Up @@ -47,7 +47,7 @@ public class ReleaseUpdate
public string Body { get; set; }

/// <summary>
/// Gets or sets a value indicating whether this <see cref="NewRelease"/> is a draft (unpublished).
/// Gets or sets a value indicating whether this <see cref="ReleaseUpdate"/> is a draft (unpublished).
/// Default: false
/// </summary>
/// <value>
Expand All @@ -56,7 +56,7 @@ public class ReleaseUpdate
public bool? Draft { get; set; }

/// <summary>
/// Gets or sets a value indicating whether this <see cref="NewRelease"/> is prerelease.
/// Gets or sets a value indicating whether this <see cref="ReleaseUpdate"/> is prerelease.
/// </summary>
/// <value>
/// <c>true</c> if prerelease; otherwise, <c>false</c>.
Expand Down
16 changes: 12 additions & 4 deletions docs/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ To retrieve all releases for a repository:
var releases = await client.Repository.Release.GetAll("octokit", "octokit.net");
var latest = releases[0];
Console.WriteLine(
"The latest release is tagged at {0} and is named {1}",
latest.TagName,
"The latest release is tagged at {0} and is named {1}",
latest.TagName,
latest.Name);
```

Expand All @@ -35,6 +35,14 @@ Note that the `Draft` flag is used to indicate when a release should be publishe
GitHub can generate a name and body for a new release [automatically](https://github.blog/2021-10-04-beta-github-releases-improving-release-experience/#introducing-auto-generated-release-notes), based upon merged pull requests.
[This is an example](https://github.com/MylesBorins/release-notes-test/releases/tag/v2.0.0) of automatically generated text.

```csharp
var newTag = "v1.5.7";
var newRelease = new NewRelease(newTag);
newRelease.GenerateReleaseNotes = true; // Set for Name and Body to be generated.
newRelease.TargetCommitish = "main"; // Optional, can be a branch, tag, or SHA; defaults to the main branch.
```

#### Customizing generated notes
```csharp
var newTag = "v1.5.7";
var generationRequest = new GenerateReleaseNotesRequest(newTag);
Expand All @@ -47,7 +55,7 @@ newRelease.Name = releaseNotes.Name;
newRelease.Body = releaseNotes.Body;
```

This feature can be customized at the repository level, by following [these instructions](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes).
This feature can be customized at the repository level, by following [these instructions](https://docs.github.com/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes).

### Update

Expand All @@ -68,7 +76,7 @@ If you have any assets to include with the release, you can upload them after cr

```csharp
using(var archiveContents = File.OpenRead("output.zip")) { // TODO: better sample
var assetUpload = new ReleaseAssetUpload()
var assetUpload = new ReleaseAssetUpload()
{
FileName = "my-cool-project-1.0.zip",
ContentType = "application/zip",
Expand Down