changelog-notes 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.4
2
+ Name: changelog-notes
3
+ Version: 0.1.0
4
+ Summary: Extract the notes for one version from CHANGELOG.md (for GitHub releases) and validate the format. Stdlib only.
5
+ Author-email: agent-one <rafal.baranowski.iot@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/rafal-one/changelog-notes
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Dynamic: license-file
14
+
15
+ # changelog-notes
16
+
17
+ Pull the release notes for one version out of a Keep-a-Changelog style `CHANGELOG.md`, and
18
+ validate the file. Handy in CI to fill a GitHub release body. Stdlib only, Python 3.9+.
19
+
20
+ ```
21
+ pip install changelog-notes
22
+ changelog-notes 1.2.0 > notes.md # notes for v1.2.0 (leading "v" optional)
23
+ changelog-notes # latest released version (skips Unreleased)
24
+ changelog-notes --list # versions and dates
25
+ changelog-notes --check # exit 1 on missing dates, empty or duplicate sections
26
+ ```
27
+
28
+ Options: `-f FILE` (default `CHANGELOG.md`). Exit codes: 0 ok, 1 not found / check failed, 2 file unreadable.
29
+ Headings like `## [1.2.0] - 2026-01-01` and `## v1.2.0 - 2026-01-01` are understood; link
30
+ reference footers (`[1.2.0]: https://...`) are dropped from the output.
31
+
32
+ GitHub Actions example: `gh release create "$TAG" -F <(changelog-notes "$TAG")`.
33
+
34
+ ## Support
35
+ If this saves you time: https://paypal.me/RafalBaranowski
36
+
37
+ MIT licensed.
@@ -0,0 +1,7 @@
1
+ changelog_notes.py,sha256=Vusk6Z4PQRYqfzt5VJh0zNDruk4RRYt2AFzlBwMSc_0,3041
2
+ changelog_notes-0.1.0.dist-info/licenses/LICENSE,sha256=-hZriFiksFsGGM2WbhdnQzoXUOFuMGve5P3y4pvA0Ws,1066
3
+ changelog_notes-0.1.0.dist-info/METADATA,sha256=9hN4Ycc_7F2Bq6L7eIBFl0fb3RRODkAiyQ-ecR1ydt4,1515
4
+ changelog_notes-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
5
+ changelog_notes-0.1.0.dist-info/entry_points.txt,sha256=e267WEf8BMhOguUFhsEBXxGBlaTRzF20bkpcfJXYdiM,57
6
+ changelog_notes-0.1.0.dist-info/top_level.txt,sha256=CS2mK9VNvtLXlQ41HRRc-OFUMdXtwpRBt5xGIQjwm64,16
7
+ changelog_notes-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ changelog-notes = changelog_notes:main
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 agent-one
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ changelog_notes
changelog_notes.py ADDED
@@ -0,0 +1,96 @@
1
+ """Extract and validate release notes from a Keep-a-Changelog style CHANGELOG.md."""
2
+ import argparse
3
+ import re
4
+ import sys
5
+
6
+ __version__ = "0.1.0"
7
+
8
+ HEAD = re.compile(r"^##\s+\[?v?([^\]\s]+)\]?(?:\s*[-–—]\s*(\S.*))?\s*$")
9
+ DATE = re.compile(r"^\d{4}-\d{2}-\d{2}$")
10
+
11
+
12
+ def parse(text):
13
+ """Return list of (version, date_or_None, body) in file order."""
14
+ out, cur = [], None
15
+ for line in text.splitlines():
16
+ m = HEAD.match(line)
17
+ if m:
18
+ if cur:
19
+ out.append(cur)
20
+ ver = m.group(1)
21
+ date = (m.group(2) or "").strip() or None
22
+ cur = [ver, date, []]
23
+ elif cur is not None:
24
+ if re.match(r"^\[[^\]]+\]:\s*\S+", line): # link reference footer
25
+ continue
26
+ cur[2].append(line)
27
+ if cur:
28
+ out.append(cur)
29
+ return [(v, d, "\n".join(b).strip("\n")) for v, d, b in out]
30
+
31
+
32
+ def get(entries, version):
33
+ version = version.lstrip("v")
34
+ for v, d, b in entries:
35
+ if v.lower() == version.lower():
36
+ return v, d, b
37
+ return None
38
+
39
+
40
+ def validate(entries):
41
+ problems = []
42
+ if not entries:
43
+ return ["no '## [version]' sections found"]
44
+ seen = set()
45
+ for v, d, b in entries:
46
+ if v.lower() in seen:
47
+ problems.append(f"duplicate version {v}")
48
+ seen.add(v.lower())
49
+ if v.lower() == "unreleased":
50
+ continue
51
+ if d is None:
52
+ problems.append(f"{v}: missing date")
53
+ elif not DATE.match(d.split()[0]):
54
+ problems.append(f"{v}: date '{d}' is not YYYY-MM-DD")
55
+ if not b.strip():
56
+ problems.append(f"{v}: empty section")
57
+ return problems
58
+
59
+
60
+ def main(argv=None):
61
+ p = argparse.ArgumentParser(prog="changelog-notes", description=__doc__)
62
+ p.add_argument("version", nargs="?", help="print notes for this version (default: latest released)")
63
+ p.add_argument("-f", "--file", default="CHANGELOG.md")
64
+ p.add_argument("--check", action="store_true", help="validate the changelog format")
65
+ p.add_argument("--list", action="store_true", help="list versions")
66
+ p.add_argument("-V", "--tool-version", action="version", version=__version__)
67
+ a = p.parse_args(argv)
68
+ try:
69
+ with open(a.file, encoding="utf-8") as f:
70
+ text = f.read()
71
+ except OSError as e:
72
+ print(f"changelog-notes: {e}", file=sys.stderr)
73
+ return 2
74
+ entries = parse(text)
75
+ if a.check:
76
+ probs = validate(entries)
77
+ for x in probs:
78
+ print(f"{a.file}: {x}")
79
+ return 1 if probs else 0
80
+ if a.list:
81
+ for v, d, _ in entries:
82
+ print(v + (f" {d}" if d else ""))
83
+ return 0
84
+ if a.version:
85
+ hit = get(entries, a.version)
86
+ else:
87
+ hit = next(((v, d, b) for v, d, b in entries if v.lower() != "unreleased"), None)
88
+ if not hit:
89
+ print(f"changelog-notes: version {a.version or '(latest)'} not found", file=sys.stderr)
90
+ return 1
91
+ print(hit[2])
92
+ return 0
93
+
94
+
95
+ if __name__ == "__main__":
96
+ sys.exit(main())