googleapis / googleapis/release-please
Add "postchangelog" option to allow the changelog to be modified
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 588
- Avg merge
- 12h 16m
- Merged PRs (30d)
- 7
Description
[standard-version](https://github.com/conventional-changelog/standard-version) ( deprecated) recommends [release-please](https://github.com/googleapis/release-please) as an alternative
One feature that could be very useful for `release-please` is the `postchangelog` option, which allows you to run a script/command once the changelog has been generated so that it can also be edited
### example/proposal `release-please-config.json`
```json
{
"packages": {
".": {
"changelog-path": "CHANGELOG.md",
"changelog-post-script": "node ./scripts/addJiraLinkToChangelog.js"
}
}
}
```
This is useful in cases where you want to change part of the style of the generated changelog.
---
## Example of changelog ( without `postchangelog` option )
```md
## [1.11.1](https://github.com/owner/repo/compare/b2b-release-v1.11.0...b2b-release-v1.11.1) (2023-08-10)
### 🐛 Bug Fixes
* [ticket-1234] fix alertbox ([2bf28f7](https://github.com/owner/repo/commit/xxx))
```
### Example of changelog ( with `postchangelog` option )
```md
[1.11.1](https://github.com/owner/repo/compare/b2b-release-v1.11.0...b2b-release-v1.11.1) (2023-08-10)
```mx
### 🐛 Bug Fixes
* [ticket-1234](https://telepass.atlassian.net/browse/TICKET-1234) fix alertbox ([2bf28f7](https://github.com/owner/repo/commit/xxx))
```
### example of `addJiraLinkToChangelog.js`
```javascript
const { promises } = require("fs");
const { resolve } = require("path");
const REGEX = [
/(\[)((ticket|TICKET){1,}-\d+)(\])(?!\()/gm,
/(\()((ticket|TICKET){1,}-\d+)(\))(?!\()/gm,
];
function replacer(found) {
const ticket = found
.replace("[", "")
.replace("]", "")
.replace("(", "")
.replace(")", "")
.toUpperCase();
return `[${ticket}](https://company.atlassian.net/browse/${ticket})`;
}
async function updateChangelog() {
const changelogPath = resolve("./", "CHANGELOG.md");
const file = await promises.readFile(changelogPath, { encoding: "utf-8" });
const result = file.replace(REGEX[0], replacer).replace(REGEX[1], replacer);
await promises.writeFile(changelogPath, result);
}
updateChangelog();
```
Contributor guide
Assessment
This issue has not been assessed yet.