Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,37 +66,58 @@ runs:
echo "FETCH_FAILED=true" >> $GITHUB_ENV
exit 1
fi


ARCH="linux_amd64"
FOUND_VERSION=""
FOUND_TAG=""

# Find the first release that matches our criteria:
# 1. Tag name starts with "v"
# 2. Tag name does not contain "-postgres"
# 3. Is not a prerelease
# 4. Is not a draft
TAG_NAME=$(echo "$JSON" | jq -r '
# 5. Has the expected CLI asset for this architecture
while IFS= read -r TAG_NAME; do
# Extract version from tag (remove "v" prefix)
VERSION=$(echo "$TAG_NAME" | sed 's|v||')
ASSET="cli_${VERSION}_${ARCH}.tar.gz"

# Check if the release actually contains the expected asset
HAS_ASSET=$(echo "$JSON" | jq -r --arg tag "$TAG_NAME" --arg asset "$ASSET" '
.[] | select(.tag_name == $tag) | .assets[] | select(.name == $asset) | .name
')

if [[ -n "$HAS_ASSET" ]]; then
echo "βœ… Found release $TAG_NAME with asset $ASSET"
FOUND_VERSION="$VERSION"
FOUND_TAG="$TAG_NAME"
break
else
echo "⚠️ Release $TAG_NAME does not have asset $ASSET, skipping..."
fi
done < <(echo "$JSON" | jq -r '
.[] |
select(.draft == false) |
select(.prerelease == false) |
select(.tag_name | startswith("v")) |
select(.tag_name | contains("-postgres") | not) |
.tag_name |
select(. != null)' | head -n1)
select(. != null)
')

# Check if we found a valid tag
if [[ "$TAG_NAME" == "null" || -z "$TAG_NAME" ]]; then
echo "❌ No valid Infisical CLI release found"
if [[ -z "$FOUND_VERSION" || -z "$FOUND_TAG" ]]; then
echo "❌ No valid Infisical CLI release found with the expected asset"
echo "Available releases:"
echo "$JSON" | jq -r '.[] | select(.draft == false) | .tag_name' | head -10
echo "FETCH_FAILED=true" >> $GITHUB_ENV
exit 1
fi

# Extract version from tag (remove "v" prefix)
VERSION=$(echo "$TAG_NAME" | sed 's|v||')
echo "πŸ” Found valid CLI version: $VERSION (tag: $TAG_NAME)"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
echo "πŸ” Found valid CLI version: $FOUND_VERSION (tag: $FOUND_TAG)"
echo "version=$FOUND_VERSION" >> "$GITHUB_OUTPUT"
echo "tag_name=$FOUND_TAG" >> "$GITHUB_OUTPUT"
echo "FETCH_FAILED=false" >> $GITHUB_ENV

- name: Cache Infisical CLI
uses: actions/cache@v5
id: infisical-cache
Expand Down
Loading