|
14 | 14 | # See the License for the specific language governing permissions and |
15 | 15 | # limitations under the License. |
16 | 16 |
|
17 | | -# Generates docs/antora.yml from docs/antora.template.yml, deriving the Antora |
18 | | -# component version from version/version.go. This keeps the Antora version in |
19 | | -# lock-step with the operator version without requiring Gradle (unlike Solr). |
| 17 | +# Generates an Antora component descriptor (antora.yml) for the operator docs |
| 18 | +# from docs/antora.template.yml, deriving the version from version/version.go. |
20 | 19 | # |
21 | | -# v0.10.0 (suffix "") -> version '0_10', display_version '0.10' |
22 | | -# v0.10.0 (suffix "prerelease") -> version '0_10', display_version '0.10-prerelease', prerelease: -prerelease |
| 20 | +# By default it writes the COMMITTED docs/antora.yml -- the descriptor the |
| 21 | +# published Reference Guide uses for this branch. The release wizard regenerates |
| 22 | +# it (via `make generate-antora-yaml`) at the steps where the published version |
| 23 | +# changes; it is deliberately NOT regenerated on the post-release patch bump, so |
| 24 | +# a release branch stays pinned to its last released version. Local preview |
| 25 | +# builds (`make docs`) pass -o to write a throwaway descriptor into the |
| 26 | +# build/staging directory, so the committed file is never modified during a |
| 27 | +# normal build. |
| 28 | +# |
| 29 | +# Usage: generate_antora_yaml.sh [-o OUTPUT] |
| 30 | +# -o OUTPUT output file (default: docs/antora.yml) |
| 31 | +# |
| 32 | +# version.go v0.9.1 -> version '0_9', display_version 'v0.9' |
| 33 | +# version.go v0.10.0 (prerelease) -> version '0_10', display_version 'v0.10-prerelease', prerelease: -prerelease |
23 | 34 |
|
24 | 35 | set -eu |
25 | 36 | set -o pipefail |
26 | 37 |
|
27 | | -# Resolve the project root (this script lives in hack/docs/). |
28 | 38 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
29 | 39 | PROJECT_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)" |
30 | | - |
31 | | -VERSION_GO="${PROJECT_DIR}/version/version.go" |
32 | 40 | TEMPLATE="${PROJECT_DIR}/docs/antora.template.yml" |
33 | 41 | OUTPUT="${PROJECT_DIR}/docs/antora.yml" |
34 | 42 |
|
35 | | -# Parse Version (e.g. v0.10.0) and VersionSuffix (e.g. prerelease) from version.go. |
| 43 | +while getopts ":o:" opt; do |
| 44 | + case "${opt}" in |
| 45 | + o) OUTPUT="${OPTARG}" ;; |
| 46 | + *) echo "Usage: $0 [-o OUTPUT]" >&2; exit 2 ;; |
| 47 | + esac |
| 48 | +done |
| 49 | + |
| 50 | +VERSION_GO="${PROJECT_DIR}/version/version.go" |
36 | 51 | RAW_VERSION="$(grep -E 'Version([[:space:]]+)=' "${VERSION_GO}" | head -1 | sed -E 's/.*["'"'"']([^"'"'"']*)["'"'"'].*/\1/')" |
37 | 52 | SUFFIX="$(grep -E 'VersionSuffix([[:space:]]+)=' "${VERSION_GO}" | sed -E 's/.*["'"'"']([^"'"'"']*)["'"'"'].*/\1/')" |
38 | 53 |
|
39 | | -# Strip leading 'v' and split into semver parts. |
40 | 54 | SEMVER="${RAW_VERSION#v}" |
41 | 55 | IFS='.' read -r MAJOR MINOR PATCH <<< "${SEMVER}" |
42 | 56 |
|
|
51 | 65 | PRERELEASE_LINE="" |
52 | 66 | fi |
53 | 67 |
|
| 68 | +mkdir -p "$(dirname "${OUTPUT}")" |
54 | 69 | # Substitute tokens. Use '|' as the sed delimiter; values contain no '|'. |
55 | 70 | sed \ |
56 | 71 | -e "s|@ANTORA_VERSION@|${ANTORA_VERSION}|g" \ |
|
0 commit comments