infra: release tag compute (#27836)

This commit is contained in:
Erick Friis 2024-11-04 12:16:51 -08:00 committed by GitHub
parent f86a09f82c
commit 4e5cc84d40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -95,16 +95,31 @@ jobs:
PKG_NAME: ${{ needs.build.outputs.pkg-name }} PKG_NAME: ${{ needs.build.outputs.pkg-name }}
VERSION: ${{ needs.build.outputs.version }} VERSION: ${{ needs.build.outputs.version }}
run: | run: |
REGEX="^$PKG_NAME==\\d+\\.\\d+\\.\\d+\$" PREV_TAG="${curr_version%.*}.$(( ${curr_version##*.} - 1 ))"; [[ "${curr_version##*.}" -eq 0 ]] && PREV_TAG=""
echo $REGEX
PREV_TAG=$(git tag --sort=-creatordate | grep -P $REGEX || true | head -1) # backup case if releasing e.g. 0.3.0, looks up last release
# note if last release (chronologically) was e.g. 0.1.47 it will get
# that instead of the last 0.2 release
if [ -z "$PREV_TAG" ]; then
REGEX="^$PKG_NAME==\\d+\\.\\d+\\.\\d+\$"
echo $REGEX
PREV_TAG=$(git tag --sort=-creatordate | grep -P $REGEX || true | head -1)
fi
# confirm prev-tag actually exists in git repo with git tag
if [ -z git tag -l "$PREV_TAG" ]; then
echo "Previous tag $PREV_TAG not found in git repo"
exit 1
fi
TAG="${PKG_NAME}==${VERSION}" TAG="${PKG_NAME}==${VERSION}"
if [ "$TAG" == "$PREV_TAG" ]; then if [ "$TAG" == "$PREV_TAG" ]; then
echo "No new version to release" echo "No new version to release"
exit 1 exit 1
fi fi
echo tag="$TAG" >> $GITHUB_OUTPUT echo tag="$TAG" >> $GITHUB_OUTPUT
echo prev-tag="$PREV_TAG" >> $GITHUB_OUTPUT echo prev-tag="$PKG_NAME==$last_version" >> $GITHUB_OUTPUT
- name: Generate release body - name: Generate release body
id: generate-release-body id: generate-release-body
working-directory: langchain working-directory: langchain