mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-07 20:30:41 +00:00
Add NewRelease.GenerateReleaseNotes property (#2596)
* Add `GenerateReleaseNotes` property Enable generating release notes during creation of a release. * Update release docs
This commit is contained in:
@@ -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
|
||||
@@ -73,6 +73,17 @@ namespace Octokit
|
||||
/// </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
|
||||
@@ -81,4 +92,4 @@ namespace Octokit
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -47,7 +47,7 @@ namespace Octokit
|
||||
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>
|
||||
@@ -56,7 +56,7 @@ namespace Octokit
|
||||
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>.
|
||||
|
||||
+12
-4
@@ -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);
|
||||
```
|
||||
|
||||
@@ -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);
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user