Skip to content

Commit

Permalink
Add commitish to config (#771)
Browse files Browse the repository at this point in the history
  • Loading branch information
subsetpark committed Feb 5, 2021
1 parent 193a397 commit 4bd7c3c
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ You can configure Release Drafter using the following key in your `.github/relea
| `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 |
| `filter-by-commitish` | Optional | Filter previous releases to consider only the target branch of the release. Default: `false`. |
| `commitish` | Optional | Specify the target branch of the release. Default: the default branch of the repo. |

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`.

Expand Down Expand Up @@ -277,6 +278,7 @@ The Release Drafter GitHub Action accepts a number of optional inputs directly i
| `version` | The version to be associated with the GitHub release that's created or updated. This will override any version calculated by the release-drafter. |
| `publish` | A boolean indicating whether the release being created or updated should be immediately published. This may be useful if the output of a previous workflow step determines that a new version of your project has been (or will be) released, as with [`salsify/action-detect-and-tag-new-version`](https://github.com/salsify/action-detect-and-tag-new-version). |
| `prerelease` | A boolean indicating whether the relase being created or updated is a prerelease. |
| `commitish` | A string specifying the target branch for the release being created. |

## Action Outputs

Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ inputs:
A boolean indicating whether the relase being created or updated is a prerelease.
required: false
default: ''
commitish:
description: |
The object that the release should be created to point to.
required: false
default: ''
outputs:
id:
description: The ID of therelease that was created or updated.
Expand Down
7 changes: 7 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ const DEFAULT_CONFIG = Object.freeze({
'sort-direction': SORT_DIRECTIONS.descending,
prerelease: false,
'filter-by-commitish': false,
commitish: '',
'category-template': `## $TITLE`,
})

Expand Down Expand Up @@ -799,10 +800,13 @@ module.exports.generateReleaseInfo = ({
: ''
}

let commitish = config['commitish'] || ''

return {
name,
tag,
body,
commitish,
prerelease: isPreRelease,
draft: shouldDraft,
}
Expand All @@ -811,6 +815,7 @@ module.exports.generateReleaseInfo = ({
module.exports.createRelease = ({ context, releaseInfo }) => {
return context.octokit.repos.createRelease(
context.repo({
target_commitish: releaseInfo.commitish,
name: releaseInfo.name,
tag_name: releaseInfo.tag,
body: releaseInfo.body,
Expand Down Expand Up @@ -919,6 +924,8 @@ const schema = (context) => {
DEFAULT_CONFIG['filter-by-commitish']
),

commitish: Joi.string().allow('').default(DEFAULT_CONFIG['commitish']),

replacers: Joi.array()
.items(
Joi.object().keys({
Expand Down
1 change: 1 addition & 0 deletions lib/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const DEFAULT_CONFIG = Object.freeze({
'sort-direction': SORT_DIRECTIONS.descending,
prerelease: false,
'filter-by-commitish': false,
commitish: '',
'category-template': `## $TITLE`,
})

Expand Down
4 changes: 4 additions & 0 deletions lib/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,13 @@ module.exports.generateReleaseInfo = ({
: ''
}

let commitish = config['commitish'] || ''

return {
name,
tag,
body,
commitish,
prerelease: isPreRelease,
draft: shouldDraft,
}
Expand All @@ -302,6 +305,7 @@ module.exports.generateReleaseInfo = ({
module.exports.createRelease = ({ context, releaseInfo }) => {
return context.octokit.repos.createRelease(
context.repo({
target_commitish: releaseInfo.commitish,
name: releaseInfo.name,
tag_name: releaseInfo.tag,
body: releaseInfo.body,
Expand Down
2 changes: 2 additions & 0 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const schema = (context) => {
DEFAULT_CONFIG['filter-by-commitish']
),

commitish: Joi.string().allow('').default(DEFAULT_CONFIG['commitish']),

replacers: Joi.array()
.items(
Joi.object().keys({
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/config/config-with-commitish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
commitish: 'staging'
template: 'dummy'

0 comments on commit 4bd7c3c

Please sign in to comment.