@@ -34,23 +34,19 @@ jobs:
3434 RELEASE_VERSION="${{ github.event.release.tag_name }}"
3535 RELEASE_VERSION="${RELEASE_VERSION#v}"
3636 RELEASE_MAJOR_MINOR=$(echo "$RELEASE_VERSION" | cut -d. -f1-2)
37+ MAINTENANCE_BRANCH="${RELEASE_MAJOR_MINOR}.x"
3738
38- MAIN_POM_VERSION=$(curl -fsSL "https://raw.githubusercontent.com/${{ github.repository }}/main/pom.xml" | yq -p xml '.project.version')
39- if [ -z "$MAIN_POM_VERSION" ]; then
40- echo "Failed to determine main branch POM version"
41- exit 1
42- fi
43- MAIN_MAJOR_MINOR=$(echo "$MAIN_POM_VERSION" | cut -d. -f1-2)
44-
39+ # A maintenance branch (e.g. 5.3.x) exists only for streams no longer
40+ # developed on main, so its absence means main is the stream being
41+ # released. Main's pom cannot be used to identify the stream: it carries
42+ # the 999-SNAPSHOT sentinel version.
4543 echo "Release tag major.minor: $RELEASE_MAJOR_MINOR"
46- echo "Main branch major.minor: $MAIN_MAJOR_MINOR"
47-
48- if [ "$RELEASE_MAJOR_MINOR" = "$MAIN_MAJOR_MINOR" ]; then
49- echo "Setting version_branch to main"
50- echo "tmp_version_branch=main" >> "$GITHUB_ENV"
44+ if git ls-remote --exit-code --heads "${{ github.server_url }}/${{ github.repository }}.git" "refs/heads/${MAINTENANCE_BRANCH}" >/dev/null 2>&1; then
45+ echo "Setting version_branch to ${MAINTENANCE_BRANCH}"
46+ echo "tmp_version_branch=${MAINTENANCE_BRANCH}" >> "$GITHUB_ENV"
5147 else
52- echo "Setting version_branch to ${RELEASE_MAJOR_MINOR}.x "
53- echo "tmp_version_branch=${RELEASE_MAJOR_MINOR}.x " >> "$GITHUB_ENV"
48+ echo "No ${MAINTENANCE_BRANCH} branch, setting version_branch to main "
49+ echo "tmp_version_branch=main " >> "$GITHUB_ENV"
5450 fi
5551 - if : ${{ env.tmp_version_branch == '' }}
5652 name : Fail if version_branch is not set
0 commit comments