Skip to content

Commit a888046

Browse files
YuriiMotovtiangolo
andauthored
🔨 Add pre-commit hook to ensure latest release header has date (#323)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
1 parent 1f35aeb commit a888046

File tree

3 files changed

+69
-22
lines changed

3 files changed

+69
-22
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,10 @@ repos:
4040
require_serial: true
4141
language: unsupported
4242
pass_filenames: false
43+
44+
- id: add-release-date
45+
language: unsupported
46+
name: add date to latest release header
47+
entry: uv run python scripts/add_latest_release_date.py
48+
files: ^release-notes\.md$
49+
pass_filenames: false

release-notes.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
* ⬆ Bump typer from 0.23.1 to 0.24.0. PR [#312](https://github.com/fastapi/fastapi-cli/pull/312) by [@dependabot[bot]](https://github.com/apps/dependabot).
5151
* ⬆ Bump uvicorn from 0.40.0 to 0.41.0. PR [#311](https://github.com/fastapi/fastapi-cli/pull/311) by [@dependabot[bot]](https://github.com/apps/dependabot).
5252

53-
## 0.0.23
53+
## 0.0.23 (2026-02-16)
5454

5555
### Breaking Changes
5656

@@ -60,7 +60,7 @@
6060

6161
* 🎨 Update format and types for Python 3.10. PR [#310](https://github.com/fastapi/fastapi-cli/pull/310) by [@tiangolo](https://github.com/tiangolo).
6262

63-
## 0.0.22
63+
## 0.0.22 (2026-02-16)
6464

6565
### Internal
6666

@@ -74,7 +74,7 @@
7474
* ⬆ Bump rich-toolkit from 0.19.2 to 0.19.3. PR [#303](https://github.com/fastapi/fastapi-cli/pull/303) by [@dependabot[bot]](https://github.com/apps/dependabot).
7575
* ➕ Replace test dependency on `fastapi-slim` with `fastapi`. PR [#301](https://github.com/fastapi/fastapi-cli/pull/301) by [@musicinmybrain](https://github.com/musicinmybrain).
7676

77-
## 0.0.21
77+
## 0.0.21 (2026-02-11)
7878

7979
### Internal
8080

@@ -108,19 +108,19 @@
108108
* ⬆ Bump actions/download-artifact from 6 to 7. PR [#260](https://github.com/fastapi/fastapi-cli/pull/260) by [@dependabot[bot]](https://github.com/apps/dependabot).
109109
* 👷 Add pre-commit workflow. PR [#266](https://github.com/fastapi/fastapi-cli/pull/266) by [@YuriiMotov](https://github.com/YuriiMotov).
110110

111-
## 0.0.20
111+
## 0.0.20 (2025-12-22)
112112

113113
### Features
114114

115115
* ✨ Add --reload-dir option to dev command. PR [#267](https://github.com/fastapi/fastapi-cli/pull/267) by [@patrick91](https://github.com/patrick91).
116116

117-
## 0.0.19
117+
## 0.0.19 (2025-12-22)
118118

119119
### Breaking Changes
120120

121121
* 🔧 Drop support for Python 3.8. PR [#269](https://github.com/fastapi/fastapi-cli/pull/269) by [@patrick91](https://github.com/patrick91).
122122

123-
## 0.0.18
123+
## 0.0.18 (2025-12-22)
124124

125125
### Features
126126

@@ -130,7 +130,7 @@
130130

131131
* 🐛 Fix log alignment when pressing Ctrl+C to stop server. PR [#253](https://github.com/fastapi/fastapi-cli/pull/253) by [@savannahostrowski](https://github.com/savannahostrowski).
132132

133-
## 0.0.17
133+
## 0.0.17 (2025-12-22)
134134

135135
### Upgrades
136136

@@ -151,13 +151,13 @@
151151
* ⬆ Bump ruff from 0.14.2 to 0.14.4. PR [#239](https://github.com/fastapi/fastapi-cli/pull/239) by [@dependabot[bot]](https://github.com/apps/dependabot).
152152
*[pre-commit.ci] pre-commit autoupdate. PR [#238](https://github.com/fastapi/fastapi-cli/pull/238) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
153153

154-
## 0.0.16
154+
## 0.0.16 (2025-11-10)
155155

156156
### Fixes
157157

158158
* 🐛 Fix support for Pydantic v1. PR [#240](https://github.com/fastapi/fastapi-cli/pull/240) by [@patrick91](https://github.com/patrick91).
159159

160-
## 0.0.15
160+
## 0.0.15 (2025-11-10)
161161

162162
### Features
163163

@@ -182,7 +182,7 @@ entrypoint = "some.importable_module:app_name"
182182
* 🔧 Configure reminder for `waiting` label in `issue-manager`. PR [#227](https://github.com/fastapi/fastapi-cli/pull/227) by [@YuriiMotov](https://github.com/YuriiMotov).
183183
*[pre-commit.ci] pre-commit autoupdate. PR [#215](https://github.com/fastapi/fastapi-cli/pull/215) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
184184

185-
## 0.0.14
185+
## 0.0.14 (2025-10-20)
186186

187187
### Upgrades
188188

@@ -192,13 +192,13 @@ entrypoint = "some.importable_module:app_name"
192192

193193
* ⬆ Bump tiangolo/issue-manager from 0.5.1 to 0.6.0. PR [#220](https://github.com/fastapi/fastapi-cli/pull/220) by [@dependabot[bot]](https://github.com/apps/dependabot).
194194

195-
## 0.0.13
195+
## 0.0.13 (2025-09-20)
196196

197197
### Features
198198

199199
* ✨ Allow to use `-h` for help. PR [#191](https://github.com/fastapi/fastapi-cli/pull/191) by [@patrick91](https://github.com/patrick91).
200200

201-
## 0.0.12
201+
## 0.0.12 (2025-09-17)
202202

203203
### Features
204204

@@ -212,7 +212,7 @@ entrypoint = "some.importable_module:app_name"
212212
*[pre-commit.ci] pre-commit autoupdate. PR [#208](https://github.com/fastapi/fastapi-cli/pull/208) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
213213
*[pre-commit.ci] pre-commit autoupdate. PR [#205](https://github.com/fastapi/fastapi-cli/pull/205) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
214214

215-
## 0.0.11
215+
## 0.0.11 (2025-09-09)
216216

217217
### Features
218218

@@ -244,7 +244,7 @@ $ fastapi run --entrypoint some.importable_module:app_name
244244
* ⬆ Bump pypa/gh-action-pypi-publish from 1.12.4 to 1.13.0. PR [#200](https://github.com/fastapi/fastapi-cli/pull/200) by [@dependabot[bot]](https://github.com/apps/dependabot).
245245
* 👷 Detect and label merge conflicts on PRs automatically. PR [#204](https://github.com/fastapi/fastapi-cli/pull/204) by [@svlandeg](https://github.com/svlandeg).
246246

247-
## 0.0.10
247+
## 0.0.10 (2025-08-31)
248248

249249
### Features
250250

@@ -259,13 +259,13 @@ $ fastapi run --entrypoint some.importable_module:app_name
259259
* ⬆ Bump tiangolo/latest-changes from 0.3.2 to 0.4.0. PR [#188](https://github.com/fastapi/fastapi-cli/pull/188) by [@dependabot[bot]](https://github.com/apps/dependabot).
260260
* ⬆ Bump astral-sh/setup-uv from 5 to 6. PR [#176](https://github.com/fastapi/fastapi-cli/pull/176) by [@dependabot[bot]](https://github.com/apps/dependabot).
261261

262-
## 0.0.9
262+
## 0.0.9 (2025-08-31)
263263

264264
### Fixes
265265

266266
* 🔧 Remove command script `fastapi`, let it be provided by the `fastapi` package. PR [#197](https://github.com/fastapi/fastapi-cli/pull/197) by [@tiangolo](https://github.com/tiangolo).
267267

268-
## 0.0.8
268+
## 0.0.8 (2025-07-07)
269269

270270
### Features
271271

@@ -290,7 +290,7 @@ If you want to install `fastapi` with the standard dependencies except for `fast
290290
* ⬆ Bump astral-sh/setup-uv from 4 to 5. PR [#140](https://github.com/fastapi/fastapi-cli/pull/140) by [@dependabot[bot]](https://github.com/apps/dependabot).
291291
* ⬆ Bump mypy from 1.13.0 to 1.14.0. PR [#141](https://github.com/fastapi/fastapi-cli/pull/141) by [@dependabot[bot]](https://github.com/apps/dependabot).
292292

293-
## 0.0.7
293+
## 0.0.7 (2024-12-15)
294294

295295
### Fixes
296296

@@ -303,7 +303,7 @@ If you want to install `fastapi` with the standard dependencies except for `fast
303303
*[pre-commit.ci] pre-commit autoupdate. PR [#62](https://github.com/fastapi/fastapi-cli/pull/62) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
304304
* ⬆ Bump ruff from 0.5.5 to 0.8.1. PR [#128](https://github.com/fastapi/fastapi-cli/pull/128) by [@dependabot[bot]](https://github.com/apps/dependabot).
305305

306-
## 0.0.6
306+
## 0.0.6 (2024-12-04)
307307

308308
### Features
309309

@@ -339,7 +339,7 @@ If you want to install `fastapi` with the standard dependencies except for `fast
339339
* 🔧 Update GitHub Action add-to-project. PR [#66](https://github.com/fastapi/fastapi-cli/pull/66) by [@tiangolo](https://github.com/tiangolo).
340340
* 👷 Add GitHub Action add-to-project. PR [#65](https://github.com/fastapi/fastapi-cli/pull/65) by [@tiangolo](https://github.com/tiangolo).
341341

342-
## 0.0.5
342+
## 0.0.5 (2024-08-02)
343343

344344
### Breaking Changes
345345

@@ -393,7 +393,7 @@ In a future version, `fastapi-cli` will not include Uvicorn unless it is install
393393
* 👷 Enable CI tests for Python 3.12. PR [#27](https://github.com/tiangolo/fastapi-cli/pull/27) by [@tiangolo](https://github.com/tiangolo).
394394
* 👷 Update Upload/Download artifacts GitHub Actions. PR [#26](https://github.com/tiangolo/fastapi-cli/pull/26) by [@tiangolo](https://github.com/tiangolo).
395395

396-
## 0.0.4
396+
## 0.0.4 (2024-05-19)
397397

398398
### Fixes
399399

@@ -404,7 +404,7 @@ In a future version, `fastapi-cli` will not include Uvicorn unless it is install
404404
* ⬆ Bump actions/cache from 3 to 4. PR [#5](https://github.com/tiangolo/fastapi-cli/pull/5) by [@dependabot[bot]](https://github.com/apps/dependabot).
405405
* ⬆ Bump pypa/gh-action-pypi-publish from 1.8.11 to 1.8.14. PR [#2](https://github.com/tiangolo/fastapi-cli/pull/2) by [@dependabot[bot]](https://github.com/apps/dependabot).
406406

407-
## 0.0.3
407+
## 0.0.3 (2024-05-07)
408408

409409
### Features
410410

@@ -424,7 +424,7 @@ In a future version, `fastapi-cli` will not include Uvicorn unless it is install
424424
* ⬆ Update pytest requirement from <8.0.0,>=4.4.0 to >=4.4.0,<9.0.0. PR [#4](https://github.com/tiangolo/fastapi-cli/pull/4) by [@dependabot[bot]](https://github.com/apps/dependabot).
425425
* ⬆ Bump mypy from 1.4.1 to 1.10.0. PR [#7](https://github.com/tiangolo/fastapi-cli/pull/7) by [@dependabot[bot]](https://github.com/apps/dependabot).
426426

427-
## 0.0.2
427+
## 0.0.2 (2024-05-02)
428428

429429
First public working version. 🚀
430430

scripts/add_latest_release_date.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""Check release-notes.md and add today's date to the latest release header if missing."""
2+
3+
import re
4+
import sys
5+
from datetime import date
6+
7+
RELEASE_NOTES_FILE = "release-notes.md"
8+
RELEASE_HEADER_PATTERN = re.compile(r"^## (\d+\.\d+\.\d+)\s*(\(.*\))?\s*$")
9+
10+
11+
def main() -> None:
12+
with open(RELEASE_NOTES_FILE) as f:
13+
lines = f.readlines()
14+
15+
for i, line in enumerate(lines):
16+
match = RELEASE_HEADER_PATTERN.match(line)
17+
if not match:
18+
continue
19+
20+
version = match.group(1)
21+
date_part = match.group(2)
22+
23+
if date_part:
24+
print(f"Latest release {version} already has a date: {date_part}")
25+
sys.exit(0)
26+
27+
today = date.today().isoformat()
28+
lines[i] = f"## {version} ({today})\n"
29+
print(f"Added date: {version} ({today})")
30+
31+
with open(RELEASE_NOTES_FILE, "w") as f:
32+
f.writelines(lines)
33+
sys.exit(0)
34+
35+
print("No release header found")
36+
sys.exit(1)
37+
38+
39+
if __name__ == "__main__":
40+
main()

0 commit comments

Comments
 (0)