-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (103 loc) · 4.09 KB
/
Copy pathrelease-notes.yml
File metadata and controls
118 lines (103 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Release notes validation
on:
pull_request:
branches: [master]
paths:
- "pyproject.toml"
- "statgpu/__init__.py"
- "CHANGELOG.md"
- "docs/en/changelog.md"
- "docs/cn/changelog.md"
- "RELEASING.md"
- ".github/releases/**"
- ".github/workflows/publish.yml"
- ".github/workflows/release-notes.yml"
workflow_dispatch:
permissions:
contents: read
jobs:
validate-release-notes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Validate versioned GitHub Release notes
run: |
python - <<'PY'
import pathlib
import re
import tomllib
root = pathlib.Path.cwd()
pyproject = tomllib.loads((root / "pyproject.toml").read_text(encoding="utf-8"))
version = pyproject["project"]["version"]
init_text = (root / "statgpu/__init__.py").read_text(encoding="utf-8")
match = re.search(r'^__version__\s*=\s*["\']([^"\']+)["\']', init_text, re.M)
if match is None:
raise SystemExit("statgpu/__init__.py does not declare __version__")
if match.group(1) != version:
raise SystemExit(
f"version mismatch: pyproject.toml={version}, "
f"statgpu/__init__.py={match.group(1)}"
)
notes_path = root / ".github" / "releases" / f"v{version}.md"
if not notes_path.is_file():
raise SystemExit(f"missing GitHub Release notes: {notes_path.relative_to(root)}")
notes = notes_path.read_text(encoding="utf-8")
lines = notes.splitlines()
expected_title = f"# statgpu {version}"
if not lines or lines[0].strip() != expected_title:
raise SystemExit(
f"release notes must start with {expected_title!r}: "
f"{notes_path.relative_to(root)}"
)
required_sections = [
"## Highlights",
"## Installation and platform support",
"## Validation",
"## Upgrade notes and known limits",
"## Full change history",
]
missing_sections = [section for section in required_sections if section not in notes]
if missing_sections:
raise SystemExit(
"release notes are missing required sections: "
+ ", ".join(missing_sections)
)
if len(notes.split()) < 500:
raise SystemExit("GitHub Release notes are too short to describe the release")
forbidden_placeholders = ["TODO", "TBD", "X.Y.Z", "CHANGEME"]
present_placeholders = [token for token in forbidden_placeholders if token in notes]
if present_placeholders:
raise SystemExit(
"release notes contain unresolved placeholders: "
+ ", ".join(present_placeholders)
)
required_fragments = [
f"pip install statgpu=={version}",
f"...v{version}",
"Windows",
"macOS",
"Ubuntu",
]
missing_fragments = [fragment for fragment in required_fragments if fragment not in notes]
if missing_fragments:
raise SystemExit(
"release notes are missing user-facing release details: "
+ ", ".join(missing_fragments)
)
synchronized_files = [
root / "CHANGELOG.md",
root / "docs" / "en" / "changelog.md",
root / "docs" / "cn" / "changelog.md",
]
for path in synchronized_files:
text = path.read_text(encoding="utf-8")
if version not in text:
raise SystemExit(
f"{path.relative_to(root)} does not contain release version {version}"
)
print(f"validated {notes_path.relative_to(root)} ({len(notes.split())} words)")
PY