1+ name : Install .NET Core SDK
2+ description : Installs a specified .NET Core SDK version
3+
4+ inputs :
5+ dotnet-version :
6+ description : The version of .NET SDK to install (e.g., 3.1.426)
7+ required : true
8+ architecture :
9+ description : Target architecture (e.g., x64 or arm64)
10+ required : true
11+
12+ runs :
13+ using : " composite"
14+ steps :
15+ - name : Resolve .NET Core SDK Version
16+ shell : bash
17+ env :
18+ RAW_INPUT : ${{ inputs.dotnet-version }}
19+ run : |
20+ DOTNET_CHANNEL="${RAW_INPUT%%.x}"
21+
22+ RELEASE_INDEX_URL="https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json"
23+
24+ # Get the URL to the channel-specific releases.json
25+ RELEASES_JSON_URL=$(curl -s $RELEASE_INDEX_URL \
26+ | jq -r --arg ver "$DOTNET_CHANNEL" '
27+ .["releases-index"][]
28+ | select(.["channel-version"] == $ver)
29+ | ."releases.json"')
30+
31+ if [ -z "$RELEASES_JSON_URL" ]; then
32+ echo "Could not resolve releases.json URL for channel $DOTNET_CHANNEL"
33+ exit 1
34+ fi
35+
36+ # Download and extract latest SDK version
37+ DOTNET_VERSION=$(curl -s $RELEASES_JSON_URL \
38+ | jq -r '
39+ .releases[]
40+ | select(.sdk.version != null)
41+ | .sdk.version' \
42+ | sort -Vr \
43+ | head -n1)
44+
45+ if [ -z "$DOTNET_VERSION" ]; then
46+ echo "Could not resolve SDK version from $RELEASES_JSON_URL"
47+ exit 1
48+ fi
49+
50+ echo "Resolved full SDK version: $DOTNET_VERSION"
51+ echo "DOTNET_VERSION=$DOTNET_VERSION" >> $GITHUB_ENV
52+
53+ - name : Install .NET Core SDK [ ${{ inputs.dotnet-version }} ]
54+ shell : bash
55+ run : |
56+ ARCHITECTURE="${{ inputs.architecture }}"
57+ INSTALL_DIR=$HOME/dotnet
58+
59+ echo "Installing .NET SDK $DOTNET_VERSION for $ARCHITECTURE..."
60+ mkdir -p "$INSTALL_DIR"
61+ curl -sSL https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh -o dotnet-install.sh
62+ chmod +x dotnet-install.sh
63+ ./dotnet-install.sh --version "$DOTNET_VERSION" --install-dir "$INSTALL_DIR" --architecture "$ARCHITECTURE"
64+
65+ - name : Add dotnet to PATH
66+ shell : bash
67+ run : echo "$HOME/dotnet" >> $GITHUB_PATH
68+
69+ - name : Check .NET SDK
70+ shell : bash
71+ run : |
72+ dotnet --info
0 commit comments