|
1 | 1 | # changelog-updater |
2 | 2 |
|
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. |
4 | 4 |
|
5 | 5 | [](https://packagist.org/packages/wnx/changelog-updater) |
6 | 6 | [](https://github.com/stefanzweifel/php-changelog-updater/actions/workflows/run-tests.yml) |
7 | 7 | [](https://github.com/stefanzweifel/php-changelog-updater/actions/workflows/php-cs-fixer.yml) |
8 | 8 | [](https://github.com/stefanzweifel/php-changelog-updater/actions/workflows/psalm.yml) |
9 | 9 | [](https://packagist.org/packages/wnx/changelog-updater) |
10 | 10 |
|
| 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. |
11 | 12 |
|
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.* |
13 | 14 |
|
14 | 15 | ## Installation |
15 | 16 |
|
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. |
17 | 18 |
|
18 | 19 | ```bash |
19 | 20 | composer global require wnx/changelog-updater |
@@ -42,53 +43,118 @@ php changelog-updater update \ |
42 | 43 |
|
43 | 44 | `--release-date`, `--path-to-changelog` and `--write` are optional. Learn more about the options by running `php changelog-updater update --help`. |
44 | 45 |
|
| 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 | +``` |
45 | 79 |
|
46 | | -### Important |
| 80 | +The CLI will then place the new version and its release notes **above** the existing versions. |
47 | 81 |
|
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 |
51 | 84 |
|
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 |
53 | 92 |
|
| 93 | +### Added |
54 | 94 |
|
| 95 | +* Initial Release |
55 | 96 | ``` |
| 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 |
56 | 101 | # Changelog |
57 | 102 | All notable changes to this project will be documented in this file. |
58 | 103 |
|
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. |
61 | 114 |
|
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. |
63 | 116 |
|
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. |
65 | 123 |
|
66 | | -## v0.1.0 - 2021-01-01 |
| 124 | +<!-- Content should be placed here --> |
| 125 | +
|
| 126 | +## v1.0.0 - 2021-01-01 |
67 | 127 |
|
68 | 128 | ### Added |
69 | 129 | - Initial Release |
70 | 130 | ``` |
71 | 131 |
|
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. |
73 | 133 |
|
74 | | -### CLI Options |
| 134 | +```diff |
| 135 | +# Changelog |
75 | 136 |
|
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) |
78 | 139 |
|
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. |
81 | 141 |
|
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 | ++ |
83 | 150 |
|
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 |
86 | 152 |
|
87 | | -### `--path-to-changelog` |
88 | | -Optional (Defaults to `CHANGELOG.md`). Path to CHANGELOG.md file. |
| 153 | +### Added |
| 154 | +* Initial Release |
| 155 | +``` |
89 | 156 |
|
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. |
92 | 158 |
|
93 | 159 | ## Testing |
94 | 160 |
|
|
0 commit comments