Skip to content

Commit

Permalink
feat: Make the releaseCount configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Nati Oskar committed Feb 4, 2020
1 parent 437f835 commit da75f59
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This action will bump version, tag commit and generate a changelog with conventi
- **Optional** `preset`: Preset that is used from conventional commits. Default `angular`.
- **Optional** `tag-prefix`: Prefix for the git tags. Default `v`.
- **Optional** `output-file`: File to output the changelog to. Default `CHANGELOG.md`.
- **Optional** `changelog-release-count`: FNumber of releases to preserve in changelog. Default `5`, use `0` to regenerate all.

## Example usage

Expand All @@ -21,4 +22,5 @@ This action will bump version, tag commit and generate a changelog with conventi
preset: 'angular'
tag-prefix: 'v'
output-file: 'CHANGELOG.md'
changelog-release-count: 5
```
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ inputs:
description: 'File to output the changelog to'
default: 'CHANGELOG.md'
required: false

changelog-release-count:
description: 'Number of releases to preserve in changelog'
default: 5
required: false
4 changes: 2 additions & 2 deletions src/helpers/generateChangelog.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const fs = require('fs')
const conventionalChangelog = require('conventional-changelog')

module.exports = (tagPrefix, preset, jsonPackage, fileName) => new Promise((resolve) => {
module.exports = (tagPrefix, preset, jsonPackage, fileName, releaseCount) => new Promise((resolve) => {
const changelogStream = conventionalChangelog({
preset,
releaseCount: 5,
releaseCount,
},
{
version: jsonPackage.version,
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ async function run() {
const tagPrefix = core.getInput('tag-prefix')
const preset = core.getInput('preset')
const outputFile = core.getInput('output-file')
const releaseCount = core.getInput('changelog-release-count')

core.info(`Using "${preset}" preset`)

Expand All @@ -33,7 +34,7 @@ async function run() {
core.info(`New version: ${jsonPackage.version}`)

// Generate the changelog
await generateChangelog(tagPrefix, preset, jsonPackage, outputFile)
await generateChangelog(tagPrefix, preset, jsonPackage, outputFile, releaseCount)

core.info('Push all changes')

Expand Down

0 comments on commit da75f59

Please sign in to comment.