-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from WeTransfer/feature/fix-release-notes
Make sure GH release notes are used correctly with previous tag
- Loading branch information
Showing
11 changed files
with
211 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
Sources/GitBuddyCore/GitHub/GitHubReleaseNotesGenerator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// GitHubReleaseNotesGenerator.swift | ||
// | ||
// | ||
// Created by Antoine van der Lee on 13/06/2023. | ||
// Copyright © 2023 WeTransfer. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import OctoKit | ||
|
||
struct GitHubReleaseNotesGenerator { | ||
let octoKit: Octokit | ||
let project: GITProject | ||
let tagName: String | ||
let targetCommitish: String | ||
let previousTagName: String | ||
|
||
func generate(using session: URLSession = URLSession.shared) throws -> ReleaseNotes { | ||
let group = DispatchGroup() | ||
group.enter() | ||
|
||
var result: Result<ReleaseNotes, Swift.Error>! | ||
|
||
octoKit.generateReleaseNotes( | ||
session, | ||
owner: project.organisation, | ||
repository: project.repository, | ||
tagName: tagName, | ||
targetCommitish: targetCommitish, | ||
previousTagName: previousTagName) { response in | ||
switch response { | ||
case .success(let releaseNotes): | ||
result = .success(releaseNotes) | ||
case .failure(let error): | ||
result = .failure(OctoKitError(error: error)) | ||
} | ||
group.leave() | ||
} | ||
|
||
group.wait() | ||
|
||
return try result.get() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// ReleaseNotesJSON.swift | ||
// | ||
// | ||
// Created by Antoine van der Lee on 13/06/2023. | ||
// Copyright © 2023 WeTransfer. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
// swiftlint:disable line_length | ||
let ReleaseNotesJSON = """ | ||
{ | ||
"name": "Release v1.0.0 is now available!", | ||
"body": "##Changes in Release v1.0.0 ... ##Contributors @monalisa" | ||
} | ||
""" |