Skip to content

Commit

Permalink
Add doc files to git when release-docs.sh run
Browse files Browse the repository at this point in the history
Signed-off-by: Joao Pereira <[email protected]>
  • Loading branch information
joaopapereira committed Jan 27, 2022
1 parent a725935 commit 6f6cfa6
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions site/hack/release-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,38 @@ if [ "${FROM_VERSION}" == "develop" ]; then # When creating a new release from d
echo "Update version on ${NEW_VERSION} docs"
sed -i.bak "s/version: develop/version: ${NEW_VERSION}/" "${CONTENT_DIRECTORY}"/${NEW_VERSION}/_index.md
rm "${CONTENT_DIRECTORY}"/${NEW_VERSION}/_index.md.bak

dashedVersion=${NEW_VERSION//\./-}
echo "Copy table of content"
cp "${TOC_DIRECTORY}"/"${TOOL}"-develop-toc.yml "${TOC_DIRECTORY}"/"${TOOL}"-"${dashedVersion}"-toc.yml
git add "${TOC_DIRECTORY}"/"${TOOL}"-"${dashedVersion}"-toc.yml
elif [ "${FROM_VERSION}" == "${LATEST_VERSION}" ]; then # When creating a patch from the latest release
echo "Copying the content of the latest documentation to named version ${LATEST_VERSION}"
cp -rf "${CONTENT_DIRECTORY}"/${LATEST_VERSION} "${CONTENT_DIRECTORY}"/"${NEW_VERSION}"

echo "Update version on ${NEW_VERSION} docs"
sed -i.bak "s/version: ${LATEST_VERSION}/version: ${NEW_VERSION}/" "${CONTENT_DIRECTORY}"/${NEW_VERSION}/_index.md
rm "${CONTENT_DIRECTORY}"/${NEW_VERSION}/_index.md.bak

dashedVersion=${NEW_VERSION//\./-}
latestVersionDashedVersion=${LATEST_VERSION//\./-}
echo "Copy table of content"
cp "${TOC_DIRECTORY}/${TOOL}-${latestVersionDashedVersion}-toc.yml" "${TOC_DIRECTORY}/${TOOL}-${dashedVersion}-toc.yml"
git add "${TOC_DIRECTORY}"/"${TOOL}"-"${dashedVersion}"-toc.yml
else # When creating a patch for any other release
echo "Copying the content of the ${FROM_VERSION} documentation to named version ${NEW_VERSION}"
cp -rf "${CONTENT_DIRECTORY}/${FROM_VERSION}/" "${CONTENT_DIRECTORY}"/"${NEW_VERSION}"
sed -i.bak "s/version: ${FROM_VERSION}/version: ${NEW_VERSION}/" "${CONTENT_DIRECTORY}"/${NEW_VERSION}/_index.md
rm "${CONTENT_DIRECTORY}"/${NEW_VERSION}/_index.md.bak

dashedVersion=${NEW_VERSION//\./-}
fromDashedVersion=${FROM_VERSION//\./-}
echo "Copy table of content"
cp "${TOC_DIRECTORY}/${TOOL}-${fromDashedVersion}-toc.yml" "${TOC_DIRECTORY}/${TOOL}-${dashedVersion}-toc.yml"
git add "${TOC_DIRECTORY}"/"${TOOL}"-"${dashedVersion}"-toc.yml
fi

dashedVersion=${NEW_VERSION//\./-}
echo "Copy table of content"
cp "${TOC_DIRECTORY}"/"${TOOL}"-develop-toc.yml "${TOC_DIRECTORY}"/"${TOOL}"-"${dashedVersion}"-toc.yml
git add "${CONTENT_DIRECTORY}"/${NEW_VERSION}

currentTOC="${TOC_DIRECTORY}"/toc-mapping.yml

Expand All @@ -71,6 +86,7 @@ ytt --ignore-unknown-comments -f"$currentTOC" -ftocOverlay.yml=<(cat <<EOF
${NEW_VERSION}: ${TOOL}-${dashedVersion}-toc
EOF) > /tmp/newToc.yml
mv /tmp/newToc.yml $currentTOC
git add $currentTOC
echo "Updating the configuration file"
if [ "${FROM_VERSION}" == "develop" ] || [ "${FROM_VERSION}" == "${LATEST_VERSION}" ]; then
Expand All @@ -90,6 +106,7 @@ params:
- ${NEW_VERSION}
EOF) > /tmp/newConfig.yml
mv /tmp/newConfig.yml config.yaml
git add config.yaml
echo "Add redirection from latest to version ${NEW_VERSION}"
for file in $(find content/${TOOL}/docs/${NEW_VERSION} -name "*.md");
Expand All @@ -101,13 +118,15 @@ EOF) > /tmp/newConfig.yml
cat "$file" | awk 'BEGIN {t=0}; { print }; /---/ { t++; if ( t==1) { printf "aliases: [/%s/docs/latest/%s]\n", tool, filename } }' tool=${TOOL} filename="${filename%.md}" > "$file.bak"
mv "$file".bak "$file"
git add $file
done
echo "Remove redirection from ${LATEST_VERSION} to latest"
for file in $(find content/${TOOL}/docs/${LATEST_VERSION} -name "*.md");
do
sed -i.bak "s/aliases: \[[a-z\/\-]*\]//" $file
rm "$file.bak"
git add $file
done
else
echo "For patch version version"
Expand All @@ -124,4 +143,5 @@ params:
- ${NEW_VERSION}
EOF) > /tmp/newConfig.yml
mv /tmp/newConfig.yml config.yaml
git add config.yaml
fi

0 comments on commit 6f6cfa6

Please sign in to comment.