Skip to content

Commit

Permalink
chore: version extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
samrose committed Dec 17, 2024
1 parent a935b19 commit a2323c2
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions .github/workflows/dockerhub-release-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,17 @@ jobs:
tags_array="["
first=true
# Extract versions directly from matrix config using grep/sed
# Extract versions using grep and sed
matrix_json='${{ needs.prepare.outputs.matrix_config }}'
versions=$(echo "$matrix_json" | grep -o '"version":"[^"]*"' | sed 's/"version":"\(.*\)"/\1/')
versions=$(echo "$matrix_json" | grep -o '"version":"[^"]*"' | sed 's/.*:"//;s/"//')
# For each version
while read -r version; do
# Skip empty versions
if [ -z "$version" ]; then
continue
fi
if [ "$first" = true ]; then
first=false
else
Expand All @@ -128,15 +133,25 @@ jobs:
else
PG_VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres'$version'"]' ansible/vars.yml)
fi
PG_VERSION=$(echo $PG_VERSION | tr -d '"')
versions_array+="\"${version}\""
tags_array+="\"supabase/postgres:${PG_VERSION}\""
# Ensure PG_VERSION is not empty and remove quotes
if [ -n "$PG_VERSION" ]; then
PG_VERSION=$(echo $PG_VERSION | tr -d '"')
versions_array+="\"${version}\""
tags_array+="\"supabase/postgres:${PG_VERSION}\""
fi
done <<< "$versions"
versions_array+="]"
tags_array+="]"
# Validate arrays are not empty
if [ "$versions_array" = "[]" ] || [ "$tags_array" = "[]" ]; then
echo "Error: No valid versions found"
exit 1
fi
echo "versions=$versions_array" >> $GITHUB_OUTPUT
echo "image_tags=$tags_array" >> $GITHUB_OUTPUT
Expand Down

0 comments on commit a2323c2

Please sign in to comment.