|
1 | 1 | #I @"../../packages/build/FAKE/tools"
|
| 2 | +#I @"../../packages/build/Octokit/lib/net45" |
2 | 3 | #r @"FakeLib.dll"
|
| 4 | +#r "Octokit.dll" |
| 5 | +#nowarn "0044" //TODO sort out FAKE 5 |
3 | 6 |
|
4 | 7 | #load @"Projects.fsx"
|
5 | 8 | #load @"Paths.fsx"
|
6 | 9 | #load @"Tooling.fsx"
|
7 | 10 | #load @"Versioning.fsx"
|
8 | 11 |
|
9 | 12 | open System
|
| 13 | +open System.Collections.Generic |
10 | 14 | open System.IO
|
11 | 15 | open System.Linq
|
12 | 16 | open System.Text
|
13 | 17 | open System.Xml.Linq
|
14 | 18 | open Microsoft.FSharp.Quotations
|
15 | 19 | open Microsoft.FSharp.Quotations.Patterns
|
16 | 20 | open Fake
|
| 21 | +open Octokit |
17 | 22 |
|
18 | 23 | open Paths
|
19 | 24 | open Projects
|
@@ -90,3 +95,56 @@ module Release =
|
90 | 95 | | 0 -> traceFAKE "publish to myget succeeded" |> ignore
|
91 | 96 | | _ -> failwith "publish to myget failed" |> ignore
|
92 | 97 | )
|
| 98 | + |
| 99 | + let GenerateNotes() = |
| 100 | + let previousVersion = Versioning.GlobalJsonVersion.ToString() |
| 101 | + let currentVersion = Versioning.CurrentVersion.ToString() |
| 102 | + let label = sprintf "v%s" currentVersion |
| 103 | + let releaseNotes = sprintf "ReleaseNotes-%s.md" currentVersion |> Paths.Output |
| 104 | + let client = new GitHubClient(new ProductHeaderValue("ReleaseNotesGenerator")) |
| 105 | + client.Credentials <- Credentials.Anonymous |
| 106 | + |
| 107 | + let filter = new RepositoryIssueRequest() |
| 108 | + filter.Labels.Add label |
| 109 | + filter.State <- ItemStateFilter.Closed |
| 110 | + |
| 111 | + let labelHeaders = |
| 112 | + [("Feature", "Features & Enhancements"); |
| 113 | + ("Bug", "Bug Fixes"); |
| 114 | + ("Deprecation", "Deprecations");] |
| 115 | + |> Map.ofList |
| 116 | + |
| 117 | + let groupByLabel (issues:IReadOnlyList<Issue>) = |
| 118 | + let dict = new Dictionary<string, Issue list>() |
| 119 | + for issue in issues do |
| 120 | + for labelHeader in labelHeaders do |
| 121 | + if issue.Labels.Any(fun l -> l.Name = labelHeader.Key) then |
| 122 | + let exists,list = dict.TryGetValue(labelHeader.Key) |
| 123 | + match exists with |
| 124 | + | true -> dict.[labelHeader.Key] <- issue :: list |
| 125 | + | false -> dict.Add(labelHeader.Key, [issue]) |
| 126 | + dict |
| 127 | + |
| 128 | + let closedIssues = client.Issue.GetAllForRepository(Paths.OwnerName, Paths.RepositoryName, filter) |
| 129 | + |> Async.AwaitTask |
| 130 | + |> Async.RunSynchronously |
| 131 | + |> groupByLabel |
| 132 | + |
| 133 | + use file = File.OpenWrite <| releaseNotes |
| 134 | + use writer = new StreamWriter(file) |
| 135 | + writer.WriteLine(sprintf "%s/compare/%s...%s" Paths.Repository previousVersion currentVersion) |
| 136 | + writer.WriteLine() |
| 137 | + for closedIssue in closedIssues do |
| 138 | + labelHeaders.[closedIssue.Key] |> sprintf "## %s" |> writer.WriteLine |
| 139 | + writer.WriteLine() |
| 140 | + for issue in closedIssue.Value do |
| 141 | + sprintf "- #%i %s" issue.Number issue.Title |> writer.WriteLine |
| 142 | + writer.WriteLine() |
| 143 | + |
| 144 | + sprintf "### [View the full list of issues and PRs](%s/issues?utf8=%%E2%%9C%%93&q=label%%3A%s)" Paths.Repository label |
| 145 | + |> writer.WriteLine |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | + |
0 commit comments