Skip to content

Commit

Permalink
Added JSON-based changes to auto-generate the changelog.
Browse files Browse the repository at this point in the history
Solves merge conflicts between changelogs, by using sorting and
type-based merging for the changelog from a series of JSON files. This
allows conflict-free generation of a changelog using JSON-based changes,
stored in `.changes`.

Each entry can be object or array-based: the array must contain objects,
where each object is a different change. The entries are added to the
changelog, in sorted order, and the validity of the changelog is
verified.

To ensure fidelity of the changelog changes, the `no changelog` flag or
at least 1 change (either removed, or added/dified and almovidated) for
a JSON file under `.changes` must occur.

A `pre-release-hook` has been added so all these changes are automerged
into the CHANGELOG prior to release.
  • Loading branch information
Alexhuszagh committed Jul 9, 2022
1 parent 77952e4 commit b89a186
Show file tree
Hide file tree
Showing 15 changed files with 1,396 additions and 26 deletions.
5 changes: 5 additions & 0 deletions .changes/918.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"description": "use JSON-based files to autogenerate CHANGELOG.md",
"issues": [662],
"type": "internal"
}
46 changes: 46 additions & 0 deletions .changes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Changes

This stores changes to automatically generate the changelog, to avoid merge conflicts. Files should be in a JSON format, with the following format:

```json
{
"description": "single-line description to add to the CHANGELOG.",
"issues": [894],
"type": "added",
"breaking": false
}
```

Valid types are:
- added (Added)
- changed (Changed)
- fixed (Fixed)
- removed (Removed)
- internal (Internal)

`breaking` is optional and defaults to false. if `breaking` is present for any active changes, a `BREAKING:` notice will be added at the start of the entry. `issues` is also optional, and is currently unused, and is an array of issues fixed by the PR, and defaults to an empty array.

The file numbers should be `${pr}.json`. The `pr` is optional, and if not, an issue number should be used, in the `_${issue}.json` format. We also support multiple PRs per entry, using the `${pr1}-${pr2}-(...).json` format.

If multiple changes are made in a single PR, you can also pass an array of entries:

```json
[
{
"description": "this is one added entry.",
"issues": [630],
"type": "added"
},
{
"description": "this is another added entry.",
"issues": [642],
"type": "added"
},
{
"description": "this is a fixed entry that has no attached issue.",
"type": "fixed"
}
]
```

See [template](/.changes/template) for sample object and array-based changes.
22 changes: 22 additions & 0 deletions .changes/template/940.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"description": "this is one added entry.",
"issues": [630],
"type": "added"
},
{
"description": "this is another added entry.",
"issues": [642],
"type": "added"
},
{
"description": "this is a fixed entry that has no attached issue.",
"type": "fixed"
},
{
"description": "this is a breaking change.",
"issues": [679],
"breaking": true,
"type": "changed"
}
]
5 changes: 5 additions & 0 deletions .changes/template/978.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"description": "sample description for a PR adding one CHANGELOG entry.",
"issues": [437],
"type": "fixed"
}
5 changes: 5 additions & 0 deletions .changes/template/979-981.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"description": "this has 2 PRs associated.",
"issues": [441],
"type": "added"
}
Loading

0 comments on commit b89a186

Please sign in to comment.