From 60859ec2b9ba241f09bc5d336d4d53975ccc04b6 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Tue, 1 Apr 2025 21:14:24 +1300 Subject: [PATCH] ci: Fix latest tag detection to exclude dev tags --- .github/workflows/check_pypi_version.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_pypi_version.yml b/.github/workflows/check_pypi_version.yml index eaf892aac..4ed4fd959 100644 --- a/.github/workflows/check_pypi_version.yml +++ b/.github/workflows/check_pypi_version.yml @@ -55,13 +55,23 @@ jobs: - name: Get latest tag id: latest_tag run: | + set -x # Enable debugging output # Fetch all tags from remote just in case git fetch --tags origin main - # Get the latest tag that looks like vX.Y.Z (no 'dev') - latest_tag=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -n 1) + # Get the latest tag that strictly matches vX.Y.Z (no suffixes like .dev) + # List all tags, sort by version descending, filter for exact pattern, take the first one + latest_tag=$(git tag --sort=-v:refname | grep -P '^v\d+\.\d+\.\d+$' | head -n 1) + + if [ -z "$latest_tag" ]; then + echo "Error: Could not find any tags matching the pattern '^v\d+\.\d+\.\d+$'" + exit 1 + fi + echo "Latest non-dev tag: $latest_tag" # Remove 'v' prefix for comparison - echo "tag=${latest_tag#v}" >> $GITHUB_OUTPUT + tag_num=${latest_tag#v} + echo "Extracted tag number: $tag_num" + echo "tag=$tag_num" >> $GITHUB_OUTPUT - name: Compare versions run: |