diff --git a/release/tag_repos.sh b/release/tag_repos.sh index 1bd7114f60..3f9e0c3416 100755 --- a/release/tag_repos.sh +++ b/release/tag_repos.sh @@ -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,8 +40,9 @@ status : Get Current ${PROJECT} tags status tag : Create tags for ${PROJECT} Options: --h : Show this help --p : push tags +-b : branch were will check the version. +-h : Show this help +-p : push tags EOT @@ -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 diff --git a/release/update-repository-version.sh b/release/update-repository-version.sh index 056a0be2f6..599f7983fd 100755 --- a/release/update-repository-version.sh +++ b/release/update-repository-version.sh @@ -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 } @@ -114,7 +117,8 @@ Usage: ${script_name} [options] Args: : Name of repository to fork and send PR from github.com/${organization} - : New version to bump the repository + : New version to bump the repository + : 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 diff --git a/release/update-repository-version_test.sh b/release/update-repository-version_test.sh index 594916dc47..199e942968 100755 --- a/release/update-repository-version_test.sh +++ b/release/update-repository-version_test.sh @@ -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