diff --git a/README.md b/README.md index a0a49797f..20f247d49 100644 --- a/README.md +++ b/README.md @@ -106,31 +106,31 @@ template: | You can configure Release Drafter using the following key in your `.github/release-drafter.yml` file: -| Key | Required | Description | -| -------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `template` | Required | The template for the body of the draft release. Use [template variables](#template-variables) to insert values. | -| `header` | Optional | Will be prepended to `template`. Use [template variables](#template-variables) to insert values. | -| `footer` | Optional | Will be appended to `template`. Use [template variables](#template-variables) to insert values. | -| `category-template` | Optional | The template to use for each category. Use [category template variables](#category-template-variables) to insert values. Default: `"## $TITLE"`. | -| `name-template` | Optional | The template for the name of the draft release. For example: `"v$NEXT_PATCH_VERSION"`. | -| `tag-template` | Optional | The template for the tag of the draft release. For example: `"v$NEXT_PATCH_VERSION"`. | -| `version-template` | Optional | The template to use when calculating the next version number for the release. Useful for projects that don't use semantic versioning. Default: `"$MAJOR.$MINOR.$PATCH"` | -| `change-template` | Optional | The template to use for each merged pull request. Use [change template variables](#change-template-variables) to insert values. Default: `"* $TITLE (#$NUMBER) @$AUTHOR"`. | -| `change-title-escapes` | Optional | Characters to escape in `$TITLE` when inserting into `change-template` so that they are not interpreted as Markdown format characters. Default: `""` | -| `no-changes-template` | Optional | The template to use for when there’s no changes. Default: `"* No changes"`. | -| `references` | Optional | The references to listen for configuration updates to `.github/release-drafter.yml`. Refer to [References](#references) to learn more about this | -| `categories` | Optional | Categorize pull requests using labels. Refer to [Categorize Pull Requests](#categorize-pull-requests) to learn more about this option. | -| `exclude-labels` | Optional | Exclude pull requests using labels. Refer to [Exclude Pull Requests](#exclude-pull-requests) to learn more about this option. | -| `include-labels` | Optional | Include only the specified pull requests using labels. Refer to [Include Pull Requests](#include-pull-requests) to learn more about this option. | -| `exclude-contributors` | Optional | Exclude specific usernames from the generated `$CONTRIBUTORS` variable. Refer to [Exclude Contributors](#exclude-contributors) to learn more about this option. | -| `no-contributors-template` | Optional | The template to use for `$CONTRIBUTORS` when there's no contributors to list. Default: `"No contributors"`. | -| `replacers` | Optional | Search and replace content in the generated changelog body. Refer to [Replacers](#replacers) to learn more about this option. | -| `sort-by` | Optional | Sort changelog by merged_at or title. Can be one of: `merged_at`, `title`. Default: `merged_at`. | -| `sort-direction` | Optional | Sort changelog in ascending or descending order. Can be one of: `ascending`, `descending`. Default: `descending`. | -| `prerelease` | Optional | Mark the draft release as pre-release. Default `false`. | -| `version-resolver` | Optional | Adjust the `$RESOLVED_VERSION` variable using labels. Refer to [Version Resolver](#version-resolver) to learn more about this | -| `commitish` | Optional | The release target, i.e. branch/tag/commit it should point to. Default: the ref that release-drafter runs for, e.g. `refs/heads/master` if configured to run on pushes to `master`. | -| `filter-by-commitish` | Optional | Filter previous releases to consider only those with the target matching `commitish`. Default: `false`. | +| Key | Required | Description | +| -------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `template` | Required | The template for the body of the draft release. Use [template variables](#template-variables) to insert values. | +| `header` | Optional | Will be prepended to `template`. Use [template variables](#template-variables) to insert values. | +| `footer` | Optional | Will be appended to `template`. Use [template variables](#template-variables) to insert values. | +| `category-template` | Optional | The template to use for each category. Use [category template variables](#category-template-variables) to insert values. Default: `"## $TITLE"`. | +| `name-template` | Optional | The template for the name of the draft release. For example: `"v$NEXT_PATCH_VERSION"`. | +| `tag-template` | Optional | The template for the tag of the draft release. For example: `"v$NEXT_PATCH_VERSION"`. | +| `version-template` | Optional | The template to use when calculating the next version number for the release. Useful for projects that don't use semantic versioning. Default: `"$MAJOR.$MINOR.$PATCH"` | +| `change-template` | Optional | The template to use for each merged pull request. Use [change template variables](#change-template-variables) to insert values. Default: `"* $TITLE (#$NUMBER) @$AUTHOR"`. | +| `change-title-escapes` | Optional | Characters to escape in `$TITLE` when inserting into `change-template` so that they are not interpreted as Markdown format characters. Default: `""` | +| `no-changes-template` | Optional | The template to use for when there’s no changes. Default: `"* No changes"`. | +| `references` | Optional | The references to listen for configuration updates to `.github/release-drafter.yml`. Refer to [References](#references) to learn more about this | +| `categories` | Optional | Categorize pull requests using labels. Refer to [Categorize Pull Requests](#categorize-pull-requests) to learn more about this option. | +| `exclude-labels` | Optional | Exclude pull requests using labels. Refer to [Exclude Pull Requests](#exclude-pull-requests) to learn more about this option. | +| `include-labels` | Optional | Include only the specified pull requests using labels. Refer to [Include Pull Requests](#include-pull-requests) to learn more about this option. | +| `exclude-contributors` | Optional | Exclude specific usernames from the generated `$CONTRIBUTORS` variable. Refer to [Exclude Contributors](#exclude-contributors) to learn more about this option. | +| `no-contributors-template` | Optional | The template to use for `$CONTRIBUTORS` when there's no contributors to list. Default: `"No contributors"`. | +| `replacers` | Optional | Search and replace content in the generated changelog body. Refer to [Replacers](#replacers) to learn more about this option. | +| `sort-by` | Optional | Sort changelog by merged_at or title. Can be one of: `merged_at`, `title`. Default: `merged_at`. | +| `sort-direction` | Optional | Sort changelog in ascending or descending order. Can be one of: `ascending`, `descending`. Default: `descending`. | +| `prerelease` | Optional | Mark the draft release as pre-release. Default `false`. | +| `version-resolver` | Optional | Adjust the `$RESOLVED_VERSION` variable using labels. Refer to [Version Resolver](#version-resolver) to learn more about this | +| `commitish` | Optional | The release target, i.e. branch or commit it should point to. Default: the ref that release-drafter runs for, e.g. `refs/heads/master` if configured to run on pushes to `master`. | +| `filter-by-commitish` | Optional | Filter previous releases to consider only those with the target matching `commitish`. Default: `false`. | Release Drafter also supports [Probot Config](https://github.com/probot/probot-config), if you want to store your configuration files in a central repository. This allows you to share configurations between projects, and create a organization-wide configuration file by creating a repository named `.github` with the file `.github/release-drafter.yml`. diff --git a/dist/index.js b/dist/index.js index 19f45643b..ddddcea80 100644 --- a/dist/index.js +++ b/dist/index.js @@ -129365,6 +129365,18 @@ const generateReleaseInfo = ({ name = template(name, versionInfo) } + // Tags are not supported as `target_commitish` by Github API. + // GITHUB_REF or the ref from webhook start with `refs/tags/`, so we handle + // those here. If it doesn't but is still a tag - it must have been set + // explicitly by the user, so it's fair to just let the API respond with an error. + if (targetCommitish.startsWith('refs/tags/')) { + log({ + context, + message: `${targetCommitish} is not supported as release target, falling back to default branch`, + }) + targetCommitish = '' + } + return { name, tag, diff --git a/lib/releases.js b/lib/releases.js index 1e8143c04..4e501db95 100644 --- a/lib/releases.js +++ b/lib/releases.js @@ -322,6 +322,18 @@ const generateReleaseInfo = ({ name = template(name, versionInfo) } + // Tags are not supported as `target_commitish` by Github API. + // GITHUB_REF or the ref from webhook start with `refs/tags/`, so we handle + // those here. If it doesn't but is still a tag - it must have been set + // explicitly by the user, so it's fair to just let the API respond with an error. + if (targetCommitish.startsWith('refs/tags/')) { + log({ + context, + message: `${targetCommitish} is not supported as release target, falling back to default branch`, + }) + targetCommitish = '' + } + return { name, tag, diff --git a/test/index.test.js b/test/index.test.js index b836e15bf..4a43c3243 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -227,7 +227,7 @@ describe('release-drafter', () => { "name": "", "prerelease": false, "tag_name": "", - "target_commitish": "refs/tags/v1.0.0", + "target_commitish": "", } `) return true