Skip to content

Commit eec1532

Browse files
authored
Add Changelog (#1487)
1 parent 6b397a6 commit eec1532

File tree

7 files changed

+117
-7
lines changed

7 files changed

+117
-7
lines changed

docs-site/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs-site/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
},
1111
"dependencies": {
1212
"@cloudflare/workers-types": "^4.20250129.0",
13-
"typescript": "^5.7.3",
14-
"wrangler": "^3.106.0",
13+
"cookie": ">=0.7.0",
1514
"esbuild": ">=0.25.0",
16-
"cookie": ">=0.7.0"
15+
"marked": "^15.0.8",
16+
"typescript": "^5.7.3",
17+
"wrangler": "^3.106.0"
1718
}
1819
}

docs-site/src/index.ts

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
import { marked } from 'marked'
2+
13
export default {
24
async fetch(request, env): Promise<Response> {
5+
const url = new URL(request.url)
6+
if (url.pathname === '/changelog.html') {
7+
const changelog = await getChangelog(env.KV, env.GIT_COMMIT_SHA)
8+
return new Response(changelog, { headers: {'content-type': 'text/html'} })
9+
}
310
const r = await env.ASSETS.fetch(request)
411
if (r.status == 404) {
5-
const url = new URL(request.url)
612
const redirectPath = redirect(url.pathname)
713
if (redirectPath) {
814
url.pathname = redirectPath
@@ -25,3 +31,55 @@ const redirect_lookup: Record<string, string> = {
2531
function redirect(pathname: string): string | null {
2632
return redirect_lookup[pathname.replace(/\/+$/, '')] ?? null
2733
}
34+
35+
async function getChangelog(kv: KVNamespace, commitSha: string): Promise<string> {
36+
const cache_key = `changelog:${commitSha}`
37+
const cached = await kv.get(cache_key, {cacheTtl: 60})
38+
if (cached) {
39+
return cached
40+
}
41+
const headers = {
42+
'X-GitHub-Api-Version': '2022-11-28',
43+
'User-Agent': 'pydantic-ai-docs'
44+
}
45+
let url: string | undefined = 'https://api.github.com/repos/pydantic/pydantic-ai/releases'
46+
const releases: Release[] = []
47+
while (typeof url == 'string') {
48+
const response = await fetch(url, { headers })
49+
if (!response.ok) {
50+
const text = await response.text()
51+
throw new Error(`Failed to fetch changelog: ${response.status} ${response.statusText} ${text}`)
52+
}
53+
const newReleases = await response.json() as Release[]
54+
releases.push(...newReleases)
55+
const linkHeader = response.headers.get('link')
56+
if (!linkHeader) {
57+
break
58+
}
59+
url = linkHeader.match(/<([^>]+)>; rel="next"/)?.[1]
60+
}
61+
marked.use({pedantic: false, gfm: true})
62+
const html = marked(releases.map(prepRelease).join('\n\n')) as string
63+
await kv.put(cache_key, html, {expirationTtl: 300})
64+
return html
65+
}
66+
67+
interface Release {
68+
name: string
69+
body: string
70+
html_url: string
71+
}
72+
73+
function prepRelease(release: Release): string {
74+
const body = release.body
75+
.replace(/(#+)/g, (m) => `##${m}`)
76+
.replace(/https:\/\/github.com\/pydantic\/pydantic-ai\/pull\/(\d+)/g, (url, id) => `[#${id}](${url})`)
77+
.replace(/\*\*Full Changelog\*\*: (\S+)/, (_, url) => `[Compare diff](${url})`)
78+
return `
79+
### ${release.name}
80+
81+
${body}
82+
83+
[View on GitHub](${release.html_url})
84+
`
85+
}

docs-site/worker-configuration.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Generated by Wrangler by running `wrangler types worker-configuration.d.ts`
22

33
interface Env {
4-
VERSION_NOTICE_CACHE: KVNamespace;
4+
KV: KVNamespace;
55
GIT_COMMIT_SHA: string;
66
GIT_BRANCH: string;
77
ASSETS: Fetcher;

docs-site/wrangler.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ binding = "ASSETS"
1212
run_worker_first = true
1313

1414
[[kv_namespaces]]
15-
binding = "VERSION_NOTICE_CACHE"
15+
binding = "KV"
1616
id = "4e49a275426244488a79d572da40eb69"
1717

1818
[env.previews]
1919
workers_dev = true
2020
routes = []
2121

2222
[[env.previews.kv_namespaces]]
23-
binding = "VERSION_NOTICE_CACHE"
23+
binding = "KV"
2424
id = "95eb127177234122896b4f0a80412f1b"

docs/changelog.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Upgrade Guide
2+
3+
PydanticAI is still pre-version 1, so breaking changes will occur, however:
4+
5+
- We try to minimize them as much as possible.
6+
- We will use minor version bumps to signify breaking changes.
7+
- Wherever possible we'll deprecate old features so code continues to work with deprecation warnings when changing the public API.
8+
- We intend to release V1 in summer 2025, and then follow strict semantic versioning, e.g. no intentional breaking changes except in major versions.
9+
10+
## Breaking Changes
11+
12+
!!! note
13+
Here's a filtered list of the breaking changes for each version to help you upgrade PydanticAI.
14+
15+
### v0.1.0 2025-04-15
16+
17+
See [#1248](https://github.com/pydantic/pydantic-ai/pull/1248) — the attribute/parameter name `result` was renamed to `output` in many places. Hopefully all changes keep a deprecated attribute or parameter with the old name, so you should get many deprecation warnings.
18+
19+
See [#1484](https://github.com/pydantic/pydantic-ai/pull/1484)`format_as_xml` was moved and made available to import from the package root, e.g. `from pydantic_ai import format_as_xml`.
20+
21+
---
22+
23+
## Full Changelog
24+
25+
<div id="display-changelog">
26+
For the full changelog, see <a href="https://github.com/pydantic/pydantic-ai/releases">GitHub Releases</a>.
27+
</div>
28+
29+
<script>
30+
async function getChangelog() {
31+
const r = await fetch('/changelog.html');
32+
if (r.ok) {
33+
document.getElementById('display-changelog').innerHTML = await r.text();
34+
}
35+
}
36+
getChangelog();
37+
</script>

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ nav:
1515
- help.md
1616
- contributing.md
1717
- troubleshooting.md
18+
- changelog.md
1819
- Documentation:
1920
- agents.md
2021
- Models:

0 commit comments

Comments
 (0)