Skip to main content
  1. Posts/

How to Automatically Categorize GitHub Release Notes by New features, Bug Fixes…

·898 words·2 mins· ·
Xianpeng Shen
Author
Xianpeng Shen
Table of Contents

If you’ve used GitHub to release projects, you’ll know that GitHub can automatically generate Release Notes.

Here’s an example of GitHub’s automatically generated Release Notes.

Example 1

The Release Notes in this screenshot are concise and easy to read. However, if the content is extensive, as in the case of the configuration-as-code-plugin project under the Jenkinsci organization, you’ll see that the Release Notes are categorized by title. If this content were mixed together, the experience would be significantly worse. (Don’t mistake this for manual categorization; programmers wouldn’t want to do that 😅)

Example 2

This article will share two methods for automatically categorizing the content of GitHub Release Notes based on their titles.

Method One: Using GitHub’s Built-in Functionality
#

Method one uses GitHub’s built-in functionality to automatically categorize Release Notes. This involves creating a configuration file, .github/release.yml, in your repository. This functionality is similar to GitHub’s Issue Template and Pull Request Template. Specific configuration options can be found in the official documentation.

Below is the configuration from the commit-check-action project configuration:

changelog:
  exclude:
    labels:
      - ignore-for-release
  categories:
    - title: '🔥 Breaking Changes'
      labels:
        - 'breaking'
    - title: 🏕 Features
      labels:
        - 'enhancement'
    - title: '🐛 Bug Fixes'
      labels:
        - 'bug'
    - title: '👋 Deprecated'
      labels:
        - 'deprecation'
    - title: 📦 Dependencies
      labels:
        - dependencies
    - title: Other Changes
      labels:
        - "*"

With the .github/release.yml configuration file added, the next time Release Notes are generated, the content will be automatically categorized (the 📦 Dependencies title in the image below is automatically added).

Example 3

Method Two: Using Release Drafter
#

Method two uses Release Drafter, requiring a configuration file named .github/release-drafter.yml in your repository.

The configuration options provided by the Release Drafter project show that it offers more features and is more complex to use. It also supports placing the configuration file in a central repository’s .github directory to enable unified configuration and sharing across multiple repositories.

Currently, method one (.github/release.yml) does not support unified configuration via a central .github repository; see this discussion.

Here’s an example of the .github/release-drafter.yml configuration from jenkinsci/configuration-as-code-plugin.

_extends: .github

The _extends: .github configuration inherits settings from the central repository’s .github/.github/release-drafter.yml configuration.

# Configuration for Release Drafter: https://github.com/toolmantim/release-drafter
name-template: $NEXT_MINOR_VERSION
tag-template: $NEXT_MINOR_VERSION
# Uses a more common 2-digit versioning in Jenkins plugins. Can be replaced by semver: $MAJOR.$MINOR.$PATCH
version-template: $MAJOR.$MINOR

# Emoji reference: https://gitmoji.carloscuesta.me/
# If adding categories, please also update: https://github.com/jenkins-infra/jenkins-maven-cd-action/blob/master/action.yaml#L16
categories:
  - title: 💥 Breaking changes
    labels:
      - breaking
  - title: 🚨 Removed
    labels:
      - removed
  - title: 🎉 Major features and improvements
    labels:
      - major-enhancement
      - major-rfe
  - title: 🐛 Major bug fixes
    labels:
      - major-bug
  - title: ⚠️ Deprecated
    labels:
      - deprecated
  - title: 🚀 New features and improvements
    labels:
      - enhancement
      - feature
      - rfe
  - title: 🐛 Bug fixes
    labels:
      - bug
      - fix
      - bugfix
      - regression
      - regression-fix
  - title: 🌐 Localization and translation
    labels:
      - localization
  - title: 👷 Changes for plugin developers
    labels:
      - developer
  - title: 📝 Documentation updates
    labels:
      - documentation
  - title: 👻 Maintenance
    labels:
      - chore
      - internal
      - maintenance
  - title: 🚦 Tests
    labels:
      - test
      - tests
  - title: ✍ Other changes
  # Default label used by Dependabot
  - title: 📦 Dependency updates
    labels:
      - dependencies
    collapse-after: 15
exclude-labels:
  - reverted
  - no-changelog
  - skip-changelog
  - invalid

template: |
  <!-- Optional: add a release summary here -->
  $CHANGES

replacers:
  - search: '/\[*JENKINS-(\d+)\]*\s*-*\s*/g'
    replace: '[JENKINS-$1](https://issues.jenkins.io/browse/JENKINS-$1) - '
  - search: '/\[*HELPDESK-(\d+)\]*\s*-*\s*/g'
    replace: '[HELPDESK-$1](https://github.com/jenkins-infra/helpdesk/issues/$1) - '
  # TODO(oleg_nenashev): Find a better way to reference issues
  - search: '/\[*SECURITY-(\d+)\]*\s*-*\s*/g'
    replace: '[SECURITY-$1](https://jenkins.io/security/advisories/) - '
  - search: '/\[*JEP-(\d+)\]*\s*-*\s*/g'
    replace: '[JEP-$1](https://github.com/jenkinsci/jep/tree/master/jep/$1) - '
  - search: '/CVE-(\d{4})-(\d+)/g'
    replace: 'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-$1-$2'
  - search: 'JFR'
    replace: 'Jenkinsfile Runner'
  - search: 'CWP'
    replace: 'Custom WAR Packager'
  - search: '@dependabot-preview'
    replace: '@dependabot'

autolabeler:
  - label: 'documentation'
    files:
      - '*.md'
    branch:
      - '/docs{0,1}\/.+/'
  - label: 'bug'
    branch:
      - '/fix\/.+/'
    title:
      - '/fix/i'
  - label: 'enhancement'
    branch:
      - '/feature\/.+/'
    body:
      - '/JENKINS-[0-9]{1,4}/'

This is the central repository’s .github/.github/release-drafter.yml configuration. The Jenkins official configuration uses many features, such as templates, replacements, and automatic label addition. A thorough reading of the Release Drafter documentation is recommended for a better understanding and utilization.

Summary
#

Both methods can automatically categorize titles when generating Release Notes, but they have some key differences. Understanding these differences will help you make a better choice.

  1. GitHub’s built-in method is easier to understand and configure and meets the needs of most projects. Its main drawback is the lack of support for reading .github/release.yml from a central .github repository.
  2. Release Drafter provides more powerful features, such as templates, sorting, replacements, and automatic label addition to pull requests. Importantly, it allows the creation of a template in a central repository for inheritance by other projects.

For large open-source organizations, Release Drafter is a better choice due to its powerful features and support for inheriting central repository configurations. For personal projects, GitHub’s built-in method is generally sufficient.

This concludes my discussion of the two methods for automatically generating and categorizing GitHub Release Notes.

Please feel free to leave any questions or suggestions in the comments section.


Please cite the author and source when reprinting this article. Do not use it for any commercial purposes. Follow the “DevOps攻城狮” WeChat official account.

Related

How to fix "hidden symbol `__gcov_init' in ../libgcov.a(_gcov.o) is referenced by DSO"
·323 words·2 mins
This article explains how to resolve the “hidden symbol `__gcov_init’ in ../libgcov.a(_gcov.o) is referenced by DSO” error when building a project with Gcov, including how to ensure symbols are not hidden.
Reliably Unforking a GitHub Repository Without Deletion and Reconstruction
·359 words·1 min
This article describes how to separate a forked repository from its parent repository using GitHub Support, avoiding data loss from deletion and reconstruction, and helping developers better manage forked repositories.
About Code Coverage
·839 words·4 mins
This article briefly introduces the concept, importance, common metrics, working principle, and mainstream tools of code coverage, emphasizing that code coverage metrics should not be over-relied upon.
How to backup Jenkins
·214 words·2 mins
This article explains how to backup Jenkins using the ThinBackup plugin and shell scripts, ensuring that your Jenkins configuration and build data are safely stored.
Jenkins Top 3 best practice
·906 words·5 mins
Discusses three best practices for Jenkins: Configuration as Code, Shared Libraries, and Multi-Branch Pipeline, highlighting their benefits in terms of transparency, traceability, and self-service builds.
Beijing 48 Hours — A DevOps Training Camp Experience
·1080 words·6 mins
A record of my experience attending the JFrog DevOps training camp in Beijing, sharing training content, personal feelings, and reflections on future work.