https://github.com/loopwerk/tag-changelog
Automatically generate a changelog since the last tag, using the conventional commit format
https://github.com/loopwerk/tag-changelog
actions changelog changelog-generator github-actions
Last synced: 4 months ago
JSON representation
Automatically generate a changelog since the last tag, using the conventional commit format
- Host: GitHub
- URL: https://github.com/loopwerk/tag-changelog
- Owner: loopwerk
- License: mit
- Created: 2021-02-19T13:44:04.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-08-08T09:31:20.000Z (10 months ago)
- Last Synced: 2025-09-20T18:45:30.611Z (9 months ago)
- Topics: actions, changelog, changelog-generator, github-actions
- Language: JavaScript
- Homepage:
- Size: 331 KB
- Stars: 62
- Watchers: 3
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# tag-changelog
A GitHub Action triggered by a new (valid semver) tag getting pushed. It then fetches all the commits since the previous tag and creates a changelog text using the [Conventional Commits](https://www.conventionalcommits.org) format. It will also turn PR numbers into clickable links, and mentions the author.
This action returns the generated changelog text, but doesn't do anything more; you need to for example prepend it to a `CHANGELOG.md` file, create a GitHub Release with this text, etc.
## Example workflow
```yml
name: Create Release
on:
push:
tags:
- "*"
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@latest
- name: Create changelog text
id: changelog
uses: loopwerk/tag-changelog@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
exclude_types: other,doc,chore
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref }}
name: Release ${{ github.ref }}
body: ${{ steps.changelog.outputs.changes }}
token: ${{ secrets.GITHUB_TOKEN }}
```
## Inputs
- `token`: Your GitHub token, `${{ secrets.GITHUB_TOKEN }}`. Required.
- `exclude_types`: A comma separated list of commit types you want to exclude from the changelog, for example: "other,chore". Optional (defaults to nothing). Can also be configured in the config file.
- `include_commit_body`: Whether to include the commit body in the changelog. Optional (defaults to "false"). Can also be configured in the config file.
- `config_file`: Location of the config file. Optional.
## Outputs
- `changelog`: Generated changelog for the latest tag, including the version/date header (suitable for prepending to a CHANGELOG.md file).
- `changes`: Generated changelog for the latest tag, without the version/date header (suitable for GitHub Releases).
## Custom config
```yml
- name: Create changelog text
uses: loopwerk/tag-changelog@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
config_file: .github/tag-changelog-config.js
```
The config file can be used to map commit types to changelog labels, to override the rendering of changelog sections, and the rendering of the overall changelog. You only need to override the things you want to override. For example, you can leave out `renderTypeSection` and `renderChangelog` and only include the `types` config; the [default config](https://github.com/loopwerk/tag-changelog/blob/main/src/defaultConfig.js) will be used for whatever is not overriden.
### Example config file:
```javascript
module.exports = {
types: [
{ types: ["feat", "feature"], label: "๐ New Features" },
{ types: ["fix", "bugfix"], label: "๐ Bugfixes" },
{ types: ["improvements", "enhancement"], label: "๐จ Improvements" },
{ types: ["perf"], label: "๐๏ธ Performance Improvements" },
{ types: ["build", "ci"], label: "๐๏ธ Build System" },
{ types: ["refactor"], label: "๐ช Refactors" },
{ types: ["doc", "docs"], label: "๐ Documentation Changes" },
{ types: ["test", "tests"], label: "๐ Tests" },
{ types: ["style"], label: "๐
Code Style Changes" },
{ types: ["chore"], label: "๐งน Chores" },
{ types: ["other"], label: "Other Changes" },
],
excludeTypes: ["other"],
renderTypeSection: function (label, commits) {
let text = `\n## ${label}\n`;
commits.forEach(commit => {
text += `- ${commit.subject}\n`;
if (commit.body) {
text += `${commit.body}\n`;
}
});
return text;
},
renderChangelog: function (release, changes) {
const now = new Date();
return `# ${release} - ${now.toISOString().substr(0, 10)}\n` + changes + "\n\n";
},
};
```
The order in which the `types` appear also determines the order of the generated sections in the changelog.
## Example output
> # v0.14.0 - 2021-02-22
>
> ## New Features
>
> - merge the default config with the user config so that the user config only has to override values it wants, and use the defaults for the others
> - the custom config file is now JS instead of JSON, allow the override of the changelog text templates ([#2](https://github.com/loopwerk/tag-changelog/pull/2) by [kevinrenskers](https://github.com/kevinrenskers))
> - commit types to exclude can now also be configured via the config file
>
> ## Documentation Changes
>
> - simplified readme
>
> ## Chores
>
> - added project logo
>
> ## BREAKING CHANGES
>
> - due to [bcb876](https://github.com/loopwerk/tag-changelog/commit/bcb8767bc22bc7d4ab47a4fffd4ef435de581054): commit types to exclude can now also be configured via the config file
>
> The `exclude` input parameter has been renamed to `exclude_types`.
You can also check out the [Releases page](https://github.com/loopwerk/tag-changelog/releases) for tag-changelog.
## Thanks
Thanks to [Helmisek/conventional-changelog-generator](https://github.com/Helmisek/conventional-changelog-generator) and [ardalanamini/auto-changelog](https://github.com/ardalanamini/auto-changelog) for inspiration. Thanks to [nektos/act](https://github.com/nektos/act) for making it possible to run GitHub Actions locally, making development and testing a whole lot easier.
## Support
Commercial support is available via [Loopwerk](https://www.loopwerk.io/open-source/support/).