From d22e5c850ff7ba9bcc35586312965818b91ebaa3 Mon Sep 17 00:00:00 2001 From: Gary Katsevman <git@gkatsev.com> Date: Mon, 27 Feb 2023 16:59:55 -0500 Subject: [PATCH] feat: create a GitHub discussion via API flag if a discussion category name was provided --- packages/conventional-github-releaser/README.md | 6 ++++++ packages/conventional-github-releaser/src/cli.js | 8 ++++++++ packages/conventional-github-releaser/src/index.js | 4 ++++ 3 files changed, 18 insertions(+) mode change 100644 => 100755 packages/conventional-github-releaser/src/cli.js diff --git a/packages/conventional-github-releaser/README.md b/packages/conventional-github-releaser/README.md index 7f6c30f3..9b31f0e6 100644 --- a/packages/conventional-github-releaser/README.md +++ b/packages/conventional-github-releaser/README.md @@ -129,6 +129,12 @@ Default: `1` How many releases of changelog you want to generate. It counts from the latest semver tag. Useful when you forgot to generate any previous releases. Set to `0` to regenerate all. +#### discussion + +Default: unset + +The discussion category name, which when given, will have GitHub automatically create a discussion in this category from the release. + ##### name Default: same as version tag diff --git a/packages/conventional-github-releaser/src/cli.js b/packages/conventional-github-releaser/src/cli.js old mode 100644 new mode 100755 index ea15f54b..3ea75bf2 --- a/packages/conventional-github-releaser/src/cli.js +++ b/packages/conventional-github-releaser/src/cli.js @@ -28,6 +28,9 @@ const cli = meow({ If 0, the whole changelog will be regenerated and the outfile will be overwritten Default: 1 + -d, --discussion The discussion category name, which when given, will have GitHub automatically create a discussion in this category from the release. + Default: not set + -v, --verbose Verbose output. Use this for debugging Default: false @@ -63,6 +66,10 @@ const cli = meow({ default: 1, type: 'number' }, + discussion: { + alias: 'd', + type: 'string' + }, verbose: { alias: 'v', default: false, @@ -123,6 +130,7 @@ const changelogOpts = { path: flags.pkg }, releaseCount: flags.releaseCount, + discussion: flags.discussion, draft: flags.draft } diff --git a/packages/conventional-github-releaser/src/index.js b/packages/conventional-github-releaser/src/index.js index c62bad74..26305545 100644 --- a/packages/conventional-github-releaser/src/index.js +++ b/packages/conventional-github-releaser/src/index.js @@ -85,6 +85,10 @@ function conventionalGithubReleaser (auth, changelogOpts, context, gitRawCommits target_commitish: changelogOpts.targetCommitish } } + if (changelogOpts.discussion) { + debug(`discussions enabled`, changelogOpts.discussion) + options.body.discussion_category_name = changelogOpts.discussion + } debug(`posting %o to the following URL - ${url}`, options) // Set auth after debug output so that we don't print auth token to console.