A simple Github Action to generate changelog automatically
When analyzing some market actions, none of them proposed to generate the incremental changelog and according to the standard established by keepachangelog.
Some, like github-changelog-generator, become unfeasible in the medium and long term by always regenerating the changelog file with each new release, because, from a performance point of view, the more releases/versions of the product there are, the more time-consuming it will be to generate the changelog automatically.
Thus, this action appears to facilitate changelog generation, since it searches, formats, and adds information only from the new release and not from all.
Here the release/version changelog will only be generated and the file will be checked with the cat
command.
name: Changelog generator
on:
workflow_dispatch:
jobs:
generate-changelog:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Changelog generator
uses: dittrichlucas/changelog-generator@main
with:
token: ${{ github.token }}
repo: ${{ github.repository }}
- name: Check changelog file
run: cat CHANGELOG.md
In this other example, the file will be generated and a PR will be opened to the repository with the changes made.
name: Changelog generator
on:
workflow_dispatch:
jobs:
generate-changelog:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Changelog generator
uses: dittrichlucas/changelog-generator@main
with:
token: ${{ github.token }}
repo: ${{ github.repository }}
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
token: ${{ github.token}}
commit-message: "project/ci: update the changelog file with new release deliveries"
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: true
branch: release-branch
delete-branch: true
title: "project/ci: generate the changelog file for the new release"
body: |
Update the `CHANGELOG.md` file with the deliveries of the new release
draft: false
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
Note: Here I am using (and I suggest) the create-pull-request action because it is very complete and fulfills the purpose I was looking for to open a PR with the updated changelog, but feel free to use the one that is most convenient for your case.
All inputs are required.
Input | Description | Default |
---|---|---|
token | Personal access token (PAT) used to fetch the repository. | Not yet |
repo | Repository name with owner. For example, owner/repo-name. | Not yet |
Check out the roadmap
I decided to list the articles that served as a basis for me to develop this action in Golang, if it is of interest.
- Writing Github Actions in Go
- Creating Github Actions in Go
- Automate changelog and releases creation in Github
- Changelog pattern
The scripts and documentation in this project are released under the MIT License