Skip to content

Commit 0c6b660

Browse files
Update README.md
1 parent e877b93 commit 0c6b660

File tree

1 file changed

+92
-26
lines changed

1 file changed

+92
-26
lines changed

README.md

Lines changed: 92 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# changelog-updater
22

3-
A PHP CLI to update a CHANGELOG following the ["Keep a Changelog"](https://keepachangelog.com/) format with the latest release notes.
3+
A PHP CLI to update a changelog with the latest release notes.
44

55
[![Latest Version on Packagist](https://img.shields.io/packagist/v/wnx/changelog-updater.svg?style=flat-square)](https://packagist.org/packages/wnx/changelog-updater)
66
[![Tests](https://github.com/stefanzweifel/php-changelog-updater/actions/workflows/run-tests.yml/badge.svg)](https://github.com/stefanzweifel/php-changelog-updater/actions/workflows/run-tests.yml)
77
[![Check & fix styling](https://github.com/stefanzweifel/php-changelog-updater/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/stefanzweifel/php-changelog-updater/actions/workflows/php-cs-fixer.yml)
88
[![Psalm](https://github.com/stefanzweifel/php-changelog-updater/actions/workflows/psalm.yml/badge.svg)](https://github.com/stefanzweifel/php-changelog-updater/actions/workflows/psalm.yml)
99
[![Total Downloads](https://img.shields.io/packagist/dt/wnx/changelog-updater.svg?style=flat-square)](https://packagist.org/packages/wnx/changelog-updater)
1010

11+
Want to automate the process of updating your changelog with GitHub Actions? Checkout the [stefanzweifel/changelog-updater-action](https://github.com/stefanzweifel/changelog-updater-action) which does exactly that.
1112

12-
Want to automate the process of updating your Changelog with GitHub Actions? Checkout the [stefanzweifel/changelog-updater-action](https://github.com/stefanzweifel/changelog-updater-action) which does exactly that.
13+
*If your changelog follows the ["Keep a Changelog"](https://keepachangelog.com/) format and has a "Unreleased" heading in it, the CLI will update the link in and place the release notes below heading.*
1314

1415
## Installation
1516

16-
You can install the changelog-updater CLI as a global composer dependency. It requires PHP 8.0 or higher.
17+
You can install the changelog-updater CLI as a composer dependency in your project or globally. It requires PHP 8.0 or higher.
1718

1819
```bash
1920
composer global require wnx/changelog-updater
@@ -42,53 +43,118 @@ php changelog-updater update \
4243

4344
`--release-date`, `--path-to-changelog` and `--write` are optional. Learn more about the options by running `php changelog-updater update --help`.
4445

46+
### CLI Options
47+
48+
### `--release-notes`
49+
**Required**. The release notes you want to add to your changelog. Should be markdown.
50+
51+
### `--latest-version`
52+
**Required**. Version number of the latest release. The value will be used as the heading text. If the changelog has a "Unreleased" heading, the value will be used in the updated compare URL.
53+
54+
Example: `v1.0.0`
55+
56+
### `--release-date`
57+
Optional (Defaults to current date). The date the latest version has been released. The value will be used in the release heading.
58+
59+
### `--path-to-changelog`
60+
Optional (Defaults to `CHANGELOG.md`). Path to CHANGELOG.md file.
61+
62+
### `--write`
63+
Optional. Write the changes to `CHANGELOG.md` or to the value of `--path-to-changelog`.
64+
65+
## Expected Changelog Formats
66+
67+
The CLI does its best to place the given release notes in the right place.
68+
69+
The CLI looks for the first second level heading in your current `CHANGELOG.md` file. It assumes that this heading represents the previous version. Here is an example of a `CHANGELOG.md` that the CLI can understand.
70+
71+
```
72+
# Changelog
73+
74+
## v1.0.0 - 2021-11-01
75+
76+
### Added
77+
- Initial Release
78+
```
4579

46-
### Important
80+
The CLI will then place the new version and its release notes **above** the existing versions.
4781

48-
Note that the Changelog MUST follow the "[Keep a Changelog](https://keepachangelog.com/en/1.0.0/)"-format.
49-
The CLI looks for a second level "Unreleased"-heading with a link. The link MUST point to the compare view of the latest version and `HEAD`.
50-
The CLI also looks for a second level heading with the name of the previous version. (If you release `v1.1.0` now, the previous version might be `v1.0.0`.)
82+
```diff
83+
# Changelog
5184

52-
Here is an example Markdown file, that will work fine with the CLI.
85+
+ ## v1.1.0 - 2021-11-10
86+
+
87+
+ ### Added
88+
+
89+
+ * New Feature
90+
+
91+
## v1.0.0 - 2021-11-01
5392

93+
### Added
5494

95+
* Initial Release
5596
```
97+
98+
If the changelog does not contain a second level heading, it considers the changelog to be "empty". It will then place the release notes at the bottom of the document.
99+
100+
```diff
56101
# Changelog
57102
All notable changes to this project will be documented in this file.
58103

59-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
60-
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
104+
+## v1.0.0 - 2021-11-01
105+
+
106+
+### Added
107+
+
108+
+* Initial Release
109+
```
110+
111+
---
112+
113+
If your changelog follows the ["Keep a Changelog"](https://keepachangelog.com/) format and contains an "Unreleased"-heading with a link to the repositories compare view, the CLI will automatically update the link in the Unreleased heading.
61114

62-
## [Unreleased](https://github.com/org/repo/compare/v0.1.0...HEAD)
115+
Here is an example of a changelog, before it is updated with the CLI.
63116

64-
*Please do not manually update this file. We've automated the process.*
117+
```
118+
# Changelog
119+
120+
## [Unreleased](https://github.com/org/repo/compare/v1.0.0...HEAD)
121+
122+
Please do not update the unreleased notes.
65123
66-
## v0.1.0 - 2021-01-01
124+
<!-- Content should be placed here -->
125+
126+
## v1.0.0 - 2021-01-01
67127
68128
### Added
69129
- Initial Release
70130
```
71131

72-
The content between the "Unreleased"-heading and the latest version will remain untouched by the CLI.
132+
Below you find a diff-view of how the CLI will update the changelog.
73133

74-
### CLI Options
134+
```diff
135+
# Changelog
75136

76-
### `--release-notes`
77-
**Required**. The release notes you want to add to your CHANGELOG. Should be markdown.
137+
+## [Unreleased](https://github.com/org/repo/compare/v1.1.0...HEAD)
138+
-## [Unreleased](https://github.com/org/repo/compare/v1.0.0...HEAD)
78139

79-
### `--latest-version`
80-
**Required**. Version number of the latest release. The value will be used as the heading text and as a parameter in the compare URL.
140+
Please do not update the unreleased notes.
81141

82-
Example: `v1.0.0`
142+
<!-- Content should be placed here -->
143+
+## [v1.1.0](https://github.com/org/repo/compare/v1.0.0...v1.1.0) - 2021-02-01
144+
+
145+
+### Added
146+
+
147+
+* New Feature A
148+
+* New Feature B
149+
+
83150

84-
### `--release-date`
85-
Optional (Defaults to current date). The date the latest version has been released. The value will be used in the release heading.
151+
## v1.0.0 - 2021-01-01
86152

87-
### `--path-to-changelog`
88-
Optional (Defaults to `CHANGELOG.md`). Path to CHANGELOG.md file.
153+
### Added
154+
* Initial Release
155+
```
89156

90-
### `--write`
91-
Optional. Write the changes to `CHANGELOG.md` or to the value of `--path-to-changelog`.
157+
The content between the "Unreleased"-heading and the latest version will remain untouched by the CLI.
92158

93159
## Testing
94160

0 commit comments

Comments
 (0)