8484 echo # Newline for better readability
8585
8686 if [[ -n "$DETECTED_VERSION" ]]; then
87- NEW_START_PAGE="${START_PAGE_COMPONENT_NAME}::v${DETECTED_VERSION}/${START_PAGE_FILE_PATH}"
87+ # v5.1+ uses flat structure (no version prefix in path)
88+ # v5.0 and earlier use nested structure (version prefix in path)
89+ # Use version comparison: if DETECTED_VERSION >= 5.1, use flat structure
90+ if [[ "$(printf '%s\n' "5.1" "$DETECTED_VERSION" | sort -V | head -n1)" == "5.1" ]]; then
91+ # For v5.1+: ivorysql-doc:v5.1:welcome.adoc (no version prefix in path)
92+ NEW_START_PAGE="${START_PAGE_COMPONENT_NAME}:v${DETECTED_VERSION}:${START_PAGE_FILE_PATH}"
93+ else
94+ # For v5.0 and earlier: ivorysql-doc:v5.0:v5.0/welcome.adoc (with version prefix)
95+ NEW_START_PAGE="${START_PAGE_COMPONENT_NAME}:v${DETECTED_VERSION}:v${DETECTED_VERSION}/${START_PAGE_FILE_PATH}"
96+ fi
8897 yq -i ".site.start_page = \"$NEW_START_PAGE\"" "$PLAYBOOK_FILE"
8998 echo "Updated .site.start_page in $PLAYBOOK_FILE to: $NEW_START_PAGE"
9099 else
@@ -133,7 +142,17 @@ jobs:
133142 set -euo pipefail
134143
135144 TARGET_BRANCH="v${LATEST_VERSION}"
136- EXPECTED_PATH="ivorysql-doc/v${LATEST_VERSION}/v${LATEST_VERSION}/welcome.html"
145+
146+ # v5.1+ uses flat structure (single-level path)
147+ # v5.0 and earlier use nested structure (double-level path)
148+ # Use version comparison: if LATEST_VERSION >= 5.1, use flat structure
149+ if [[ "$(printf '%s\n' "5.1" "$LATEST_VERSION" | sort -V | head -n1)" == "5.1" ]]; then
150+ # For v5.1+: ivorysql-doc/v5.1/welcome.html (single-level)
151+ EXPECTED_PATH="ivorysql-doc/v${LATEST_VERSION}/welcome.html"
152+ else
153+ # For v5.0 and earlier: ivorysql-doc/v5.0/v5.0/welcome.html (double-level)
154+ EXPECTED_PATH="ivorysql-doc/v${LATEST_VERSION}/v${LATEST_VERSION}/welcome.html"
155+ fi
137156
138157 if [[ "${MERGED_PR_BASE}" != "${TARGET_BRANCH}" ]]; then
139158 echo "Base branch ${MERGED_PR_BASE} is not the latest version branch ${TARGET_BRANCH}, skip index redirect check."
@@ -152,8 +171,9 @@ jobs:
152171 if grep -q "${EXPECTED_PATH}" "${FILE_PATH}"; then
153172 echo "${FILE_PATH} already points to latest ${LATEST_VERSION}."
154173 else
155- # Replace all version segments like vX.Y or vX.Y.Z in href/location/meta/script targets
156- sed -i -E "s@ivorysql-doc/v[0-9]+(\\.[0-9]+){1,2}/v[0-9]+(\\.[0-9]+){1,2}/welcome\\.html@${EXPECTED_PATH}@g" "${FILE_PATH}"
174+ # Replace path to latest version
175+ # Handle both old double-level and new single-level path formats
176+ sed -i -E "s@ivorysql-doc/v[0-9]+(\\.[0-9]+){1,2}/(v[0-9]+(\\.[0-9]+){1,2}/)?welcome\\.html@${EXPECTED_PATH}@g" "${FILE_PATH}"
157177 UPDATE_NEEDED=true
158178 echo "Updated ${FILE_PATH} to latest ${LATEST_VERSION} redirect."
159179 fi
0 commit comments