Merge pull request #141 from jcvenegas/release-multi-branch

release: support release branches.
This commit is contained in:
Julio Montes 2018-08-22 08:07:13 -05:00 committed by GitHub
commit 6a18753dfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 17 deletions

View File

@ -15,10 +15,10 @@ script_name="$(basename "${BASH_SOURCE[0]}")"
OWNER=${OWNER:-"kata-containers"}
PROJECT="Kata Containers"
PUSH="${PUSH:-"false"}"
commit="master"
branch="master"
readonly URL_RAW_FILE="https://raw.githubusercontent.com/${OWNER}"
#The runtime version is used as reference of latest release
readonly kata_version=$(curl -Ls "${URL_RAW_FILE}/runtime/${commit}/VERSION" | grep -v -P "^#")
readonly kata_version=$(curl -Ls "${URL_RAW_FILE}/runtime/${branch}/VERSION" | grep -v -P "^#")
source "${script_dir}/../scripts/lib.sh"
@ -40,6 +40,7 @@ status : Get Current ${PROJECT} tags status
tag : Create tags for ${PROJECT}
Options:
-b <branch>: branch were will check the version.
-h : Show this help
-p : push tags
@ -77,7 +78,7 @@ check_versions() {
info "Check all repos has version ${kata_version} in VERSION file"
for repo in "${repos[@]}"; do
repo_version=$(curl -Ls "${URL_RAW_FILE}/${repo}/${commit}/VERSION" | grep -v -P "^#")
repo_version=$(curl -Ls "${URL_RAW_FILE}/${repo}/${branch}/VERSION" | grep -v -P "^#")
info "${repo} is in $repo_version"
[ "${repo_version}" == "${kata_version}" ] || die "${repo} is not in version ${kata_version}"
done
@ -130,8 +131,9 @@ create_github_release() {
fi
}
while getopts "hp" opt; do
while getopts "b:hp" opt; do
case $opt in
b) branch="${OPTARG}" ;;
h) usage && exit 0 ;;
p) PUSH="true" ;;
esac

View File

@ -59,11 +59,13 @@ generate_commit() {
}
bump_repo() {
repo=$1
new_version=$2
local repo="${1:-}"
local new_version="${2:-}"
local target_branch="${3:-}"
[ -n "${repo}" ] || die "repository not provided"
[ -n "$new_version" ] || die "no new version"
remote_github="https://github.com/${organization}/${repo}.git"
[ -n "${new_version}" ] || die "no new version"
[ -n "${target_branch}" ] || die "no target branch"
local remote_github="https://github.com/${organization}/${repo}.git"
info "Update $repo to version $new_version"
info "remote: ${remote_github}"
@ -88,7 +90,8 @@ EOT
info "Updating VERSION file"
echo "${new_version}" >VERSION
branch="${new_version}-branch-bump"
git checkout -b "${branch}" master
git fetch origin "${target_branch}"
git checkout "origin/${target_branch}" -b "${branch}"
git add -u
info "Creating commit with new changes"
commit_msg="$(generate_commit $new_version $current_version)"
@ -102,7 +105,7 @@ EOT
${hub_bin} push fork -f "${branch}"
info "Create PR"
out=""
out=$("${hub_bin}" pull-request -F "${notes_file}" 2>&1) || echo "$out" | grep "A pull request already exists"
out=$("${hub_bin}" pull-request -b "${target_branch}" -F "${notes_file}" 2>&1) || echo "$out" | grep "A pull request already exists"
fi
popd >>/dev/null
}
@ -115,6 +118,7 @@ Usage:
Args:
<repository-name> : Name of repository to fork and send PR from github.com/${organization}
<new-version> : New version to bump the repository
<target-branch> : The base branch to create to PR
Example:
${script_name} 1.10
Options
@ -135,9 +139,11 @@ shift $((OPTIND - 1))
repo=${1:-}
new_version=${2:-}
target_branch=${3:-}
[ -n "${repo}" ] || (echo "ERROR: repository not provided" && usage 1)
[ -n "$new_version" ] || (echo "ERROR: no new version" && usage 1)
[ -n "${new_version}" ] || (echo "ERROR: no new version" && usage 1)
[ -n "${target_branch}" ] || die "no target branch"
pushd "$tmp_dir" >>/dev/null
bump_repo "${repo}" "${new_version}"
bump_repo "${repo}" "${new_version}" "${target_branch}"
popd >>/dev/null

View File

@ -37,7 +37,7 @@ output_should_contain "${out}" "Usage"
OK
echo "Missing version show help"
out=$("${script_dir}/update-repository-version.sh" runtime 2>&1) || (($? != 0))
out=$("${script_dir}/update-repository-version.sh" "runtime" 2>&1) || (($? != 0))
echo "${out}" | grep Usage >>/dev/null
echo "${out}" | grep "no new version" >>/dev/null
OK
@ -49,6 +49,6 @@ OK
echo "Local update version update should work"
new_version=50.0.0
out=$("${script_dir}/update-repository-version.sh" runtime ${new_version} 2>&1)
out=$("${script_dir}/update-repository-version.sh" "runtime" "${new_version}" "master" 2>&1)
output_should_contain "${out}" "release: Kata Containers ${new_version}"
OK