A Github Action to generate CHANGELOG automatically according to conventional commits. Feel free to contribute!
auto-generate-changelog
A Github Action to generate CHANGELOG automatically according to conventional commits.
Feel free to submit a pull request or an issue, but make sure to follow the templates.
Welcome contributors to improve this project together!
If you like this, please give me a star!
Usage
Create a workflow file such as .github/workflows/changelog.yml (you can find it in this repo)
name: Generate changelog
on:
release:
types: [created, edited]
jobs: generate-changelog: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: BobAnkh/auto-generate-changelog@v1.3.1 with: REPO_NAME: "<YourUserName>/<YourRepoName>" ACCESSTOKEN: ${{secrets.GITHUBTOKEN}} PATH: "CHANGELOG.md" COMMIT_MESSAGE: "docs(CHANGELOG): update release notes" TYPE: "feat:Feature,fix:Bug Fixes,docs:Documentation,refactor:Refactor,perf:Performance Improvements"
NOTE: Generating CHANGELOG needs all the commit history so you should set>fetch-depth: 0withactions/checkout
NOTE: commit log begins withdocs(changelog)ordoc(CHANGELOG)will not be added to the CHANGELOG
Inputs
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 | | ACCESSTOKEN | Github Access Token. See NOTES 1 | yes | You can just pass ${{secrets.GITHUBTOKEN}} | | 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 | | REPLACEEMPTYRELEASE_INFO | Replace empty release info with some words | no | false |
NOTES 1: ${{secrets.GITHUBTOKEN}} has a rate limit 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: PULLREQUEST 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 PULLREQUEST (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:
> > See CHANGELOG for more details. This line will be hided when changelog is generated. > > <!-- HIDE IN CHANGELOG END --> >> <!-- HIDE IN CHANGELOG BEGIN -->
Maintainer
How to contribute
You should follow our Code of Conduct.
See CONTRIBUTING GUIDELINES for contributing conventions.
Make sure to pass all the tests before submitting your code. You can conduct pytest -ra at the root directory to run all tests.
You can use local mode when develope it on your local machine, here is the command-line help info:
usage: main.py [-h] [-m MODE] [-f FILE] [-o OUTPUT] [-t TOKEN]
optional arguments: -h, --help show this help message and exit -m MODE, --mode MODE choose to use local-dev mode or on github action mode. Valid values are 'local' or 'github' -f FILE, --file FILE configuration file to read from when running local-dev mode -o OUTPUT, --output OUTPUT output file when running local-dev mode -t TOKEN, --token TOKEN Github Access Token
Contributors
|
Yixin Shen |
Jonathan Mang |
Sebastian RΓΌhl |
okcoder1 |
LICENSE
Apache-2.0 Β© BobAnkh