Merge branch 'master' into master
This commit is contained in:
commit
474fe34688
|
@ -1,5 +1,5 @@
|
|||
name: Main workflow
|
||||
on: [push]
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
run:
|
||||
name: Run
|
||||
|
|
|
@ -92,3 +92,4 @@ typings/
|
|||
.dynamodb/
|
||||
|
||||
.vscode/*
|
||||
node_modules
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<a href="https://github.com/actions/setup-dotnet"><img alt="GitHub Actions status" src="https://github.com/actions/setup-dotnet/workflows/Main%20workflow/badge.svg"></a>
|
||||
</p>
|
||||
|
||||
This action sets up a dotnet environment for use in actions by:
|
||||
This action sets up a [dotnet core cli](https://github.com/dotnet/cli) environment for use in actions by:
|
||||
|
||||
- optionally downloading and caching a version of dotnet by SDK version and adding to PATH
|
||||
- registering problem matchers for error output
|
||||
|
@ -30,7 +30,7 @@ jobs:
|
|||
runs-on: ubuntu-16.04
|
||||
strategy:
|
||||
matrix:
|
||||
dotnet: [ '2.2.103', '3.0.100-preview8-013656', '4.5.1' ]
|
||||
dotnet: [ '2.2.103', '3.0.100', '3.1.100-preview1-014459' ]
|
||||
name: Dotnet ${{ matrix.dotnet }} sample
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
|
|
@ -37,15 +37,13 @@
|
|||
.PARAMETER SharedRuntime
|
||||
This parameter is obsolete and may be removed in a future version of this script.
|
||||
The recommended alternative is '-Runtime dotnet'.
|
||||
|
||||
Default: false
|
||||
Installs just the shared runtime bits, not the entire SDK.
|
||||
This is equivalent to specifying `-Runtime dotnet`.
|
||||
.PARAMETER Runtime
|
||||
Installs just a shared runtime, not the entire SDK.
|
||||
Possible values:
|
||||
- dotnet - the Microsoft.NETCore.App shared runtime
|
||||
- aspnetcore - the Microsoft.AspNetCore.App shared runtime
|
||||
- windowsdesktop - the Microsoft.WindowsDesktop.App shared runtime
|
||||
.PARAMETER DryRun
|
||||
If set it will not perform installation but instead display what command line to use to consistently install
|
||||
currently requested version of dotnet cli. In example if you specify version 'latest' it will display a link
|
||||
|
@ -76,14 +74,18 @@
|
|||
Skips installing non-versioned files if they already exist, such as dotnet.exe.
|
||||
.PARAMETER NoCdn
|
||||
Disable downloading from the Azure CDN, and use the uncached feed directly.
|
||||
.PARAMETER JSonFile
|
||||
Determines the SDK version from a user specified global.json file
|
||||
Note: global.json must have a value for 'SDK:Version'
|
||||
#>
|
||||
[cmdletbinding()]
|
||||
param(
|
||||
[string]$Channel="LTS",
|
||||
[string]$Version="Latest",
|
||||
[string]$JSonFile,
|
||||
[string]$InstallDir="<auto>",
|
||||
[string]$Architecture="<auto>",
|
||||
[ValidateSet("dotnet", "aspnetcore", IgnoreCase = $false)]
|
||||
[ValidateSet("dotnet", "aspnetcore", "windowsdesktop", IgnoreCase = $false)]
|
||||
[string]$Runtime,
|
||||
[Obsolete("This parameter may be removed in a future version of this script. The recommended alternative is '-Runtime dotnet'.")]
|
||||
[switch]$SharedRuntime,
|
||||
|
@ -257,7 +259,6 @@ function GetHTTPResponse([Uri] $Uri)
|
|||
})
|
||||
}
|
||||
|
||||
|
||||
function Get-Latest-Version-Info([string]$AzureFeed, [string]$Channel, [bool]$Coherent) {
|
||||
Say-Invocation $MyInvocation
|
||||
|
||||
|
@ -268,6 +269,10 @@ function Get-Latest-Version-Info([string]$AzureFeed, [string]$Channel, [bool]$Co
|
|||
elseif ($Runtime -eq "aspnetcore") {
|
||||
$VersionFileUrl = "$UncachedFeed/aspnetcore/Runtime/$Channel/latest.version"
|
||||
}
|
||||
# Currently, the WindowsDesktop runtime is manufactured with the .Net core runtime
|
||||
elseif ($Runtime -eq "windowsdesktop") {
|
||||
$VersionFileUrl = "$UncachedFeed/Runtime/$Channel/latest.version"
|
||||
}
|
||||
elseif (-not $Runtime) {
|
||||
if ($Coherent) {
|
||||
$VersionFileUrl = "$UncachedFeed/Sdk/$Channel/latest.coherent.version"
|
||||
|
@ -299,10 +304,50 @@ function Get-Latest-Version-Info([string]$AzureFeed, [string]$Channel, [bool]$Co
|
|||
return $VersionInfo
|
||||
}
|
||||
|
||||
|
||||
function Get-Specific-Version-From-Version([string]$AzureFeed, [string]$Channel, [string]$Version) {
|
||||
function Parse-Jsonfile-For-Version([string]$JSonFile) {
|
||||
Say-Invocation $MyInvocation
|
||||
|
||||
If (-Not (Test-Path $JSonFile)) {
|
||||
throw "Unable to find '$JSonFile'"
|
||||
exit 0
|
||||
}
|
||||
try {
|
||||
$JSonContent = Get-Content($JSonFile) -Raw | ConvertFrom-Json | Select-Object -expand "sdk" -ErrorAction SilentlyContinue
|
||||
}
|
||||
catch {
|
||||
throw "Json file unreadable: '$JSonFile'"
|
||||
exit 0
|
||||
}
|
||||
if ($JSonContent) {
|
||||
try {
|
||||
$JSonContent.PSObject.Properties | ForEach-Object {
|
||||
$PropertyName = $_.Name
|
||||
if ($PropertyName -eq "version") {
|
||||
$Version = $_.Value
|
||||
Say-Verbose "Version = $Version"
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
throw "Unable to parse the SDK node in '$JSonFile'"
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw "Unable to find the SDK node in '$JSonFile'"
|
||||
exit 0
|
||||
}
|
||||
If ($Version -eq $null) {
|
||||
throw "Unable to find the SDK:version node in '$JSonFile'"
|
||||
exit 0
|
||||
}
|
||||
return $Version
|
||||
}
|
||||
|
||||
function Get-Specific-Version-From-Version([string]$AzureFeed, [string]$Channel, [string]$Version, [string]$JSonFile) {
|
||||
Say-Invocation $MyInvocation
|
||||
|
||||
if (-not $JSonFile) {
|
||||
switch ($Version.ToLower()) {
|
||||
{ $_ -eq "latest" } {
|
||||
$LatestVersionInfo = Get-Latest-Version-Info -AzureFeed $AzureFeed -Channel $Channel -Coherent $False
|
||||
|
@ -314,6 +359,10 @@ function Get-Specific-Version-From-Version([string]$AzureFeed, [string]$Channel,
|
|||
}
|
||||
default { return $Version }
|
||||
}
|
||||
}
|
||||
else {
|
||||
return Parse-Jsonfile-For-Version $JSonFile
|
||||
}
|
||||
}
|
||||
|
||||
function Get-Download-Link([string]$AzureFeed, [string]$SpecificVersion, [string]$CLIArchitecture) {
|
||||
|
@ -325,6 +374,9 @@ function Get-Download-Link([string]$AzureFeed, [string]$SpecificVersion, [string
|
|||
elseif ($Runtime -eq "aspnetcore") {
|
||||
$PayloadURL = "$AzureFeed/aspnetcore/Runtime/$SpecificVersion/aspnetcore-runtime-$SpecificVersion-win-$CLIArchitecture.zip"
|
||||
}
|
||||
elseif ($Runtime -eq "windowsdesktop") {
|
||||
$PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/windowsdesktop-runtime-$SpecificVersion-win-$CLIArchitecture.zip"
|
||||
}
|
||||
elseif (-not $Runtime) {
|
||||
$PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-sdk-$SpecificVersion-win-$CLIArchitecture.zip"
|
||||
}
|
||||
|
@ -374,23 +426,6 @@ function Resolve-Installation-Path([string]$InstallDir) {
|
|||
return $InstallDir
|
||||
}
|
||||
|
||||
function Get-Version-Info-From-Version-File([string]$InstallRoot, [string]$RelativePathToVersionFile) {
|
||||
Say-Invocation $MyInvocation
|
||||
|
||||
$VersionFile = Join-Path -Path $InstallRoot -ChildPath $RelativePathToVersionFile
|
||||
Say-Verbose "Local version file: $VersionFile"
|
||||
|
||||
if (Test-Path $VersionFile) {
|
||||
$VersionText = cat $VersionFile
|
||||
Say-Verbose "Local version file text: $VersionText"
|
||||
return Get-Version-Info-From-Version-Text $VersionText
|
||||
}
|
||||
|
||||
Say-Verbose "Local version file not found."
|
||||
|
||||
return $null
|
||||
}
|
||||
|
||||
function Is-Dotnet-Package-Installed([string]$InstallRoot, [string]$RelativePathToPackage, [string]$SpecificVersion) {
|
||||
Say-Invocation $MyInvocation
|
||||
|
||||
|
@ -526,7 +561,7 @@ function Prepend-Sdk-InstallRoot-To-Path([string]$InstallRoot, [string]$BinFolde
|
|||
}
|
||||
|
||||
$CLIArchitecture = Get-CLIArchitecture-From-Architecture $Architecture
|
||||
$SpecificVersion = Get-Specific-Version-From-Version -AzureFeed $AzureFeed -Channel $Channel -Version $Version
|
||||
$SpecificVersion = Get-Specific-Version-From-Version -AzureFeed $AzureFeed -Channel $Channel -Version $Version -JSonFile $JSonFile
|
||||
$DownloadLink = Get-Download-Link -AzureFeed $AzureFeed -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
|
||||
$LegacyDownloadLink = Get-LegacyDownload-Link -AzureFeed $AzureFeed -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
|
||||
|
||||
|
@ -564,6 +599,10 @@ elseif ($Runtime -eq "aspnetcore") {
|
|||
$assetName = "ASP.NET Core Runtime"
|
||||
$dotnetPackageRelativePath = "shared\Microsoft.AspNetCore.App"
|
||||
}
|
||||
elseif ($Runtime -eq "windowsdesktop") {
|
||||
$assetName = ".NET Core Windows Desktop Runtime"
|
||||
$dotnetPackageRelativePath = "shared\Microsoft.WindowsDesktop.App"
|
||||
}
|
||||
elseif (-not $Runtime) {
|
||||
$assetName = ".NET Core SDK"
|
||||
$dotnetPackageRelativePath = "sdk"
|
||||
|
|
|
@ -148,7 +148,7 @@ get_linux_platform_name() {
|
|||
return 0
|
||||
elif [ -e /etc/redhat-release ]; then
|
||||
local redhatRelease=$(</etc/redhat-release)
|
||||
if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
|
||||
if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux "*" release 6."* ]]; then
|
||||
echo "rhel.6"
|
||||
return 0
|
||||
fi
|
||||
|
@ -435,11 +435,52 @@ get_latest_version_info() {
|
|||
return $?
|
||||
}
|
||||
|
||||
# args:
|
||||
# json_file - $1
|
||||
parse_jsonfile_for_version() {
|
||||
eval $invocation
|
||||
|
||||
local json_file="$1"
|
||||
if [ ! -f "$json_file" ]; then
|
||||
say_err "Unable to find \`$json_file\`"
|
||||
return 1
|
||||
fi
|
||||
|
||||
sdk_section=$(cat $json_file | awk '/"sdk"/,/}/')
|
||||
if [ -z "$sdk_section" ]; then
|
||||
say_err "Unable to parse the SDK node in \`$json_file\`"
|
||||
return 1
|
||||
fi
|
||||
|
||||
sdk_list=$(echo $sdk_section | awk -F"[{}]" '{print $2}')
|
||||
sdk_list=${sdk_list//[\" ]/}
|
||||
sdk_list=${sdk_list//,/$'\n'}
|
||||
sdk_list="$(echo -e "${sdk_list}" | tr -d '[[:space:]]')"
|
||||
|
||||
local version_info=""
|
||||
while read -r line; do
|
||||
IFS=:
|
||||
while read -r key value; do
|
||||
if [[ "$key" == "version" ]]; then
|
||||
version_info=$value
|
||||
fi
|
||||
done <<< "$line"
|
||||
done <<< "$sdk_list"
|
||||
if [ -z "$version_info" ]; then
|
||||
say_err "Unable to find the SDK:version node in \`$json_file\`"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "$version_info"
|
||||
return 0
|
||||
}
|
||||
|
||||
# args:
|
||||
# azure_feed - $1
|
||||
# channel - $2
|
||||
# normalized_architecture - $3
|
||||
# version - $4
|
||||
# json_file - $5
|
||||
get_specific_version_from_version() {
|
||||
eval $invocation
|
||||
|
||||
|
@ -447,7 +488,9 @@ get_specific_version_from_version() {
|
|||
local channel="$2"
|
||||
local normalized_architecture="$3"
|
||||
local version="$(to_lowercase "$4")"
|
||||
local json_file="$5"
|
||||
|
||||
if [ -z "$json_file" ]; then
|
||||
case "$version" in
|
||||
latest)
|
||||
local version_info
|
||||
|
@ -468,6 +511,12 @@ get_specific_version_from_version() {
|
|||
return 0
|
||||
;;
|
||||
esac
|
||||
else
|
||||
local version_info
|
||||
version_info="$(parse_jsonfile_for_version "$json_file")" || return 1
|
||||
echo "$version_info"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
# args:
|
||||
|
@ -558,24 +607,6 @@ resolve_installation_path() {
|
|||
return 0
|
||||
}
|
||||
|
||||
# args:
|
||||
# install_root - $1
|
||||
get_installed_version_info() {
|
||||
eval $invocation
|
||||
|
||||
local install_root="$1"
|
||||
local version_file="$(combine_paths "$install_root" "$local_version_file_relative_path")"
|
||||
say_verbose "Local version file: $version_file"
|
||||
if [ ! -z "$version_file" ] | [ -r "$version_file" ]; then
|
||||
local version_info="$(cat "$version_file")"
|
||||
echo "$version_info"
|
||||
return 0
|
||||
fi
|
||||
|
||||
say_verbose "Local version file not found."
|
||||
return 0
|
||||
}
|
||||
|
||||
# args:
|
||||
# relative_or_absolute_path - $1
|
||||
get_absolute_path() {
|
||||
|
@ -612,6 +643,9 @@ copy_files_or_dirs_from_list() {
|
|||
local target="$out_path/$path"
|
||||
if [ "$override" = true ] || (! ([ -d "$target" ] || [ -e "$target" ])); then
|
||||
mkdir -p "$out_path/$(dirname "$path")"
|
||||
if [ -d "$target" ]; then
|
||||
rm -rf "$target"
|
||||
fi
|
||||
cp -R $override_switch "$root_path/$path" "$target"
|
||||
fi
|
||||
done
|
||||
|
@ -721,7 +755,7 @@ calculate_vars() {
|
|||
normalized_architecture="$(get_normalized_architecture_from_architecture "$architecture")"
|
||||
say_verbose "normalized_architecture=$normalized_architecture"
|
||||
|
||||
specific_version="$(get_specific_version_from_version "$azure_feed" "$channel" "$normalized_architecture" "$version")"
|
||||
specific_version="$(get_specific_version_from_version "$azure_feed" "$channel" "$normalized_architecture" "$version" "$json_file")"
|
||||
say_verbose "specific_version=$specific_version"
|
||||
if [ -z "$specific_version" ]; then
|
||||
say_err "Could not resolve version information."
|
||||
|
@ -823,6 +857,7 @@ temporary_file_template="${TMPDIR:-/tmp}/dotnet.XXXXXXXXX"
|
|||
|
||||
channel="LTS"
|
||||
version="Latest"
|
||||
json_file=""
|
||||
install_dir="<auto>"
|
||||
architecture="<auto>"
|
||||
dry_run=false
|
||||
|
@ -868,6 +903,9 @@ do
|
|||
runtime="$1"
|
||||
if [[ "$runtime" != "dotnet" ]] && [[ "$runtime" != "aspnetcore" ]]; then
|
||||
say_err "Unsupported value for --runtime: '$1'. Valid values are 'dotnet' and 'aspnetcore'."
|
||||
if [[ "$runtime" == "windowsdesktop" ]]; then
|
||||
say_err "WindowsDesktop archives are manufactured for Windows platforms only."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
@ -906,6 +944,10 @@ do
|
|||
runtime_id="$1"
|
||||
non_dynamic_parameters+=" $name "\""$1"\"""
|
||||
;;
|
||||
--jsonfile|-[Jj][Ss]on[Ff]ile)
|
||||
shift
|
||||
json_file="$1"
|
||||
;;
|
||||
--skip-non-versioned-files|-[Ss]kip[Nn]on[Vv]ersioned[Ff]iles)
|
||||
override_non_versioned_files=false
|
||||
non_dynamic_parameters+=" $name"
|
||||
|
@ -947,22 +989,25 @@ do
|
|||
echo " Possible values:"
|
||||
echo " - dotnet - the Microsoft.NETCore.App shared runtime"
|
||||
echo " - aspnetcore - the Microsoft.AspNetCore.App shared runtime"
|
||||
echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
|
||||
echo " -SkipNonVersionedFiles"
|
||||
echo " --dry-run,-DryRun Do not perform installation. Display download link."
|
||||
echo " --no-path, -NoPath Do not set PATH for the current process."
|
||||
echo " --verbose,-Verbose Display diagnostics information."
|
||||
echo " --azure-feed,-AzureFeed Azure feed location. Defaults to $azure_feed, This parameter typically is not changed by the user."
|
||||
echo " --uncached-feed,-UncachedFeed Uncached feed location. This parameter typically is not changed by the user."
|
||||
echo " --no-cdn,-NoCdn Disable downloading from the Azure CDN, and use the uncached feed directly."
|
||||
echo " --feed-credential,-FeedCredential Azure feed shared access token. This parameter typically is not specified."
|
||||
echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
|
||||
echo " -SkipNonVersionedFiles"
|
||||
echo " --no-cdn,-NoCdn Disable downloading from the Azure CDN, and use the uncached feed directly."
|
||||
echo " --jsonfile <JSONFILE> Determines the SDK version from a user specified global.json file."
|
||||
echo " Note: global.json must have a value for 'SDK:Version'"
|
||||
echo " --runtime-id Installs the .NET Tools for the given platform (use linux-x64 for portable linux)."
|
||||
echo " -RuntimeId"
|
||||
echo " -?,--?,-h,--help,-Help Shows this help message"
|
||||
echo ""
|
||||
echo "Obsolete parameters:"
|
||||
echo " --shared-runtime The recommended alternative is '--runtime dotnet'."
|
||||
echo " -SharedRuntime Installs just the shared runtime bits, not the entire SDK."
|
||||
echo " This parameter is obsolete and may be removed in a future version of this script."
|
||||
echo " Installs just the shared runtime bits, not the entire SDK."
|
||||
echo ""
|
||||
echo "Install Location:"
|
||||
echo " Location is chosen in following order:"
|
||||
|
|
|
@ -26,7 +26,6 @@ const fs_1 = require("fs");
|
|||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
const semver = __importStar(require("semver"));
|
||||
const util = __importStar(require("util"));
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
if (!tempDirectory) {
|
||||
let baseLocation;
|
||||
|
@ -73,7 +72,7 @@ class DotnetCoreInstaller {
|
|||
console.log('Using cached tool');
|
||||
}
|
||||
// Need to set this so that .NET Core global tools find the right locations.
|
||||
core.exportVariable('DOTNET_ROOT', path.join(toolPath, '../..'));
|
||||
core.exportVariable('DOTNET_ROOT', toolPath);
|
||||
// Prepend the tools path. instructs the agent to prepend for future tasks
|
||||
core.addPath(toolPath);
|
||||
});
|
||||
|
@ -175,39 +174,29 @@ class DotnetCoreInstaller {
|
|||
getDownloadUrls(osSuffixes, version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let downloadUrls = [];
|
||||
let releasesJSON = yield this.getReleasesJson();
|
||||
core.debug('Releases: ' + releasesJSON);
|
||||
let releasesInfo = JSON.parse(yield releasesJSON.readBody());
|
||||
const httpCallbackClient = new httpClient.HttpClient('actions/setup-dotnet', [], {});
|
||||
const releasesJsonUrl = yield this.getReleasesJsonUrl(httpCallbackClient, version.split('.'));
|
||||
let releasesJSON = yield httpCallbackClient.get(releasesJsonUrl);
|
||||
let releasesInfo = JSON.parse(yield releasesJSON.readBody())['releases'];
|
||||
releasesInfo = releasesInfo.filter((releaseInfo) => {
|
||||
return (releaseInfo['version-sdk'] === version ||
|
||||
releaseInfo['version-sdk-display'] === version);
|
||||
return (releaseInfo['sdk']['version'] === version ||
|
||||
releaseInfo['sdk']['version-display'] === version);
|
||||
});
|
||||
if (releasesInfo.length != 0) {
|
||||
let release = releasesInfo[0];
|
||||
let blobUrl = release['blob-sdk'];
|
||||
let dlcUrl = release['dlc--sdk'];
|
||||
let fileName = release['sdk-' + osSuffixes[0]]
|
||||
? release['sdk-' + osSuffixes[0]]
|
||||
: release['sdk-' + osSuffixes[1]];
|
||||
if (!!fileName) {
|
||||
fileName = fileName.trim();
|
||||
// For some latest version, the filename itself can be full download url.
|
||||
// Do a very basic check for url(instead of regex) as the url is only for downloading and
|
||||
// is coming from .net core releases json and not some ransom user input
|
||||
if (fileName.toLowerCase().startsWith('https://')) {
|
||||
downloadUrls.push(fileName);
|
||||
let files = release['sdk']['files'];
|
||||
files = files.filter((file) => {
|
||||
if (file['rid'] == osSuffixes[0] || file['rid'] == osSuffixes[1]) {
|
||||
return (file['url'].endsWith('.zip') || file['url'].endsWith('.tar.gz'));
|
||||
}
|
||||
});
|
||||
if (files.length > 0) {
|
||||
files.forEach((file) => {
|
||||
downloadUrls.push(file['url']);
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (!!blobUrl) {
|
||||
downloadUrls.push(util.format('%s%s', blobUrl.trim(), fileName));
|
||||
}
|
||||
if (!!dlcUrl) {
|
||||
downloadUrls.push(util.format('%s%s', dlcUrl.trim(), fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw `The specified version's download links are not correctly formed in the supported versions document => ${DotNetCoreReleasesUrl}`;
|
||||
throw `The specified version's download links are not correctly formed in the supported versions document => ${releasesJsonUrl}`;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -221,9 +210,23 @@ class DotnetCoreInstaller {
|
|||
return downloadUrls;
|
||||
});
|
||||
}
|
||||
getReleasesJson() {
|
||||
var httpCallbackClient = new httpClient.HttpClient('setup-dotnet', [], {});
|
||||
return httpCallbackClient.get(DotNetCoreReleasesUrl);
|
||||
getReleasesJsonUrl(httpCallbackClient, versionParts) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const releasesIndex = yield httpCallbackClient.get(DotNetCoreIndexUrl);
|
||||
let releasesInfo = JSON.parse(yield releasesIndex.readBody())['releases-index'];
|
||||
releasesInfo = releasesInfo.filter((info) => {
|
||||
// channel-version is the first 2 elements of the version (e.g. 2.1), filter out versions that don't match 2.1.x.
|
||||
const sdkParts = info['channel-version'].split('.');
|
||||
if (versionParts.length >= 2 && versionParts[1] != 'x') {
|
||||
return versionParts[0] == sdkParts[0] && versionParts[1] == sdkParts[1];
|
||||
}
|
||||
return versionParts[0] == sdkParts[0];
|
||||
});
|
||||
if (releasesInfo.length === 0) {
|
||||
throw `Could not find info for version ${versionParts.join('.')} at ${DotNetCoreIndexUrl}`;
|
||||
}
|
||||
return releasesInfo[0]['releases.json'];
|
||||
});
|
||||
}
|
||||
getFallbackDownloadUrls(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
|
@ -306,4 +309,4 @@ class DotnetCoreInstaller {
|
|||
}
|
||||
}
|
||||
exports.DotnetCoreInstaller = DotnetCoreInstaller;
|
||||
const DotNetCoreReleasesUrl = 'https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases.json';
|
||||
const DotNetCoreIndexUrl = 'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json';
|
||||
|
|
|
@ -26,6 +26,7 @@ function run() {
|
|||
// Version is optional. If supplied, install / use from the tool cache
|
||||
// If not supplied then task is still used to setup proxy, auth, etc...
|
||||
//
|
||||
console.log(`::warning::Use the v1 tag to get the last version, master may contain breaking changes and will not contain any required packages in the future. i.e. actions/setup-dotnet@v1`);
|
||||
let version = core.getInput('version');
|
||||
if (!version) {
|
||||
version = core.getInput('dotnet-version');
|
||||
|
|
|
@ -59,7 +59,7 @@ export class DotnetCoreInstaller {
|
|||
}
|
||||
|
||||
// Need to set this so that .NET Core global tools find the right locations.
|
||||
core.exportVariable('DOTNET_ROOT', path.join(toolPath, '../..'));
|
||||
core.exportVariable('DOTNET_ROOT', toolPath);
|
||||
|
||||
// Prepend the tools path. instructs the agent to prepend for future tasks
|
||||
core.addPath(toolPath);
|
||||
|
@ -187,43 +187,46 @@ export class DotnetCoreInstaller {
|
|||
version: string
|
||||
): Promise<string[]> {
|
||||
let downloadUrls: string[] = [];
|
||||
let releasesJSON = await this.getReleasesJson();
|
||||
core.debug('Releases: ' + releasesJSON);
|
||||
|
||||
let releasesInfo = JSON.parse(await releasesJSON.readBody());
|
||||
const httpCallbackClient = new httpClient.HttpClient(
|
||||
'actions/setup-dotnet',
|
||||
[],
|
||||
{}
|
||||
);
|
||||
const releasesJsonUrl: string = await this.getReleasesJsonUrl(
|
||||
httpCallbackClient,
|
||||
version.split('.')
|
||||
);
|
||||
|
||||
let releasesJSON = await httpCallbackClient.get(releasesJsonUrl);
|
||||
|
||||
let releasesInfo: any[] = JSON.parse(await releasesJSON.readBody())[
|
||||
'releases'
|
||||
];
|
||||
releasesInfo = releasesInfo.filter((releaseInfo: any) => {
|
||||
return (
|
||||
releaseInfo['version-sdk'] === version ||
|
||||
releaseInfo['version-sdk-display'] === version
|
||||
releaseInfo['sdk']['version'] === version ||
|
||||
releaseInfo['sdk']['version-display'] === version
|
||||
);
|
||||
});
|
||||
|
||||
if (releasesInfo.length != 0) {
|
||||
let release = releasesInfo[0];
|
||||
let blobUrl: string = release['blob-sdk'];
|
||||
let dlcUrl: string = release['dlc--sdk'];
|
||||
let fileName: string = release['sdk-' + osSuffixes[0]]
|
||||
? release['sdk-' + osSuffixes[0]]
|
||||
: release['sdk-' + osSuffixes[1]];
|
||||
let files: any[] = release['sdk']['files'];
|
||||
files = files.filter((file: any) => {
|
||||
if (file['rid'] == osSuffixes[0] || file['rid'] == osSuffixes[1]) {
|
||||
return (
|
||||
file['url'].endsWith('.zip') || file['url'].endsWith('.tar.gz')
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if (!!fileName) {
|
||||
fileName = fileName.trim();
|
||||
// For some latest version, the filename itself can be full download url.
|
||||
// Do a very basic check for url(instead of regex) as the url is only for downloading and
|
||||
// is coming from .net core releases json and not some ransom user input
|
||||
if (fileName.toLowerCase().startsWith('https://')) {
|
||||
downloadUrls.push(fileName);
|
||||
if (files.length > 0) {
|
||||
files.forEach((file: any) => {
|
||||
downloadUrls.push(file['url']);
|
||||
});
|
||||
} else {
|
||||
if (!!blobUrl) {
|
||||
downloadUrls.push(util.format('%s%s', blobUrl.trim(), fileName));
|
||||
}
|
||||
|
||||
if (!!dlcUrl) {
|
||||
downloadUrls.push(util.format('%s%s', dlcUrl.trim(), fileName));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw `The specified version's download links are not correctly formed in the supported versions document => ${DotNetCoreReleasesUrl}`;
|
||||
throw `The specified version's download links are not correctly formed in the supported versions document => ${releasesJsonUrl}`;
|
||||
}
|
||||
} else {
|
||||
console.log(
|
||||
|
@ -241,9 +244,30 @@ export class DotnetCoreInstaller {
|
|||
return downloadUrls;
|
||||
}
|
||||
|
||||
private getReleasesJson(): Promise<HttpClientResponse> {
|
||||
var httpCallbackClient = new httpClient.HttpClient('setup-dotnet', [], {});
|
||||
return httpCallbackClient.get(DotNetCoreReleasesUrl);
|
||||
private async getReleasesJsonUrl(
|
||||
httpCallbackClient: httpClient.HttpClient,
|
||||
versionParts: string[]
|
||||
): Promise<string> {
|
||||
const releasesIndex: HttpClientResponse = await httpCallbackClient.get(
|
||||
DotNetCoreIndexUrl
|
||||
);
|
||||
let releasesInfo: any[] = JSON.parse(await releasesIndex.readBody())[
|
||||
'releases-index'
|
||||
];
|
||||
releasesInfo = releasesInfo.filter((info: any) => {
|
||||
// channel-version is the first 2 elements of the version (e.g. 2.1), filter out versions that don't match 2.1.x.
|
||||
const sdkParts: string[] = info['channel-version'].split('.');
|
||||
if (versionParts.length >= 2 && versionParts[1] != 'x') {
|
||||
return versionParts[0] == sdkParts[0] && versionParts[1] == sdkParts[1];
|
||||
}
|
||||
return versionParts[0] == sdkParts[0];
|
||||
});
|
||||
if (releasesInfo.length === 0) {
|
||||
throw `Could not find info for version ${versionParts.join(
|
||||
'.'
|
||||
)} at ${DotNetCoreIndexUrl}`;
|
||||
}
|
||||
return releasesInfo[0]['releases.json'];
|
||||
}
|
||||
|
||||
private async getFallbackDownloadUrls(version: string): Promise<string[]> {
|
||||
|
@ -350,5 +374,5 @@ export class DotnetCoreInstaller {
|
|||
private arch: string;
|
||||
}
|
||||
|
||||
const DotNetCoreReleasesUrl: string =
|
||||
'https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases.json';
|
||||
const DotNetCoreIndexUrl: string =
|
||||
'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json';
|
||||
|
|
|
@ -9,6 +9,10 @@ async function run() {
|
|||
// Version is optional. If supplied, install / use from the tool cache
|
||||
// If not supplied then task is still used to setup proxy, auth, etc...
|
||||
//
|
||||
console.log(
|
||||
`::warning::Use the v1 tag to get the last version, master may contain breaking changes and will not contain any required packages in the future. i.e. actions/setup-dotnet@v1`
|
||||
);
|
||||
|
||||
let version = core.getInput('version');
|
||||
if (!version) {
|
||||
version = core.getInput('dotnet-version');
|
||||
|
|
Loading…
Reference in New Issue