Skip to content

Commit cb483b2

Browse files
vdusekclaude
andauthored
docs: Fix broken versioning of changelog (#1829)
## Summary - Replace manual `cp CHANGELOG.md` in build scripts with a Docusaurus `changelogFromRoot` plugin that copies the root changelog to `docs/` and all `versioned_docs/` at build time - Remove versioned changelog snapshots from git tracking (gitignored, same as SDK/client repos) - Update release workflow to exclude changelog from version snapshots - The current workflow doesn't work anyway --- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d220bcf commit cb483b2

File tree

7 files changed

+39
-1400
lines changed

7 files changed

+39
-1400
lines changed

.github/workflows/manual_release_stable.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,13 @@ jobs:
157157
rm -rf "versioned_docs/version-${MAJOR_MINOR}"
158158
rm -rf "versioned_sidebars/version-${MAJOR_MINOR}-sidebars.json"
159159
jq 'map(select(. != env.MAJOR_MINOR))' versions.json > tmp.json && mv tmp.json versions.json
160-
# Copy changelog
161-
cp ../CHANGELOG.md ../docs/changelog.md
162160
# Build API reference and create version snapshots
163161
bash build_api_reference.sh
164162
npx docusaurus docs:version "$MAJOR_MINOR"
165163
npx docusaurus api:version "$MAJOR_MINOR"
164+
# Changelog is not versioned - it is copied from root at build time
165+
rm -f "versioned_docs/version-${MAJOR_MINOR}/changelog.md"
166+
echo "changelog.md" > "versioned_docs/version-${MAJOR_MINOR}/.gitignore"
166167
167168
- name: Commit and push versioned docs
168169
id: commit_versioned_docs

website/docusaurus.config.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable global-require */
2-
const path = require('path');
2+
const fs = require('node:fs');
3+
const path = require('node:path');
34

45
const { externalLinkProcessor } = require('./tools/utils/externalLink');
56

@@ -232,6 +233,35 @@ module.exports = {
232233
},
233234
};
234235
},
236+
// Copy root CHANGELOG.md to docs/ and all versioned_docs/ so every
237+
// doc version displays the same (latest) changelog — not a snapshot.
238+
function changelogFromRoot() {
239+
const sourceChangelog = path.join(__dirname, '..', 'CHANGELOG.md');
240+
return {
241+
name: 'changelog-from-root',
242+
async loadContent() {
243+
if (!fs.existsSync(sourceChangelog)) return;
244+
245+
const changelog = fs.readFileSync(sourceChangelog, 'utf-8');
246+
const docsDir = path.join(__dirname, '..', 'docs');
247+
const versionedDocsDir = path.join(__dirname, 'versioned_docs');
248+
249+
const targetDirs = [docsDir];
250+
if (fs.existsSync(versionedDocsDir)) {
251+
for (const version of fs.readdirSync(versionedDocsDir)) {
252+
targetDirs.push(path.join(versionedDocsDir, version));
253+
}
254+
}
255+
256+
for (const dir of targetDirs) {
257+
fs.writeFileSync(path.join(dir, 'changelog.md'), changelog);
258+
}
259+
},
260+
getPathsToWatch() {
261+
return [sourceChangelog];
262+
},
263+
};
264+
},
235265
[
236266
path.resolve(__dirname, 'src/plugins/docusaurus-plugin-segment'),
237267
{

website/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"scripts": {
44
"examples": "docusaurus-examples",
55
"postinstall": "npx patch-package",
6-
"start": "rimraf .docusaurus && cp ../CHANGELOG.md ../docs/changelog.md && docusaurus start",
7-
"start:fast": "rimraf .docusaurus && cp ../CHANGELOG.md ../docs/changelog.md && CRAWLEE_DOCS_FAST=1 docusaurus start",
8-
"build": "rimraf .docusaurus && cp ../CHANGELOG.md ../docs/changelog.md && node --max_old_space_size=16000 node_modules/@docusaurus/core/bin/docusaurus.mjs build",
6+
"start": "rimraf .docusaurus && docusaurus start",
7+
"start:fast": "rimraf .docusaurus && CRAWLEE_DOCS_FAST=1 docusaurus start",
8+
"build": "rimraf .docusaurus && node --max_old_space_size=16000 node_modules/@docusaurus/core/bin/docusaurus.mjs build",
99
"publish-gh-pages": "docusaurus-publish",
1010
"write-translations": "docusaurus write-translations",
1111
"version": "docusaurus version",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
changelog.md

0 commit comments

Comments
 (0)