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 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.
name: Create Release
on:
push:
tags:
- "*"
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- 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: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: ${{ steps.changelog.outputs.changes }}
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.config_file
: Location of the config file. Optional.
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).
- 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 will be used for whatever is not overriden.
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.
- 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 by kevinrenskers)
- commit types to exclude can now also be configured via the config file
- simplified readme
- added project logo
- due to bcb876: commit types to exclude can now also be configured via the config file
The
exclude
input parameter has been renamed toexclude_types
.
You can also check out the Releases page for tag-changelog.
Thanks to Helmisek/conventional-changelog-generator and ardalanamini/auto-changelog for inspiration. Thanks to nektos/act for making it possible to run GitHub Actions locally, making development and testing a whole lot easier.