Skip to content

Commit 1663b95

Browse files
Merge pull request #1632 from SgtCoDFish/freeze-docs
Add script for 'freezing' docs
2 parents 759b1eb + d16b14e commit 1663b95

File tree

6 files changed

+71
-10
lines changed

6 files changed

+71
-10
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ site you're working on.
8989
For example, the [manifest for the docs section](https://github.com/cert-manager/website/blob/master/content/docs/manifest.json)
9090
contains the expected path for every file.
9191

92+
If you're adding a top-level page which should only appear in the `docs/` section (such as the existing "contributing" section)
93+
then add `"x-only-docs": true` underneath the title in `manifest.json`. This will cause that section to be removed when a new versioned docs section.
94+
95+
Likewise, if a folder shouldn't be copied from `docs/` to a versioned section, add a file called `.x-only-docs` to that folder, and it will be removed from any newly created versioned documentation.
96+
9297
### Task: Changing OpenGraph / social sharing tags
9398

9499
These tags are defined in Next.js code and config.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is a marker file indicating that this folder should not be copied when freezing docs and should only be visible in `content/docs`.
2+
3+
See `scripts/freeze-docs` for more details.

content/docs/contributing/release-process.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,20 +256,16 @@ page if a step is missing or if it is outdated.
256256
+"cert_manager_latest_version": "v1.14.3",
257257
```
258258
259-
5. (**final release only**) Freeze the `docs/` folder by creating a copy ,
260-
removing the pages from that copy that don't make sense to be versioned,
261-
and updating the `manifest.json` file:
259+
5. (**final release only**) Freeze the `docs/` folder by running the following script:
262260
263261
```bash
264-
export RELEASE=1.15
265-
cp -r content/docs content/v${RELEASE}-docs
266-
rm -rf content/v${RELEASE}-docs/{release-notes,contributing}
267-
sed -i.bak "s|/docs/|/v${RELEASE}-docs/|g" content/v${RELEASE}-docs/manifest.json
268-
jq < content/v${RELEASE}-docs/manifest.json >/tmp/manifest \
269-
'del(.routes[0].routes[] | select(.title | test("Releases|Contributing")))'
270-
mv /tmp/manifest content/v${RELEASE}-docs/manifest.json
262+
# From the website repository, on the master branch.
263+
./scripts/freeze-docs 1.16
271264
```
272265
266+
This copies the `docs/` folder to a versioned folder (e.g. `v1.15-docs`) and removes any
267+
folders which should not be present in versioned docs.
268+
273269
6. (**final + patch releases**) Update the [API docs](https://cert-manager.io/docs/reference/api-docs/) and [CLI docs](https://cert-manager.io/docs/cli//):
274270
275271
```bash

content/docs/manifest.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
{
1616
"title": "Releases",
17+
"x-only-docs": true,
1718
"routes": [
1819
{
1920
"title": "Supported Releases",
@@ -696,6 +697,7 @@
696697
},
697698
{
698699
"title": "Contributing",
700+
"x-only-docs": true,
699701
"routes": [
700702
{
701703
"title": "Introduction",

content/docs/releases/.x-only-docs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is a marker file indicating that this folder should not be copied when freezing docs and should only be visible in `content/docs`.
2+
3+
See `scripts/freeze-docs` for more details.

scripts/freeze-docs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2025 The cert-manager Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
# This script "freezes" the docs folder, copying docs which are relevant for a
22+
# specific cert-manager release into their own folder so they can be browsed
23+
# individually.
24+
#
25+
# For example, upon the release of cert-manager v1.17 we use this script to
26+
# "freeze" cert-manager v1.16, creating content/v1.16-docs and removing some
27+
# fields which aren't relevant (such as release notes or "contributing" docs)
28+
29+
RELEASE=${1:-}
30+
31+
if [[ -z "${RELEASE}" ]]; then
32+
echo "usage: $0 <release-version>"
33+
echo "e.g. $0 1.16"
34+
exit 1
35+
fi
36+
37+
cp -r content/docs content/v${RELEASE}-docs
38+
39+
# Delete any folders in the new v$RELEASE-docs section which contain a file
40+
# named ".x-only-docs"
41+
rm -rf $(find content/v${RELEASE}-docs -name ".x-only-docs" -execdir pwd \;)
42+
43+
TMP_FILE=$(mktemp)
44+
45+
trap "rm -rf ${TMP_FILE}" EXIT
46+
47+
# Replace paths containing /docs/ with a versioned path
48+
sed "s|/docs/|/v${RELEASE}-docs/|g" content/v${RELEASE}-docs/manifest.json > $TMP_FILE
49+
50+
# Remove any parts of the manifest which have "x-only-docs": true
51+
jq <$TMP_FILE > content/v${RELEASE}-docs/manifest.json \
52+
'del(.routes[0].routes[] | select(."x-only-docs" == true))'

0 commit comments

Comments
 (0)