Skip to content

Commit 2eb3d7f

Browse files
committed
fix: release job isn't respecting minor latest streams
Signed-off-by: xstefank <xstefank122@gmail.com>
1 parent 1affd7d commit 2eb3d7f

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,37 @@ jobs:
3131
echo "tmp_version_branch=v4" >> "$GITHUB_ENV"
3232
- if: ${{ startsWith(github.event.release.tag_name, 'v5.' ) }}
3333
run: |
34-
echo "Setting version_branch to main"
35-
echo "tmp_version_branch=main" >> "$GITHUB_ENV"
34+
RELEASE_VERSION="${{ github.event.release.tag_name }}"
35+
RELEASE_VERSION="${RELEASE_VERSION#v}"
36+
RELEASE_MAJOR_MINOR=$(echo "$RELEASE_VERSION" | cut -d. -f1-2)
37+
38+
# getting this version from POM would require pulling the whole repo
39+
MAIN_POM_VERSION=$(curl -fsSL "https://raw.githubusercontent.com/${{ github.repository }}/main/pom.xml" | python3 -c "
40+
import xml.etree.ElementTree as ET, sys
41+
root = ET.parse(sys.stdin).getroot()
42+
ns = root.tag.split('}')[0].lstrip('{') if '}' in root.tag else ''
43+
tag = '{' + ns + '}version' if ns else 'version'
44+
v = root.find(tag)
45+
if v is None:
46+
sys.exit(1)
47+
print(v.text)
48+
")
49+
if [ -z "$MAIN_POM_VERSION" ]; then
50+
echo "Failed to determine main branch POM version"
51+
exit 1
52+
fi
53+
MAIN_MAJOR_MINOR=$(echo "$MAIN_POM_VERSION" | cut -d. -f1-2)
54+
55+
echo "Release tag major.minor: $RELEASE_MAJOR_MINOR"
56+
echo "Main branch major.minor: $MAIN_MAJOR_MINOR"
57+
58+
if [ "$RELEASE_MAJOR_MINOR" = "$MAIN_MAJOR_MINOR" ]; then
59+
echo "Setting version_branch to main"
60+
echo "tmp_version_branch=main" >> "$GITHUB_ENV"
61+
else
62+
echo "Setting version_branch to ${RELEASE_MAJOR_MINOR}.x"
63+
echo "tmp_version_branch=${RELEASE_MAJOR_MINOR}.x" >> "$GITHUB_ENV"
64+
fi
3665
- if: ${{ env.tmp_version_branch == '' }}
3766
name: Fail if version_branch is not set
3867
run: |

0 commit comments

Comments
 (0)