]> jfr.im git - yt-dlp.git/blob - devscripts/update_changelog.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / devscripts / update_changelog.py
1 #!/usr/bin/env python3
2
3 # Allow direct execution
4 import os
5 import sys
6
7 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
8
9 from pathlib import Path
10
11 from devscripts.make_changelog import create_changelog, create_parser
12 from devscripts.utils import read_file, read_version, write_file
13
14 # Always run after devscripts/update-version.py, and run before `make doc|pypi-files|tar|all`
15
16 if __name__ == '__main__':
17 parser = create_parser()
18 parser.description = 'Update an existing changelog file with an entry for a new release'
19 parser.add_argument(
20 '--changelog-path', type=Path, default=Path(__file__).parent.parent / 'Changelog.md',
21 help='path to the Changelog file')
22 args = parser.parse_args()
23 new_entry = create_changelog(args)
24
25 header, sep, changelog = read_file(args.changelog_path).partition('\n### ')
26 write_file(args.changelog_path, f'{header}{sep}{read_version()}\n{new_entry}\n{sep}{changelog}')