From 256a80b2569447dd6c3a25673981647a71f10eca Mon Sep 17 00:00:00 2001 From: Matt Edwards Date: Fri, 21 Jun 2024 14:36:28 -0400 Subject: [PATCH] grab the latest release by version --- .github/workflows/publish.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6aaf36d5..919cc638 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -49,8 +49,13 @@ jobs: id: get_version_suffix shell: bash run: | - release_info=$(gh release view $version) || exit 1 - version_suffix=${release_info#*$version} + # Fetch the list of releases + releases=$(gh release list --json createdAt,tagName --limit 100) + + # Filter the releases based on the starting version number, sort them by date, and extract the most recent one + latest_release=$(echo "$releases" | jq -r --arg version "$version" 'map(select(.tagName | startswith($version))) | sort_by(.createdAt) | reverse | .[0] | .tagName') + + version_suffix=${latest_release#*$version} echo "VERSION_SUFFIX=$version_suffix" >> $GITHUB_ENV env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}