Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix versionize-docs.sh and mark-new-version.sh to rewrite links to release branch rather than to tag #16553

Merged
merged 1 commit into from
Oct 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions build/mark-new-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ if ! ($SED --version 2>&1 | grep -q GNU); then
fi

echo "+++ Running ./versionize-docs"
${KUBE_ROOT}/build/versionize-docs.sh ${NEW_VERSION}
git commit -am "Versioning docs and examples for ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
# Links in docs should always point to the release branch.
${KUBE_ROOT}/build/versionize-docs.sh ${release_branch}
git commit -am "Versioning docs and examples to ${release_branch}"

VERSION_FILE="${KUBE_ROOT}/pkg/version/base.go"

Expand Down
21 changes: 11 additions & 10 deletions build/versionize-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,22 @@
# Updates the docs to be ready to be used as release docs for a particular
# version.
# Example usage:
# ./versionize-docs.sh v1.0.1
# ./versionize-docs.sh release-1.1

set -o errexit
set -o nounset
set -o pipefail

KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..

NEW_VERSION=${1-}
RELEASE_BRANCH=${1-}

# NEW_VERSION is expected to be vMajor.Minor.Micro.
MAJOR_AND_MINOR_VERSION=${NEW_VERSION%.*}
# MAJOR_AND_MINOR_VERSION is expected to be something like "v1.1"
MAJOR_AND_MINOR_VERSION="v${RELEASE_BRANCH#release-}"

if [ "$#" -lt 1 ]; then
echo "Usage: versionize-docs <release-version>"
echo "Usage: versionize-docs.sh <release-branch>, e.g., versionize-docs.sh release-1.1."
echo "The <release-branch> is used to rewrites link URL, which should always point to a release branch, NOT a tag like v1.1.1."
exit 1
fi

Expand Down Expand Up @@ -59,11 +60,11 @@ done
for doc in "${md_files[@]}"; do
$SED -ri \
-e '/<!-- BEGIN STRIP_FOR_RELEASE -->/,/<!-- END STRIP_FOR_RELEASE -->/d' \
-e "s|(releases.k8s.io)/[^/]+|\1/${NEW_VERSION}|g" \
-e "s|(releases.k8s.io)/[^/]+|\1/${RELEASE_BRANCH}|g" \
"${doc}"

# Replace /HEAD in html preview links with /NEW_VERSION.
$SED -ri -e "s|(${HTML_PREVIEW_PREFIX})/HEAD|\1/blob/${NEW_VERSION}|g" "${doc}"
# Replace /HEAD in html preview links with /RELEASE_BRANCH
$SED -ri -e "s|(${HTML_PREVIEW_PREFIX})/HEAD|\1/${RELEASE_BRANCH}|g" "${doc}"

# Replace <REPLACE-WITH-RELEASE-VERSION> with MAJOR_AND_MINOR_VERSION.
$SED -ri -e "s|${DIRECTORY_KEY_WORDS}|${MAJOR_AND_MINOR_VERSION}|g" "${doc}"
Expand Down Expand Up @@ -91,8 +92,8 @@ go_files+=(pkg/apis/*/types.go)

for file in "${go_files[@]}"; do
$SED -ri \
-e "s|(releases.k8s.io)/[^/]+|\1/${NEW_VERSION}|g" \
-e "s|(${HTML_PREVIEW_PREFIX})/HEAD|\1/blob/${NEW_VERSION}|g" \
-e "s|(releases.k8s.io)/[^/]+|\1/${RELEASE_BRANCH}|g" \
-e "s|(${HTML_PREVIEW_PREFIX})/HEAD|\1/${RELEASE_BRANCH}|g" \
"${file}"
done

Expand Down