Changelog CI (Commit and/or Comment Auto-generated Changelog to PR using Actions)
Maksudul Haque
Posted on September 3, 2020
My Workflow
I have created my first Open Source GitHub Action called Changelog CI.
This is a GitHub Action that generates changelog, prepends it to CHANGELOG.md file, and commits and/or comments it to the release pull request.
Changelog CI is a GitHub Action that enables a project to automatically generate changelogs
What is Changelog CI?
Changelog CI is a GitHub Action that enables a project to automatically generate changelogs.
Changelog CI can be triggered on pull_request, workflow_dispatch and any other events that can provide the required inputs
Learn more about events that trigger workflows
The workflow can be configured to perform any (or all) of the following actions:
For pull_request event:
Generates changelog using Pull Request Titles or Commit Messages made after the last release.
Prepends the generated changelog to the CHANGELOG.md/CHANGELOG.rst file.
Then Commits the modified CHANGELOG.md/CHANGELOG.rst file to the release pull request branch.
Adds a Comment on the release pull request with the generated changelog.
For other events:
Generate changelog using Pull Request Title or Commit Messages made after the last release.
Prepends the generated changelog to the CHANGELOG.md/CHANGELOG.rst file.
Then Creates a Pull Request with the CHANGELOG.md/CHANGELOG.rst file changes.
Changelog CI itself uses this Action to generate Changelog.
How Does It Work:
Changelog CI uses python and GitHub API to generate a changelog for a repository.
First, it tries to get the latest release from the repository (If available).
Then, it checks all the pull requests merged after the last release using the GitHub API. After that, it parses the data and generates the changelog. Finally, It writes the generated changelog at the beginning of the CHANGELOG.md (or user-provided filename) file. In addition to that, if a user provides a config (JSON file), Changelog CI parses the user-provided config file and renders the changelog according to users config. Then the changes are committed and/or commented on the release Pull request.
Usage:
To use this Action The pull request title must match with the default regex or the user-provided regex from the config file.
Default title regex:^(?i)release (title must start with the word "release" (case insensitive))
Default version number regex: This follows SemVer (Semantic Versioning) pattern. e.g. 1.0.0, 1.0, v1.0.1 etc.
name:Changelog CI# Controls when the action will run. Triggers the workflow on pull requeston:pull_request:types:[opened,reopened]jobs:build:runs-on:ubuntu-lateststeps:# Checks-out your repository-uses:actions/checkout@v2-name:Run Changelog CIuses:saadmk11/changelog-ci@v0.5.0with:# Optional, you can provide any name for your changelog file.# defaults to ``CHANGELOG.md`` if not provided.changelog_filename:CHANGELOG.md# Optional, only required when you want more customizationconfig_file:changelog-ci-config.jsonenv:# Optional, Only required for ``private`` repositories# and required if the changelog comment # option is turned on through the config fileGITHUB_TOKEN:${{secrets.GITHUB_TOKEN}}
Changelog CI Badge:
Add this to your README to display the badge:
![Changelog CI Status](https://github.com/<username>/<repo_name>/workflows/Changelog%20CI/badge.svg)
Example Changelog Output using config file:
Learn more about config file for Changelog CI
from the README.md