What are GitHub actions?
That is well described in this post by Brian Douglas. He has also an entire post series about tips around GitHub actions.
Which problem should be solved?
There are different solutions to create automatic releases based on certain criteria. Again Brian Douglas pointed out some possibilities in this post.
For this open-source project, the requirement was to determine the release structure via labels at the pull request. This was preferred over conventional commits. Also, not every merged pull request should automatically trigger a new release. Therefore, a draft is the right way to collect the changes and publish a version whenever needed.
Addionatylly to the GitHub releases, a changelog.md helps see the version history, for example, directly in the code editor. That changelog.md should be updated every time a release is published.
The combination Release Drafter and gren is the approach to solve the problem.
Configure Release Drafter
To configure Release Drafter in the default way, it needs two files and the according labels.
This template describes the structure of the release draft and the needed labels.
The full path is .github/release-drafter.yml
The GitHub actions configuration like this:
github/workflows/release-drafter.yml
Configure gren
The releases are published manually at certain times. This trigger this configuration.
The command "overrideChangelog": "gren changelog --override"
from the package.json update then the changelog.md.
Because of the main branch protection, itβs not possible to push the changes directly back. This will do this via a pull request with the GitHub action create-pull-request.
How it looks like
The collection of the changes in a release draft.
The labels in a pull request.
The result in the GitHub release.
The result in the CHANGELOG.md.