Skip to content
ly.ton edited this page Oct 23, 2018 · 31 revisions

Configuration

Fields

owner
repo
authorization
tagName
targetCommitish
releaseName
body
draft
prerelease
releaseAssets overwrite

owner

githubRelease {
  owner 'breadmoirai'
  owner { 'breadmoirai' }
  owner = 'breadmoirai'
  setOwner('breadmoirai')
}

This field specifies the user or organization that the github repo belongs to.
By default, if this property is not set, it is inferred using the last part of the project.group value. If

group = 'com.github.breadmoirai'

then

githubRelease {
  owner = 'breadmoirai'
}

repo

githubRelease {
  repo 'github-release-gradle-plugin'
  repo { 'github-release-gradle-plugin' }
  repo = 'github-release-gradle-plugin'
  setRepo('github-release-gradle-plugin')
}

This field specifies the name of the github repo. If this field is not set, it attempts to use the project.name or the rootProject.name

name = 'github-release-gradle-plugin'

then

githubRelease {
  repo = 'github-release-gradle-plugin'
}

authorization

For authorization, either a token or username and password is required. A token can be acquired from user settings > developer settings on Github which must contain repo permissions. In lieu of a token, the username and password can be used as shown below.

githubRelease {
  token 'TOKEN'
  token { 'TOKEN' }
  token = 'TOKEN'
  setToken('TOKEN')

  authorization 'Token TOKEN'
  ...

  authorization 'Basic ' + Base64.encoder.encodeToString('username:password'.bytes)
  ...

  authorization {
    def result = null
    new SwingBuilder().edt {
      dialog(modal: true, 
          title: 'Login to Github', 
          alwaysOnTop: true, 
          resizable: false, 
          locationRelativeTo: null, 
          pack: true, 
          show: true
      ) {
        vbox {
          label(text: "username")
          def username = textField()
          label(text: "password")
          def password = passwordField()
          button(defaultButton: true, text: 'Login', actionPerformed: {
            result = 'Basic ' + Base64.encoder.encodeToString("$username.text:$password.password".bytes)
            dispose()
          })
        }
      }
    }
    return result
  }
}

tagName

This field specifies the name of the git tag to use or create for this release.
By default this is set to "v$project.version"

githubRelease {
  tagName 'v1.0.0'
  tagName { 'v1.0.0' }
  tagName = 'v1.0.0'
  setTagName('v1.0.0')
}

targetCommitish

This field specifies the target commit hash that this release should point to. Be default, this is set to 'master'

githubRelease {
  targetCommitish 'master'
  targetCommitish { 'master' }
  targetCommitish = 'master'
  setTargetCommitish('master')
}

releaseName

The name of the release.
By default, this is set to whatever the tagName is set to.

githubRelease {
  releaseName 'v1.0.0'
  releaseName { 'v1.0.0' }
  releaseName = 'v1.0.0'
  releaseName('v1.0.0')
}

body

The body of the release. By default, this is empty. However, we provide a changelog that attempts to retrieve the list of commits ranging from the most current to the release prior to this one.

githubRelease {
  body 'Hello world!'
  body { 'Hello world!' }
  body = 'Hello world!'
  setBody('Hello world!')

  body changelog {
    ...
  }
}

changelog

executable is set to 'git' by default as the changelog makes a call to git rev-list to retrieve a list of past commits. If the git executable is not available in the Path, the path to the executable must be set.
currentCommit identifies the most recent commit tied to this release. By default, it is set to 'Head'.
lastCommit identifies the oldest commit that should be included. By default, this will make a call to the Github API and look for the most recent release before the current one and use that release's targetCommitish.
options is a list of strings that is passed to the git rev-list command. By default, this is set as `["--format=oneline", "--abbrev-commit", "--max-count=50"]'

githubRelease {
  body changelog {
    executable 'git' //path to git executable
    currentCommit 'HEAD' //optional
    lastCommit 'HEAD~10' //optional
    options(["--format=oneline", "--abbrev-commit", "--max-count=50", "graph"]) //optional
  }
  
  body {
    changelog().call()
      .readLines()
      .stream()
      .map{ "- $it" }
      .collect(Collectors.joining('\n', '## Changelog\n', ''))
  }
}
Clone this wiki locally