microsoft / PowerShellForGitHub

Microsoft PowerShell wrapper for GitHub API
Other
584 stars 184 forks source link

Auto-generate release notes? #346

Closed JasonDictos closed 2 years ago

JasonDictos commented 2 years ago

This is a question, is it possible to programmatically with this powershell module, click the 'Auto-generate release notes' button on the 'Make Release' portal in github?

image

HowardWolosky commented 2 years ago

Yes, but there isn't a direct command for it at the moment.

This appears to be the API: https://docs.github.com/en/rest/reference/repos#generate-release-notes-content-for-a-release

To use that with the module as it stands today, you'd do something like this:

$ownerName = '' # your repo's owner name
$repositoryName = '' # your repo's name

$hashBody = @{
#  REQUIRED: Set this to an existing or new tag for the release
   'tag_name' = ''

#  OPTIONAL: You only include this if tag_name does not reference an existing tag.
#  'target_commitish' = ''

#  OPTIONAL: Only specify this if you want to use this previous tag's release notes as a starting point for this new one
#  'previous_tag_name' = ''

#  OPTIONAL: A path to a file in the repo containing config settings used for generating the release notes.  If not specified, will use .github/release.yml or .github/release.yaml.  If neither of those are found, the default config is used.
#  'configuration_file_path' = ''
}

$params = @{
        'UriFragment' = "repos/$ownerName/$repositoryName/releases/generate-notes"
        'Body' = (ConvertTo-Json -InputObject $hashBody)
        'Method' = 'Post'
        'Description' = "Generating release notes"
}

Invoke-GHRestMethod @params