|
| 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