Skip to content

Commit d31084a

Browse files
committed
Simplify dotnet install versions lookup step
1 parent 2f0a155 commit d31084a

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

.github/actions/dotnet/action.yml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,15 @@ runs:
88
id: dotnet
99
shell: bash
1010
run: |
11-
# Try to read versions from .github/workflows/dotnet.json first
1211
if [ -f .github/workflows/dotnet.json ]; then
13-
VERSIONS=$(jq -r '.[]' .github/workflows/dotnet.json | tr '\n' ',' | sed 's/,$//')
12+
VERSIONS=$(jq -r '.[]' .github/workflows/dotnet.json)
1413
else
15-
VERSIONS=$(gh api repos/${{ github.repository }}/properties/values | jq -r '.[] | select(.property_name == "DOTNET") | .value')
14+
VERSIONS=$(gh api repos/${{ github.repository }}/properties/values | jq -r '[.[] | select(.property_name == "DOTNET") | .value] | join(",") | split(",")[] | gsub("^\\s+|\\s+$"; "")')
1615
fi
17-
# Remove extra whitespace from VERSIONS
18-
VERSIONS=$(echo "$VERSIONS" | tr -s ' ' | tr -d ' ')
19-
# Convert comma-separated to newline-separated
20-
NEWLINE_VERSIONS=$(echo "$VERSIONS" | tr ',' '\n')
21-
# Validate versions
22-
while IFS= read -r version; do
23-
if ! [[ $version =~ ^[0-9]+(\.[0-9]+(\.[0-9]+)?)?(\.x)?$ ]]; then
24-
echo "Error: Invalid version format: $version"
25-
exit 1
26-
fi
27-
done <<< "$NEWLINE_VERSIONS"
2816
# Write multiline output to $GITHUB_OUTPUT
2917
{
3018
echo 'versions<<EOF'
31-
echo "$NEWLINE_VERSIONS"
19+
echo "$VERSIONS"
3220
echo 'EOF'
3321
} >> $GITHUB_OUTPUT
3422

0 commit comments

Comments
 (0)