Skip to content

Commit

Permalink
chore(changelog): new way to maintain the changelog (#11279)
Browse files Browse the repository at this point in the history
Summary
Maintaining changelogs in a single markdown file in the repo is one of the easy ways to maintain and also keep consistency. Since Kong has multiple release versions, sometimes a bug fix needs to be backported to all the supported versions after it gets merged to the master branch. The backport bot is currently broken because of the git conflict.

We're Introducing a new way to maintain Kong's changelog, which makes the changelog item become an individual file. The idea is, that you don't get the conflict if you don't edit the same file.

---------

Co-authored-by: Hans Hübner <hans.huebner@gmail.com>
Co-authored-by: Wangchong Zhou <wangchong@konghq.com>
(cherry picked from commit 17c971b)
  • Loading branch information
vm-001 authored and github-actions[bot] committed Aug 29, 2023
1 parent e32df85 commit 574f1b0
Show file tree
Hide file tree
Showing 10 changed files with 562 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ https://github.com/Kong/kong/blob/master/CONTRIBUTING.md#contributing
### Checklist

- [ ] The Pull Request has tests
- [ ] There's an entry in the CHANGELOG
- [ ] A changelog file has been added to `CHANGELOG/unreleased/kong` or adding `skip-changelog` label on PR if unnecessary. [README.md](https://github.com/Kong/kong/CHANGELOG/README.md) (Please ping @vm-001 if you need help)
- [ ] There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE

### Full changelog
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
# ignore markdown files (CHANGELOG.md, README.md, etc.)
- '**/*.md'
- '.github/workflows/release.yml'
- 'CHANGELOG/**'
push:
paths-ignore:
# ignore markdown files (CHANGELOG.md, README.md, etc.)
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Changelog

on:
pull_request:
types: [ "opened", "synchronize", "labeled", "unlabeled" ]

jobs:
require-changelog:
name: Is changelog required?
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Retrives changed files in CHANGELOG/unreleased/**/*.yaml
id: changelog-check
uses: tj-actions/changed-files@5817a9efb0d7cc34b917d8146ea10b9f32044968 # v37
with:
files: 'CHANGELOG/unreleased/**/*.yaml'

- name: Requires a changelog file if 'skip-changelog' label is not added
if: ${{ !contains(github.event.*.labels.*.name, 'skip-changelog') }}
run: >
if [ "${{ steps.changelog-check.outputs.added_files_count }}" = "0" ]; then
echo "PR should contain a changelog file"
exit 1
fi
validate-changelog:
name: Validate changelog
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Validate changelogs
uses: thiagodnf/yaml-schema-checker@228a5be72029114e3cd6301e0aaeef6b557fa033 # v0.0.8
with:
jsonSchemaFile: CHANGELOG/schema.json
yamlFiles: |
CHANGELOG/unreleased/*/*.yaml
3 changes: 3 additions & 0 deletions CHANGELOG/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
install_dependencies:
luarocks install penlight --local
luarocks install lyaml --local
88 changes: 88 additions & 0 deletions CHANGELOG/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# CHANGELOG

The CHANGELOG directory is used for individual changelog file practice.
The `kong/CHANGELOG.md` now is deprecated.


## How to add a changelog file for your PR?

1/ Copy the `changelog-template.yaml` file and rename with your PR number or a short message as the filename. For example, `11279.yaml`, `introduce-a-new-changelog-system.yaml`. (Prefer using PR number as it's already unique and wouldn't introduce conflict)

2/ Fill out the changelog template.


The description of the changelog file field, please follow the `schema.json` for more details.

- message: Message of the changelog
- type: Changelog type. (`feature`, `bugfix`, `dependency`, `deprecation`, `breaking_change`)
- scope: Changelog scope. (`Core`, `Plugin`, `PDK`, `Admin API`, `Performance`, `Configuration`, `Clustering`)
- prs: List of associated GitHub PRs
- issues: List of associated GitHub issues
- jiras: List of associated Jira tickets for internal track

Sample 1
```yaml
message: Introduce the request id as core feature.
type: feat
scope: Core
prs:
- 11308
```
Sample 2
```yaml
message: Fix response body gets repeated when `kong.response.get_raw_body()` is called multiple times in a request lifecycle.
type: bugfix
scope: PDK
prs:
- 11424
jiras:
- "FTI-5296"
```
## changelog command
The `changelog` command tool provides `preview`, and `release` commands.

### Prerequisites

You can skip this part if you're at Kong Bazel virtual env.

Install luajit

Install luarocks libraries

```
luarocks install penlight --local
luarocks install lyaml --local
```
### Usage
```shell
$ ./changelog -h
Usage: changelog <command> [options]
Commands:
release <version> release a release note based on the files in the CHANGELOG/unreleased directory.
preview <version> preview a release note based on the files in the CHANGELOG/unreleased directory.
Options:
-h, --help display help for command
Examples:
changelog preview 1.0.0
changelog release 1.0.0
```

**Preview a release note**
```shell
./changelog preview 1.0.0
```

**Release a release note**
```shell
./changelog release 1.0.0
```
Loading

0 comments on commit 574f1b0

Please sign in to comment.