Skip to content

Commit 7e9acf4

Browse files
authored
Allow installing multiple coma-separated versions
1 parent 917ff54 commit 7e9acf4

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

.github/actions/dotnet/action.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,27 @@ runs:
99
shell: bash
1010
run: |
1111
VERSIONS=$(gh api /repos/${{ github.repository }}/properties/values | jq -r '.[] | select(.property_name == "DOTNET") | .value')
12-
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
12+
# Remove extra whitespace from VERSIONS
13+
VERSIONS=$(echo "$VERSIONS" | tr -s ' ' | tr -d ' ')
14+
# Convert comma-separated to newline-separated
15+
NEWLINE_VERSIONS=$(echo "$VERSIONS" | tr ',' '\n')
16+
# Validate versions
17+
while IFS= read -r version; do
18+
if ! [[ $version =~ ^[0-9]+(\.[0-9]+(\.[0-9]+)?)?(\.x)?$ ]]; then
19+
echo "Error: Invalid version format: $version"
20+
exit 1
21+
fi
22+
done <<< "$NEWLINE_VERSIONS"
23+
# Write multiline output to $GITHUB_OUTPUT
24+
{
25+
echo 'versions<<EOF'
26+
echo "$NEWLINE_VERSIONS"
27+
echo 'EOF'
28+
} >> $GITHUB_OUTPUT
1329
1430
- name: ⚙ dotnet
1531
if: steps.dotnet.outputs.versions != ''
1632
uses: actions/setup-dotnet@v4
1733
with:
18-
dotnet-version: ${{ steps.dotnet.outputs.versions }}
34+
dotnet-version: |
35+
${{ steps.dotnet.outputs.versions }}

0 commit comments

Comments
 (0)