From 6151c894cb87c3922e2b3904ffa758a4dd63a687 Mon Sep 17 00:00:00 2001 From: hanliu <741550557@qq.com> Date: Thu, 16 Nov 2023 16:56:30 +0800 Subject: [PATCH] update the select branch name policy --- build-bin/maven/maven_release | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build-bin/maven/maven_release b/build-bin/maven/maven_release index e47bd43ff68..3df408180c6 100755 --- a/build-bin/maven/maven_release +++ b/build-bin/maven/maven_release @@ -26,9 +26,17 @@ export MAVEN_OPTS="$($(dirname "$0")/maven_opts)" trigger_tag=${1?trigger_tag is required. Ex release-1.2.3} release_version=$(build-bin/git/version_from_trigger_tag release- ${trigger_tag}) -# Checkout the tag to release +# Checkout the branch that triggered this build git fetch --tags origin -git checkout ${trigger_tag} +commit_sha=$(git rev-parse "$trigger_tag") +branches=$(git branch --contains "$commit_sha") +branch_name=$(echo "$branches" | head -n 1 | awk '{print $2}') +if [ -z "$branch_name" ]; then + default_branch="master" + echo "Unable to determine a valid branch. Auto-selecting the default branch: $default_branch" + branch_name=$default_branch +fi +git checkout "$branch_name" # Prepare and push release commits and the version tag (N.N.N), which triggers deployment. ./mvnw --batch-mode -nsu -DreleaseVersion=${release_version} -Denforcer.fail=false -Darguments="-DskipTests -Denforcer.fail=false" release:prepare