Skip to content

Commit

Permalink
update the select branch name policy
Browse files Browse the repository at this point in the history
  • Loading branch information
mrproliu committed Nov 16, 2023
1 parent d743d7f commit 6151c89
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions build-bin/maven/maven_release
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6151c89

Please sign in to comment.