Skip to content

Commit

Permalink
fix: Fix fetching latest version using refs/tags API
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Aug 23, 2023
1 parent 3721d50 commit 14ddf2d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/alpha-releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ jobs:
RELEASE_SUFFIX=${GITHUB_REF#refs/heads/release/}
# Fetch all tags and get the latest that matches the pattern
LATEST_VERSION=$(curl --silent "https://api.github.com/repos/$GITHUB_REPOSITORY/releases" \
| jq -r --arg suffix "$RELEASE_SUFFIX" '.[] | select(.tag_name | test("^v?[0-9]+\\.[0-9]+\\.[0-9]+-" + $suffix + "$")) | .tag_name' \
| sort -V | tail -n 1)
# Using the refs/tags API
LATEST_VERSION=$(curl --silent "https://api.github.com/repos/$GITHUB_REPOSITORY/git/refs/tags" \
| jq -r --arg suffix "$RELEASE_SUFFIX" '.[] | select(.ref | test("refs/tags/v?[0-9]+\\.[0-9]+\\.[0-9]+-" + $suffix + "$")) | .ref' \
| sed 's|refs/tags/||' | sort -V | tail -n 1)
echo "Found latest $RELEASE_SUFFIX version: $LATEST_VERSION"
# Default to 0.0.0 if no matching release was found
Expand All @@ -44,7 +45,7 @@ jobs:
# Log the short commit SHA
SHORT_COMMIT=$(git rev-parse --short HEAD)
echo "Git commit: $SHORT_COMMIT"
git tag -a "$VERSION" -m "Release $VERSION"
Expand Down

0 comments on commit 14ddf2d

Please sign in to comment.