mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-07 13:55:20 +00:00
Spruce up release instructions and release scripts (#2931)
* Update tag-release script Signed-off-by: Carlisia <carlisia@vmware.com> * Reorg release instructions Signed-off-by: Carlisia <carlisia@vmware.com> * Move "troubleshooting" to proper section Signed-off-by: Carlisia <carlisia@vmware.com> * Better formatting Signed-off-by: Carlisia <carlisia@vmware.com> * Fix sorcery Signed-off-by: Carlisia <carlisia@vmware.com> * Address code review Signed-off-by: Carlisia <carlisia@vmware.com> * More code reviews Signed-off-by: Carlisia <carlisia@vmware.com>
This commit is contained in:
committed by
GitHub
parent
afa552ca67
commit
6e20eaaba8
22
hack/release-tools/brew-update.sh
Executable file
22
hack/release-tools/brew-update.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script assumes that 2 environment variables are defined outside of it:
|
||||
# VELERO_VERSION - a full version version string, starting with v. example: v1.4.2
|
||||
# HOMEBREW_GITHUB_API_TOKEN - the GitHub API token that the brew command will use to create a PR on the user's behalf.
|
||||
|
||||
|
||||
# Check if brew is found on the user's $PATH; exit if not.
|
||||
if [ -z $(which brew) ];
|
||||
then
|
||||
echo "Homebrew must first be installed to use this script!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# GitHub URL which contains the source code archive for the tagged release
|
||||
URL=https://github.com/vmware-tanzu/velero/archive/$VELERO_VERSION.tar.gz
|
||||
|
||||
# Update brew so we're sure we have the latest Velero formula
|
||||
brew update
|
||||
|
||||
# Invoke brew's helper function, which will run all their tests and end up opening a browser with the resulting PR.
|
||||
brew bump-formula-pr velero --url=$URL
|
||||
35
hack/release-tools/changelog.sh
Executable file
35
hack/release-tools/changelog.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2018 the Velero contributors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
function join { local IFS="$1"; shift; echo "$*"; }
|
||||
|
||||
CHANGELOG_PATH='changelogs/unreleased'
|
||||
UNRELEASED=$(ls -t ${CHANGELOG_PATH})
|
||||
echo -e "Generating CHANGELOG markdown from ${CHANGELOG_PATH}\n"
|
||||
for entry in $UNRELEASED
|
||||
do
|
||||
IFS=$'-' read -ra pruser <<<"$entry"
|
||||
contents=$(cat ${CHANGELOG_PATH}/${entry})
|
||||
pr=${pruser[0]}
|
||||
user=$(join '-' ${pruser[@]:1})
|
||||
echo " * ${contents} (#${pr}, @${user})"
|
||||
done
|
||||
echo -e "\nCopy and paste the list above in to the appropriate CHANGELOG file."
|
||||
echo "Be sure to run: git rm ${CHANGELOG_PATH}/*"
|
||||
@@ -22,13 +22,13 @@ import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// This regex should match both our GA format (example: v1.4.3) and pre-release format (v1.2.4-beta.2)
|
||||
// This regex should match both our GA format (example: v1.4.3) and pre-release formats (v1.2.4-beta.2, v1.5.0-rc.1)
|
||||
// The following sub-capture groups are defined:
|
||||
// major
|
||||
// minor
|
||||
// patch
|
||||
// prerelease (this will be alpha/beta followed by a ".", followed by 1 or more digits (alpha.5)
|
||||
var release_regex *regexp.Regexp = regexp.MustCompile("^v(?P<major>[[:digit:]]+)\\.(?P<minor>[[:digit:]]+)\\.(?P<patch>[[:digit:]]+)(-{1}(?P<prerelease>(alpha|beta)\\.[[:digit:]]+))*")
|
||||
// prerelease (this will be alpha/beta/rc followed by a ".", followed by 1 or more digits (alpha.5)
|
||||
var release_regex *regexp.Regexp = regexp.MustCompile("^v(?P<major>[[:digit:]]+)\\.(?P<minor>[[:digit:]]+)\\.(?P<patch>[[:digit:]]+)(-{1}(?P<prerelease>(alpha|beta|rc)\\.[[:digit:]]+))*")
|
||||
|
||||
// This small program exists because checking the VELERO_VERSION rules in bash is difficult, and difficult to test for correctness.
|
||||
// Calling it with --verify will verify whether or not the VELERO_VERSION environment variable is a valid version string, without parsing for its components.
|
||||
|
||||
142
hack/release-tools/gen-docs.sh
Executable file
142
hack/release-tools/gen-docs.sh
Executable file
@@ -0,0 +1,142 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2020 the Velero contributors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# gen-docs.sh is used for the "make gen-docs" target. It generates a new
|
||||
# versioned docs directory under site/content/docs. It follows
|
||||
# the following process:
|
||||
# 1. Copies the contents of the most recently tagged docs directory into the new
|
||||
# directory, to establish a useful baseline to diff against.
|
||||
# 2. Adds all copied content from step 1 to git's staging area via 'git add'.
|
||||
# 3. Replaces the contents of the new docs directory with the contents of the
|
||||
# 'main' docs directory, updating any version-specific links (e.g. to a
|
||||
# specific branch of the GitHub repository) to use the new version
|
||||
# 4. Copies the previous version's ToC file and runs 'git add' to establish
|
||||
# a useful baseline to diff against.
|
||||
# 5. Replaces the content of the new ToC file with the main ToC.
|
||||
# 6. Update site/config.yaml and site/_data/toc-mapping.yml to include entries
|
||||
# for the new version.
|
||||
#
|
||||
# The unstaged changes in the working directory can now easily be diff'ed against the
|
||||
# staged changes using 'git diff' to review all docs changes made since the previous
|
||||
# tagged version. Once the unstaged changes are ready, they can be added to the
|
||||
# staging area using 'git add' and then committed.
|
||||
#
|
||||
# NEW_DOCS_VERSION defines the version that the docs will be tagged with
|
||||
# (i.e. what’s in the URL, what shows up in the version dropdown on the site).
|
||||
# This should be formatted as either v1.4 (for any GA release, including minor), or v1.5.0-beta.1/v1.5.0-rc.1 (for an alpha/beta/RC).
|
||||
|
||||
# To run gen-docs: "VELERO_VERSION=v1.4.0 NEW_DOCS_VERSION=v1.4 PREVIOUS_DOCS_VERSION= make gen-docs"
|
||||
# Note: if PREVIOUS_DOCS_VERSION is not set, the script will copy from the
|
||||
# latest version.
|
||||
#
|
||||
# **NOTE**: there are additional manual steps required to finalize the process of generating
|
||||
# a new versioned docs site. The full process is documented in site/README-HUGO.md
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
DOCS_DIRECTORY=site/content/docs
|
||||
DATA_DOCS_DIRECTORY=site/data/docs
|
||||
CONFIG_FILE=site/config.yaml
|
||||
MAIN_BRANCH=main
|
||||
|
||||
# don't run if there's already a directory for the target docs version
|
||||
if [[ -d $DOCS_DIRECTORY/$NEW_DOCS_VERSION ]]; then
|
||||
echo "ERROR: $DOCS_DIRECTORY/$NEW_DOCS_VERSION already exists"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# get the alphabetically last item in $DOCS_DIRECTORY to use as PREVIOUS_DOCS_VERSION
|
||||
# if not explicitly specified by the user
|
||||
if [[ -z "${PREVIOUS_DOCS_VERSION:-}" ]]; then
|
||||
echo "PREVIOUS_DOCS_VERSION was not specified, getting the latest version"
|
||||
PREVIOUS_DOCS_VERSION=$(ls -1 $DOCS_DIRECTORY/ | tail -n 1)
|
||||
fi
|
||||
|
||||
# make a copy of the previous versioned docs dir
|
||||
echo "Creating copy of docs directory $DOCS_DIRECTORY/$PREVIOUS_DOCS_VERSION in $DOCS_DIRECTORY/$NEW_DOCS_VERSION"
|
||||
cp -r $DOCS_DIRECTORY/${PREVIOUS_DOCS_VERSION}/ $DOCS_DIRECTORY/${NEW_DOCS_VERSION}/
|
||||
|
||||
# 'git add' the previous version's docs as-is so we get a useful diff when we copy the $MAIN_BRANCH docs in
|
||||
echo "Running 'git add' for previous version's doc contents to use as a base for diff"
|
||||
git add -f $DOCS_DIRECTORY/${NEW_DOCS_VERSION}
|
||||
|
||||
# now copy the contents of $DOCS_DIRECTORY/$MAIN_BRANCH into the same directory so we can get a nice
|
||||
# git diff of what changed since previous version
|
||||
echo "Copying $DOCS_DIRECTORY/$MAIN_BRANCH/ to $DOCS_DIRECTORY/${NEW_DOCS_VERSION}/"
|
||||
rm -rf $DOCS_DIRECTORY/${NEW_DOCS_VERSION}/ && cp -r $DOCS_DIRECTORY/$MAIN_BRANCH/ $DOCS_DIRECTORY/${NEW_DOCS_VERSION}/
|
||||
|
||||
# make a copy of the previous versioned ToC
|
||||
NEW_DOCS_TOC="$(echo ${NEW_DOCS_VERSION} | tr . -)-toc"
|
||||
PREVIOUS_DOCS_TOC="$(echo ${PREVIOUS_DOCS_VERSION} | tr . -)-toc"
|
||||
|
||||
echo "Creating copy of $DATA_DOCS_DIRECTORY/$PREVIOUS_DOCS_TOC.yml at $DATA_DOCS_DIRECTORY/$NEW_DOCS_TOC.yml"
|
||||
cp $DATA_DOCS_DIRECTORY/$PREVIOUS_DOCS_TOC.yml $DATA_DOCS_DIRECTORY/$NEW_DOCS_TOC.yml
|
||||
|
||||
# 'git add' the previous version's ToC content as-is so we get a useful diff when we copy the $MAIN_BRANCH ToC in
|
||||
echo "Running 'git add' for previous version's ToC to use as a base for diff"
|
||||
git add $DATA_DOCS_DIRECTORY/$NEW_DOCS_TOC.yml
|
||||
|
||||
# now copy the $MAIN_BRANCH ToC so we can get a nice git diff of what changed since previous version
|
||||
echo "Copying $DATA_DOCS_DIRECTORY/$MAIN_BRANCH-toc.yml to $DATA_DOCS_DIRECTORY/$NEW_DOCS_TOC.yml"
|
||||
rm $DATA_DOCS_DIRECTORY/$NEW_DOCS_TOC.yml && cp $DATA_DOCS_DIRECTORY/$MAIN_BRANCH-toc.yml $DATA_DOCS_DIRECTORY/$NEW_DOCS_TOC.yml
|
||||
|
||||
# replace known version-specific links -- the sed syntax is slightly different in OS X and Linux,
|
||||
# so check which OS we're running on.
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
echo "[OS X] updating version-specific links"
|
||||
find $DOCS_DIRECTORY/${NEW_DOCS_VERSION} -type f -name "*.md" | xargs sed -i '' "s|https://velero.io/docs/$MAIN_BRANCH|https://velero.io/docs/$VELERO_VERSION|g"
|
||||
find $DOCS_DIRECTORY/${NEW_DOCS_VERSION} -type f -name "*.md" | xargs sed -i '' "s|https://github.com/vmware-tanzu/velero/blob/$MAIN_BRANCH|https://github.com/vmware-tanzu/velero/blob/$VELERO_VERSION|g"
|
||||
find $DOCS_DIRECTORY/${NEW_DOCS_VERSION} -type f -name "_index.md" | xargs sed -i '' "s|version: $MAIN_BRANCH|version: $NEW_DOCS_VERSION|g"
|
||||
|
||||
echo "[OS X] Updating latest version in $CONFIG_FILE"
|
||||
sed -i '' "s/latest: ${PREVIOUS_DOCS_VERSION}/latest: ${NEW_DOCS_VERSION}/" $CONFIG_FILE
|
||||
|
||||
# newlines and lack of indentation are requirements for this sed syntax
|
||||
# which is doing an append
|
||||
echo "[OS X] Adding latest version to versions list in $CONFIG_FILE"
|
||||
sed -i '' "/- $MAIN_BRANCH/a\\
|
||||
\ \ \ \ - ${NEW_DOCS_VERSION}
|
||||
" $CONFIG_FILE
|
||||
|
||||
echo "[OS X] Adding ToC mapping entry"
|
||||
sed -i '' "/$MAIN_BRANCH: $MAIN_BRANCH-toc/a\\
|
||||
${NEW_DOCS_VERSION}: ${NEW_DOCS_TOC}
|
||||
" $DATA_DOCS_DIRECTORY/toc-mapping.yml
|
||||
|
||||
else
|
||||
echo "[Linux] updating version-specific links"
|
||||
find $DOCS_DIRECTORY/${NEW_DOCS_VERSION} -type f -name "*.md" | xargs sed -i'' "s|https://velero.io/docs/$MAIN_BRANCH|https://velero.io/docs/$VELERO_VERSION|g"
|
||||
find $DOCS_DIRECTORY/${NEW_DOCS_VERSION} -type f -name "*.md" | xargs sed -i'' "s|https://github.com/vmware-tanzu/velero/blob/$MAIN_BRANCH|https://github.com/vmware-tanzu/velero/blob/$VELERO_VERSION|g"
|
||||
|
||||
echo "[Linux] Updating latest version in $CONFIG_FILE"
|
||||
sed -i'' "s/latest: ${PREVIOUS_DOCS_VERSION}/latest: ${NEW_DOCS_VERSION}/" $CONFIG_FILE
|
||||
|
||||
echo "[Linux] Adding latest version to versions list in $CONFIG_FILE"
|
||||
sed -i'' "/- $MAIN_BRANCH/a - ${NEW_DOCS_VERSION}" $CONFIG_FILE
|
||||
|
||||
echo "[Linux] Adding ToC mapping entry"
|
||||
sed -i'' "/$MAIN_BRANCH: $MAIN_BRANCH-toc/a ${NEW_DOCS_VERSION}: ${NEW_DOCS_TOC}" $DATA_DOCS_DIRECTORY/toc-mapping.yml
|
||||
fi
|
||||
|
||||
echo "Success! $DOCS_DIRECTORY/$NEW_DOCS_VERSION has been created."
|
||||
echo ""
|
||||
echo "The next steps are:"
|
||||
echo " 1. Consult site/README-HUGO.md for further manual steps required to finalize the new versioned docs generation."
|
||||
echo " 2. Run a 'git diff' to review all changes made to the docs since the previous version."
|
||||
echo " 3. Make any manual changes/corrections necessary."
|
||||
echo " 4. Run 'git add' to stage all unstaged changes, then 'git commit'."
|
||||
52
hack/release-tools/goreleaser.sh
Executable file
52
hack/release-tools/goreleaser.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2018 the Velero contributors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
if [[ -z "${GITHUB_TOKEN}" ]]; then
|
||||
echo "GITHUB_TOKEN must be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# TODO derive this from the major+minor version
|
||||
if [ -z "${RELEASE_NOTES_FILE}" ]; then
|
||||
echo "RELEASE_NOTES_FILE must be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GIT_DIRTY=$(git status --porcelain 2> /dev/null)
|
||||
if [[ -z "${GIT_DIRTY}" ]]; then
|
||||
export GIT_TREE_STATE=clean
|
||||
else
|
||||
export GIT_TREE_STATE=dirty
|
||||
fi
|
||||
|
||||
# $PUBLISH must explicitly be set to 'TRUE' for goreleaser
|
||||
# to publish the release to GitHub.
|
||||
if [[ "${PUBLISH:-}" != "TRUE" ]]; then
|
||||
echo "Not set to publish"
|
||||
goreleaser release \
|
||||
--rm-dist \
|
||||
--release-notes="${RELEASE_NOTES_FILE}" \
|
||||
--skip-publish
|
||||
else
|
||||
echo "Getting ready to publish"
|
||||
goreleaser release \
|
||||
--rm-dist \
|
||||
--release-notes="${RELEASE_NOTES_FILE}"
|
||||
fi
|
||||
@@ -15,9 +15,24 @@
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
# This script will do the necessary checks and actions to create a release of Velero.
|
||||
# It will first validate that all prerequisites are met, then verify the version string is what the user expects.
|
||||
# A git tag will be created and pushed to GitHub, and GoReleaser will be invoked.
|
||||
# This script will do the necessary checks and actions to create a release of Velero. It will:
|
||||
# - validate that all prerequisites are met
|
||||
# - verify the version string is what the user expects.
|
||||
# - create a git tag
|
||||
# - push the created git tag to GitHub
|
||||
# - run GoReleaser
|
||||
|
||||
# The following variables are needed:
|
||||
|
||||
# - $VELERO_VERSION: defines the tag of Velero that any https://github.com/vmware-tanzu/velero/...
|
||||
# links in the docs should redirect to.
|
||||
# - $publish: TRUE/FALSE value where FALSE (or not including it) will indicate a dry-run, and TRUE, or simply adding 'publish',
|
||||
# will tag the release with the $VELERO_VERSION and push the tag to a remote named 'upstream'.
|
||||
# - $GITHUB_TOKEN: Needed to run the goreleaser process to generate a GitHub release.
|
||||
# Use https://github.com/settings/tokens/new?scopes=repo if you don't already have a token.
|
||||
# Regenerate an existing token: https://github.com/settings/tokens.
|
||||
# You may regenerate the token for every release if you prefer.
|
||||
# See https://goreleaser.com/environment/ for more details.
|
||||
|
||||
# This script is meant to be a combination of documentation and executable.
|
||||
# If you have questions at any point, please stop and ask!
|
||||
@@ -26,7 +41,7 @@
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
# Parse out the branch we're on so we can switch back to it at the end of a dry-run, where we delete the tag. Requires git v1.8.1+
|
||||
original_branch=$(git symbolic-ref --short HEAD)
|
||||
upstream_branch=$(git symbolic-ref --short HEAD)
|
||||
|
||||
function tag_and_push() {
|
||||
echo "Tagging $VELERO_VERSION"
|
||||
@@ -76,6 +91,7 @@ printf "Based on this, the following assumptions have been made: \n"
|
||||
|
||||
[[ "$VELERO_PATCH" != 0 ]] && printf "*\t This is a patch release.\n"
|
||||
|
||||
# $VELERO_PRERELEASE gets populated by the chk_version.go script that parses and verifies the given version format
|
||||
# -n is "string is non-empty"
|
||||
[[ -n $VELERO_PRERELEASE ]] && printf "*\t This is a pre-release.\n"
|
||||
|
||||
@@ -97,6 +113,7 @@ echo "Alright, let's go."
|
||||
echo "Pulling down all git tags and branches before doing any work."
|
||||
git fetch upstream --tags
|
||||
|
||||
# $VELERO_PATCH gets populated by the chk_version.go scrip that parses and verifies the given version format
|
||||
# If we've got a patch release, we'll need to create a release branch for it.
|
||||
if [[ "$VELERO_PATCH" > 0 ]]; then
|
||||
release_branch_name=release-$VELERO_MAJOR.$VELERO_MINOR
|
||||
@@ -114,7 +131,7 @@ if [[ "$VELERO_PATCH" > 0 ]]; then
|
||||
echo "Now you'll need to cherry-pick any relevant git commits into this release branch."
|
||||
echo "Either pause this script with ctrl-z, or open a new terminal window and do the cherry-picking."
|
||||
if [[ $publish == "TRUE" ]]; then
|
||||
read -p "Press enter when you're done cherry-picking. THIS WILL MAKE A TAG PUSH THE BRANCH TO UPSTREAM"
|
||||
read -p "Press enter when you're done cherry-picking. THIS WILL MAKE A TAG PUSH THE BRANCH TO upstream"
|
||||
else
|
||||
read -p "Press enter when you're done cherry-picking."
|
||||
fi
|
||||
@@ -144,7 +161,7 @@ if [[ $publish == "FALSE" ]]; then
|
||||
# Delete the local tag so we don't potentially conflict when it's re-run for real.
|
||||
# This also means we won't have to just ignore existing tags in tag_and_push, which could be a problem if there's an existing tag.
|
||||
echo "Dry run complete. Deleting git tag $VELERO_VERSION"
|
||||
git checkout $original_branch
|
||||
git checkout $upstream_branch
|
||||
git tag -d $VELERO_VERSION
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user