예제 #1
0
        public async Task<IHttpActionResult> CreateReleaseNotes(string owner, string repo, string tag,
            ReleaseNotesRequest payload, bool dryRun = false)
        {
            var authorizationToken = GetAuthorizationToken();
            if (string.IsNullOrWhiteSpace(authorizationToken))
                return Unauthorized(new AuthenticationHeaderValue("token"));

            payload = payload ?? new ReleaseNotesRequest();

            var client = new GitHubClient(owner, repo, authorizationToken);
            var composer = new ReleaseNotesComposer(client);

            var preRelease = tag.Contains("-");
            var timeRange = await composer.GetIssuesTimeRangeAsync(tag, payload.ReferenceTag, preRelease);

            var releaseNotes = await composer.ComposeAsync(tag, timeRange.Item1, timeRange.Item2,
                payload.CreateCategories(), payload.TitleTemplate, payload.BodyTemplate);

            var release = await client.SaveReleaseNotesAsync(releaseNotes, preRelease, dryRun);
            return Json(new ReleaseResponse(release),
                new JsonSerializerSettings {ContractResolver = new JavaScriptContractResolver()});
        }
예제 #2
0
 public ReleaseNotesComposer(GitHubClient client)
 {
     _client = client;
 }