@@ -100,15 +100,32 @@ jobs:
100100 PKG_NAME : ${{ needs.build.outputs.pkg-name }}
101101 VERSION : ${{ needs.build.outputs.version }}
102102 run : |
103- PREV_TAG="$PKG_NAME==${VERSION%.*}.$(( ${VERSION##*.} - 1 ))"; [[ "${VERSION##*.}" -eq 0 ]] && PREV_TAG=""
104-
105- # backup case if releasing e.g. 0.3.0, looks up last release
106- # note if last release (chronologically) was e.g. 0.1.47 it will get
107- # that instead of the last 0.2 release
108- if [ -z "$PREV_TAG" ]; then
109- REGEX="^$PKG_NAME==\\d+\\.\\d+\\.\\d+\$"
110- echo $REGEX
111- PREV_TAG=$(git tag --sort=-creatordate | (grep -P $REGEX || true) | head -1)
103+ # Handle regular versions and pre-release versions differently
104+ if [[ "$VERSION" == *"-"* ]]; then
105+ # This is a pre-release version (contains a hyphen)
106+ # Extract the base version without the pre-release suffix
107+ BASE_VERSION=${VERSION%%-*}
108+ # Look for the latest release of the same base version
109+ REGEX="^$PKG_NAME==$BASE_VERSION\$"
110+ PREV_TAG=$(git tag --sort=-creatordate | (grep -P "$REGEX" || true) | head -1)
111+
112+ # If no exact base version match, look for the latest release of any kind
113+ if [ -z "$PREV_TAG" ]; then
114+ REGEX="^$PKG_NAME==\\d+\\.\\d+\\.\\d+\$"
115+ PREV_TAG=$(git tag --sort=-creatordate | (grep -P "$REGEX" || true) | head -1)
116+ fi
117+ else
118+ # Regular version handling
119+ PREV_TAG="$PKG_NAME==${VERSION%.*}.$(( ${VERSION##*.} - 1 ))"; [[ "${VERSION##*.}" -eq 0 ]] && PREV_TAG=""
120+
121+ # backup case if releasing e.g. 0.3.0, looks up last release
122+ # note if last release (chronologically) was e.g. 0.1.47 it will get
123+ # that instead of the last 0.2 release
124+ if [ -z "$PREV_TAG" ]; then
125+ REGEX="^$PKG_NAME==\\d+\\.\\d+\\.\\d+\$"
126+ echo $REGEX
127+ PREV_TAG=$(git tag --sort=-creatordate | (grep -P $REGEX || true) | head -1)
128+ fi
112129 fi
113130
114131 # if PREV_TAG is empty, let it be empty
@@ -363,10 +380,9 @@ jobs:
363380 # Shallow-fetch just that single tag
364381 git fetch --depth=1 origin tag "$LATEST_PACKAGE_TAG"
365382
366- # Navigate to the partner directory
367- cd $GITHUB_WORKSPACE/libs/partners/${{ matrix.partner }}
368-
369383 # Checkout the latest package files
384+ rm -rf $GITHUB_WORKSPACE/libs/partners/${{ matrix.partner }}/*
385+ cd $GITHUB_WORKSPACE/libs/partners/${{ matrix.partner }}
370386 git checkout "$LATEST_PACKAGE_TAG" -- .
371387
372388 # Print as a sanity check
0 commit comments