From b5baf83fd879712246472da88ac9e411837c4954 Mon Sep 17 00:00:00 2001 From: jamshale <31809382+jamshale@users.noreply.github.com> Date: Tue, 21 May 2024 08:25:20 -0700 Subject: [PATCH] Fix the release workflow upgrade check (#480) Signed-off-by: jamshale --- .github/workflows/create-release.yaml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 11223b011..8f340300f 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -64,14 +64,18 @@ jobs: } for file in ${get_changed_files}; do - if [[ $file == *"/poetry.lock"* ]] && [[ $file != *"integration/poetry.lock"* ]]; then - lock_version=$(grep -A1 'name = "aries-cloudagent"' $file | grep -v 'name = "aries-cloudagent"') - version=$(grep -oP '(?<=").*?(?=")' <<< "$lock_version") - echo "Version = $version" + number_of_slashes=$(grep -o "/" <<< "$file" | wc -l) + # Check if the lock file is rooted + if [[ $file == *"/poetry.lock"* ]] && [[ "$number_of_slashes" == 1 ]]; then + changes="$(git diff ${{ github.event.before }} ${{ github.event.after }} $file)" + lock_version=$(echo "$changes" | grep -A1 'name = "aries-cloudagent"' | head -n 2 | tail -n 1 | awk '{print $3}' | tr -d '"') + echo "File = $file" + echo "Old Version = $lock_version" echo "Global Version = $current_global_version" - if [[ $(sem_version $current_global_version) -ge $(sem_version $version) ]]; then - echo "Upgrade Detected for $plugin in file $file" + if [[ "$lock_version" ]] && [[ $(sem_version $current_global_version) -gt $(sem_version $lock_version) ]]; then + echo "Upgrade Detected in $file" found_upgrade=true + break fi fi done