Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for github generated release notes, closes #51 #52

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# github-release
[![Gradle Plugin Portal](https://img.shields.io/badge/version-2.3.7-blue.svg)](https://plugins.gradle.org/plugin/com.github.breadmoirai.github-release/2.3.7)

[i51]: https://github.com/BreadMoirai/github-release-gradle-plugin/issues/51
[p42]: https://github.com/BreadMoirai/github-release-gradle-plugin/pull/42
[p41]: https://github.com/BreadMoirai/github-release-gradle-plugin/pull/41
[p38]: https://github.com/BreadMoirai/github-release-gradle-plugin/pull/38
Expand Down Expand Up @@ -34,6 +35,9 @@ This plugin uses [OkHttp](http://square.github.io/okhttp/) to send a POST reques
If you are using multiple GithubRelease tasks to compose a single release, the release must be published `draft=false` with the first task. Currently, the plugin cannot find an existing release if it is a draft.

## Changelog
2.4.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 I'm not sure how strictly this repo follows semver, but as a new feature I thought a minor bump would be appropriate.

- Add support for GitHub generated release notes with `generateReleaseNotes: true`. If a name is not provided one will be generated. If a body is provided it will be pre-pended to the auto generated notes. Fixes [#51](i51).

2.3.7
- Update dependencies to latest version
- OkHttp 4.*, etc; Addressing [#36][i36]
Expand Down Expand Up @@ -132,6 +136,7 @@ githubRelease {
tagName.set "v1.0.0" // by default this is set to "v${project.version}"
targetCommitish.set "main" // by default this is set to "main"
releaseName.set "v1.0.0" // Release title, by default this is the same as the tagName
generateReleaseNotes.set false // Generate release notes automatically, if true and body is present, body will be pre-pended, if name is not given, one will be generated by the tag
body.set "" // by default this is empty
draft.set true // by default this is true
prerelease.set false // by default this is false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.github.breadmoirai.githubreleaseplugin

import com.github.breadmoirai.githubreleaseplugin.GithubApi
import com.github.breadmoirai.githubreleaseplugin.ast.ExtensionClass
import com.github.breadmoirai.githubreleaseplugin.exceptions.PropertyNotSetException
import groovy.transform.Memoized
Expand Down Expand Up @@ -200,4 +201,4 @@ class ChangeLogSupplier implements Callable<String> {
this.options.add(option)
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Input

import java.util.concurrent.Callable

Expand Down Expand Up @@ -59,8 +58,12 @@ import java.util.concurrent.Callable
* <td>'v' + project.version</td>
* </tr>
* <tr>
* <td>generateReleaseNotes</td>
* <td>false</td>
* </tr>
* <tr>
* <td>body</td>
* <td>list of commits since last release</td>
* <td>""</td>
* </tr>
* <tr>
* <td>draft</td>
Expand Down Expand Up @@ -99,6 +102,7 @@ class GithubReleaseExtension {
final Property<CharSequence> tagName
final Property<CharSequence> targetCommitish
final Property<CharSequence> releaseName
final Property<Boolean> generateReleaseNotes
final Property<CharSequence> body
final Property<Boolean> draft
final Property<Boolean> prerelease
Expand All @@ -124,6 +128,7 @@ class GithubReleaseExtension {
tagName = objectFactory.property(CharSequence)
targetCommitish = objectFactory.property(CharSequence)
releaseName = objectFactory.property(CharSequence)
generateReleaseNotes = objectFactory.property(Boolean)
body = objectFactory.property(CharSequence)
draft = objectFactory.property(Boolean)
prerelease = objectFactory.property(Boolean)
Expand All @@ -146,6 +151,7 @@ class GithubReleaseExtension {
draft { false }
prerelease { false }
// authorization has no default value
generateReleaseNotes { false }
body { "" }
overwrite { false }
allowUploadToExisting { false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class GithubReleasePlugin implements Plugin<Project> {
setTagName ext.tagNameProvider
setTargetCommitish ext.targetCommitishProvider
setReleaseName ext.releaseNameProvider
setGenerateReleaseNotes ext.generateReleaseNotesProvider
setBody ext.bodyProvider
setDraft ext.draftProvider
setPrerelease ext.prereleaseProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class GithubReleaseTask extends DefaultTask {
@Input
final Property<CharSequence> releaseName
@Input
final Property<Boolean> generateReleaseNotes
@Input
final Property<CharSequence> body
@Input
final Property<Boolean> draft
Expand All @@ -62,7 +64,6 @@ class GithubReleaseTask extends DefaultTask {
@Input
final Property<CharSequence> apiEndpoint


GithubReleaseTask() {
this.setGroup('publishing')
final ObjectFactory objectFactory = project.objects
Expand All @@ -72,6 +73,7 @@ class GithubReleaseTask extends DefaultTask {
tagName = objectFactory.property(CharSequence)
targetCommitish = objectFactory.property(CharSequence)
releaseName = objectFactory.property(CharSequence)
generateReleaseNotes = objectFactory.property(Boolean)
body = objectFactory.property(CharSequence)
draft = objectFactory.property(Boolean)
prerelease = objectFactory.property(Boolean)
Expand Down Expand Up @@ -156,23 +158,27 @@ class GithubReleaseTask extends DefaultTask {
private void createRelease(GithubApi api, CharSequence ownerValue, CharSequence repoValue, CharSequence tagValue) {

def values = [
tag_name : tagValue,
target_commitish: targetCommitish.get(),
name : releaseName.get(),
body : body.get(),
draft : (releaseAssets.size() > 0) ? false : draft.get(),
prerelease : prerelease.get()
tag_name : tagValue,
target_commitish : targetCommitish.get(),
name : releaseName.get(),
generate_release_notes: generateReleaseNotes.get(),
body : body.get(),
draft : (releaseAssets.size() > 0) ? false : draft.get(),
prerelease : prerelease.get(),
]

log """CREATING NEW RELEASE
{
tag_name = ${tagValue}
target_commitish = ${targetCommitish.get()}
name = ${releaseName.get()}
generate_release_notes = ${generateReleaseNotes.get()}
body =
${body.get().replace('\n': '\n\t\t')}
draft = ${draft.get()}
prerelease = ${prerelease.get()}
}"""

if (dryRun.get()) {
uploadAssetsToUrl null, null
return
Expand Down