fix(ci): validate private .NET SDK
This commit is contained in:
@@ -21,7 +21,16 @@ jobs:
|
||||
# dir via dotnet-install.sh and retry once on failure, mirroring the
|
||||
# npm ci / NuGet retries elsewhere in this workflow.
|
||||
run: |
|
||||
if [ -x "$HOME/.dotnet/dotnet" ] && "$HOME/.dotnet/dotnet" --list-sdks | grep -q '^9\.'; then
|
||||
export DOTNET_ROOT="$HOME/.dotnet"
|
||||
export PATH="$DOTNET_ROOT:$PATH"
|
||||
|
||||
validate_sdk() {
|
||||
[ -x "$DOTNET_ROOT/dotnet" ] \
|
||||
&& "$DOTNET_ROOT/dotnet" --list-sdks | grep -q '^9\.' \
|
||||
&& "$DOTNET_ROOT/dotnet" --info >/dev/null
|
||||
}
|
||||
|
||||
if validate_sdk; then
|
||||
echo "Reusing valid runner-local .NET 9 SDK."
|
||||
else
|
||||
install() {
|
||||
@@ -31,14 +40,15 @@ jobs:
|
||||
feed_args=(--azure-feed "$feed")
|
||||
fi
|
||||
curl -fsSL https://dot.net/v1/dotnet-install.sh -o /tmp/dotnet-install.sh
|
||||
rm -rf "$HOME/.dotnet"
|
||||
bash /tmp/dotnet-install.sh --channel 9.0 --install-dir "$HOME/.dotnet" "${feed_args[@]}"
|
||||
rm -rf "$DOTNET_ROOT"
|
||||
bash /tmp/dotnet-install.sh --channel 9.0 --install-dir "$DOTNET_ROOT" "${feed_args[@]}"
|
||||
validate_sdk
|
||||
}
|
||||
install || ( echo "dotnet install failed ($?) — retrying from alternate Microsoft CDN..." \
|
||||
&& install https://dotnetcli.azureedge.net/dotnet )
|
||||
fi
|
||||
echo "$HOME/.dotnet" >> "$GITHUB_PATH"
|
||||
"$HOME/.dotnet/dotnet" --info
|
||||
echo "$DOTNET_ROOT" >> "$GITHUB_PATH"
|
||||
"$DOTNET_ROOT/dotnet" --info
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
|
||||
Reference in New Issue
Block a user