Skip to content

Commit

Permalink
Merge pull request #98 from WeTransfer/feature/github-release-notes
Browse files Browse the repository at this point in the history
Add the possibility to let GitHub generate release notes
  • Loading branch information
AvdLee authored May 31, 2023
2 parents 2dc8706 + 435ba2b commit d0e0130
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"repositoryURL": "https://github.com/WeTransfer/octokit.swift",
"state": {
"branch": "main",
"revision": "f20ac29a920aa8a7b36340d7f285a727e9b30d6e",
"revision": "3d0fea9587af530cb13ef5801a3cb90186fce43e",
"version": null
}
},
Expand Down
6 changes: 5 additions & 1 deletion Sources/GitBuddyCore/Commands/ReleaseCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ struct ReleaseCommand: ParsableCommand {
@Flag(name: .customLong("sections"), help: "Whether the changelog should be split into sections. Defaults to false.")
private var isSectioned: Bool = false

@Flag(name: .customLong("useGitHubReleaseNotes"), help: "If `true`, release notes will be generated by GitHub. Defaults to false, which will lead to a changelog based on PR and issue titles matching the tag changes.")
private var useGitHubReleaseNotes: Bool = false

@Flag(name: .customLong("json"), help: "Whether the release output should be in JSON, containing more details. Defaults to false.")
private var shouldUseJSONOutput: Bool = false

Expand All @@ -89,7 +92,8 @@ struct ReleaseCommand: ParsableCommand {
releaseTitle: releaseTitle,
lastReleaseTag: lastReleaseTag,
baseBranch: baseBranch,
changelogToTag: changelogToTag)
changelogToTag: changelogToTag,
useGitHubReleaseNotes: useGitHubReleaseNotes)
let release = try releaseProducer.run(isSectioned: isSectioned)

if shouldUseJSONOutput {
Expand Down
9 changes: 7 additions & 2 deletions Sources/GitBuddyCore/Release/ReleaseProducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ final class ReleaseProducer: URLSessionInjectable, ShellInjectable {
let lastReleaseTag: String?
let changelogToTag: String?
let baseBranch: String
let useGitHubReleaseNotes: Bool

init(
changelogPath: String?,
Expand All @@ -42,7 +43,8 @@ final class ReleaseProducer: URLSessionInjectable, ShellInjectable {
releaseTitle: String? = nil,
lastReleaseTag: String? = nil,
baseBranch: String? = nil,
changelogToTag: String? = nil
changelogToTag: String? = nil,
useGitHubReleaseNotes: Bool
) throws {
try Octokit.authenticate()

Expand All @@ -59,6 +61,7 @@ final class ReleaseProducer: URLSessionInjectable, ShellInjectable {
self.lastReleaseTag = lastReleaseTag
self.changelogToTag = changelogToTag
self.baseBranch = baseBranch ?? "master"
self.useGitHubReleaseNotes = useGitHubReleaseNotes
}

@discardableResult public func run(isSectioned: Bool) throws -> Release {
Expand Down Expand Up @@ -187,6 +190,7 @@ final class ReleaseProducer: URLSessionInjectable, ShellInjectable {
prerelease: \(isPrerelease)
draft: false
title: \(releaseTitle)
useGitHubReleaseNotes: \(useGitHubReleaseNotes)
body:
\(body)\n
""")
Expand All @@ -201,7 +205,8 @@ final class ReleaseProducer: URLSessionInjectable, ShellInjectable {
name: releaseTitle,
body: body,
prerelease: isPrerelease,
draft: false
draft: false,
generateReleaseNotes: useGitHubReleaseNotes
) { response in
switch response {
case .success(let release):
Expand Down

0 comments on commit d0e0130

Please sign in to comment.