diff --git a/Octokit/Models/Request/NewRelease.cs b/Octokit/Models/Request/NewRelease.cs index 23e561d2f0..050be78837 100644 --- a/Octokit/Models/Request/NewRelease.cs +++ b/Octokit/Models/Request/NewRelease.cs @@ -7,7 +7,7 @@ namespace Octokit /// Used to create a new release. /// /// - /// API: https://developer.github.com/v3/repos/releases/#create-a-release + /// API: https://docs.github.com/rest/releases/releases#create-a-release /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class NewRelease @@ -73,6 +73,17 @@ public NewRelease(string tagName) /// public bool Prerelease { get; set; } + /// + /// Gets or sets a value indicating whether to automatically generate the name and body for this release. + /// If name is specified, the specified name will be used; otherwise, a name will + /// be automatically generated. If body is specified, the body will be pre-pended to the + /// automatically generated notes. + /// + /// + /// true to generate release notes; otherwise, false. + /// + public bool GenerateReleaseNotes { get; set; } + internal string DebuggerDisplay { get @@ -81,4 +92,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Request/ReleaseUpdate.cs b/Octokit/Models/Request/ReleaseUpdate.cs index 64399e78ab..9bf687bb55 100644 --- a/Octokit/Models/Request/ReleaseUpdate.cs +++ b/Octokit/Models/Request/ReleaseUpdate.cs @@ -7,7 +7,7 @@ namespace Octokit /// Used to update a release. /// /// - /// API: https://developer.github.com/v3/repos/releases/#create-a-release + /// API: https://docs.github.com/rest/releases/releases#update-a-release /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class ReleaseUpdate @@ -47,7 +47,7 @@ public class ReleaseUpdate public string Body { get; set; } /// - /// Gets or sets a value indicating whether this is a draft (unpublished). + /// Gets or sets a value indicating whether this is a draft (unpublished). /// Default: false /// /// @@ -56,7 +56,7 @@ public class ReleaseUpdate public bool? Draft { get; set; } /// - /// Gets or sets a value indicating whether this is prerelease. + /// Gets or sets a value indicating whether this is prerelease. /// /// /// true if prerelease; otherwise, false. diff --git a/docs/releases.md b/docs/releases.md index e863e950e0..3d92c78e44 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -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",