Skip to content

Commit

Permalink
feat(changelog): support incremental generation
Browse files Browse the repository at this point in the history
- support the replace of default empty release description
- support to exclude unreleased commits
  • Loading branch information
BobAnkh committed Jul 13, 2022
1 parent 62d6d85 commit 8f2b648
Show file tree
Hide file tree
Showing 7 changed files with 426 additions and 245 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ jobs:
with:
ACCESS_TOKEN: ${{secrets.GITHUB_TOKEN}}
PATH: 'CHANGELOG.md'
COMMIT_MESSAGE: 'docs(CHANGELOG): update release notes'
COMMIT_MESSAGE: 'docs(changelog): update release notes'
TYPE: 'feat:Feature,fix:Bug Fixes,docs:Documentation,refactor:Refactor,perf:Performance Improvements'
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Generate changelog
on:
release:
types: [created, edited]
push:
branches:
- dev

jobs:
generate-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: BobAnkh/auto-generate-changelog@dev
with:
ACCESS_TOKEN: ${{secrets.GITHUB_TOKEN}}
PATH: 'CHANGELOG.md'
COMMIT_MESSAGE: 'docs(changelog): update release notes'
TYPE: 'feat:Feature,fix:Bug Fixes,docs:Documentation,refactor:Refactor,perf:Performance Improvements'
BRANCH: 'dev'
REGENERATE_COUNT: '5'
UNRELEASED_COMMITS: 'true'
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@

## Unreleased

Changes unreleased.
*No description*

### Feature

- main:
- add logs ([f58349e](https://github.com/BobAnkh/auto-generate-changelog/commit/f58349e096c357bd8b5899a7003e11e4a8d5e4a5))

- incr:
- add incr generate ([999e098](https://github.com/BobAnkh/auto-generate-changelog/commit/999e098a789dcd53463e02f20d8d5f02c37d433c))

### Bug Fixes

- release:
- fix typo ([ecf8b65](https://github.com/BobAnkh/auto-generate-changelog/commit/ecf8b658a274957a45342708d61006ce98e5eb12))

### Documentation

Expand Down
61 changes: 33 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feel free to submit a pull request or an issue, but make sure to follow the temp

Welcome contributors to improve this project together!

**If you like this, please give me a star!**
**If you like this, please give me a star**!

## Usage

Expand All @@ -30,7 +30,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: BobAnkh/auto-generate-changelog@master
- uses: BobAnkh/auto-generate-changelog@v1
with:
REPO_NAME: '<YourUserName>/<YourRepoName>'
ACCESS_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand All @@ -45,34 +45,39 @@ jobs:
### Inputs

**Please see notes below the table for more optional features**.

| Inputs | Description | Required | Default |
| ----------------- | ----------------------------------------------------------- | -------- | --------------------------------------------------------- |
| REPO_NAME | Repository name | no | `''` which means current repository |
| ACCESS_TOKEN | Github Access Token | yes | You can just pass `${{secrets.GITHUB_TOKEN}}` |
| PATH | Path to the your file | no | `/CHANGELOG.md` |
| BRANCH | The branch to update file specified in PATH | no | `''` which means default branch |
| PULL_REQUEST | Open a new pull request if set to a target branch name | no | `''` which means not open pull request by default |
| COMMIT_MESSAGE | commit message | no | `docs(CHANGELOG): update release notes` |
| TYPE | The type of commits you want to add to CHANGELOG | no | `'feat:Feature,fix:Fix'` |
| COMMITTER | The committer you want to use to update file | no | `''` which means default committer |
| DEFAULT_SCOPE | The default scope to hold all unscoped commits | no | `general` |
| SUPPRESS_UNSCOPED | Whether to exclude unscoped commits | no | false |

> `${{secrets.GITHUB_TOKEN}}` has a rate limit smaller than Personal Access Token, so if you have much more requests(commits, prs, etc.), use PAT instead.
>
> `COMMITTER` should be in the format: `'author <author.example>'`
>
> NOTE: `PULL_REQUEST` must be used with `BRANCH` together, both **should be provided** if you want to **open a pull request**
>
> You can define the keyword detected from commit message and the corresonding word presented in the changelog in input `TYPE`. For example, define `feat:Feature` will detect commit message like `feat(main): add new option` and present this in changelog as part `Feature`
>
> NOTE: You can use format below to avoid some lines in release description to appear in CHANGELOG:
>
**Please see NOTES below the table for how to set some of the parameters**.

| Inputs | Description | Required | Default |
| --------------------------- | ----------------------------------------------------------------------- | -------- | --------------------------------------------------- |
| REPO_NAME | Repository name | no | `''` which means current repository |
| ACCESS_TOKEN | Github Access Token. See **NOTES 1** | yes | You can just pass `${{secrets.GITHUB_TOKEN}}` |
| PATH | Path to the your file | no | `CHANGELOG.md` |
| BRANCH | The branch to update file specified in PATH | no | `''` which means default branch |
| PULL_REQUEST | Open a new pull request if set to a target branch name. See **NOTES 2** | no | `''` which means not open pull request by default |
| COMMIT_MESSAGE | Commit message | no | `docs(CHANGELOG): update release notes` |
| TYPE | The type of commits you want to add to CHANGELOG. See **NOTES 3** | no | `'feat:Feature,fix:Fix'` |
| COMMITTER | The committer you want to use to update file. See **NOTES 4** | no | `''` which means default committer |
| DEFAULT_SCOPE | The default scope to hold all unscoped commits | no | `general` |
| SUPPRESS_UNSCOPED | Whether to exclude unscoped commits | no | false |
| UNRELEASED_COMMITS | Whether to include unreleased commits in the changelog | no | false |
| REGENERATE_COUNT | Regenerate n recent releases' changelog. See **NOTES 5** | no | 0 |
| REPLACE_EMPTY_RELEASE_INFO | Replace empty release info with some words | no | false |

**NOTES 1**: `${{secrets.GITHUB_TOKEN}}` has a [rate limit](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting) smaller than Personal Access Token (PAT), so if you have much more requests(commits, prs, etc.) or face a 403 rate-limit-error, use PAT instead.

**NOTES 2**: `PULL_REQUEST` must be used with `BRANCH` together, both **should be provided** with a valid branch name if you want to **open a pull request**. The GA will open a pull request from the `BRANCH` (head branch) to the `PULL_REQUEST` (base branch). Leave `PULL_REQUEST` blank if you don't want to open a pull request.

**NOTES 3**: You can define the keyword detected from commit message and the corresponding word presented in the changelog in input `TYPE`. For example, define `feat:Feature,fix:Bug Fixes` will have commit messages like `feat(main): add new option` to be presented in changelog under part `Feature` and have commit messages like `fix(server): adjust rendering` to be presented in changelog under part `Bug Fixes`.

**NOTES 4**: `COMMITTER` should be in the format: `'author <author@email>'`

**NOTES 5**: All the releases not exist in the changelog will of course be added to the changelog. Use this parameter to regenerate the last n releases' changelog. Default set to 0 means only generate for new releases. You can set to -1 to regenerate all the releases.

**NOTES 6**: You can use the format below to avoid some lines in release description to appear in the CHANGELOG:

> ```markdown
> <!-- HIDE IN CHANGELOG BEGIN -->
> See CHANGELOG for more details.
> See CHANGELOG for more details. This line will be hided when changelog is generated.
> <!-- HIDE IN CHANGELOG END -->
> ```
Expand Down
14 changes: 13 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ inputs:
COMMIT_MESSAGE:
description: "Commit message"
required: false
default: 'docs(CHANGELOG): update release notes'
default: 'docs(changelog): update release notes'
TYPE:
description: "The type of commits you want to add to CHANGELOG"
required: false
Expand All @@ -44,6 +44,18 @@ inputs:
description: "Suppress the generation of release notes for un-scoped commits e.g. 'fix: some general fix'"
required: false
default: 'false'
UNRELEASED_COMMITS:
description: "Whether to include unreleased commits in the changelog"
required: false
default: 'false'
REGENERATE_COUNT:
description: "Regenerate n recent releases' changelog. All non-exist releases will be generated. -1 means regenerating all the releases and 0 means no old releases will be regenerated"
required: false
default: '0'
REPLACE_EMPTY_RELEASE_INFO:
description: "Replace empty release info with some words"
required: false
default: '*No description*'
runs:
using: "docker"
image: "Dockerfile"
Loading

0 comments on commit 8f2b648

Please sign in to comment.