Merge remote-tracking branch 'upstream/main' into dependabot/npm_and_yarn/node-notifier-8.0.1
This commit is contained in:
commit
b25fa305a3
|
@ -0,0 +1 @@
|
|||
* @actions/virtual-environments-owners
|
|
@ -2,22 +2,31 @@
|
|||
name: Bug report
|
||||
about: Create a bug report
|
||||
title: ''
|
||||
labels: ''
|
||||
labels: bug, needs triage
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### Description
|
||||
**Description:**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
<!--
|
||||
* Please share short description of the problem
|
||||
-->
|
||||
**Task version:**
|
||||
Specify the task version
|
||||
|
||||
### Details
|
||||
**Platform:**
|
||||
- [ ] Ubuntu
|
||||
- [ ] macOS
|
||||
- [ ] Windows
|
||||
|
||||
<!--
|
||||
* Include the relevant yaml, platform, and dotnet versions in use
|
||||
* If an error occurred on a public action, please share a link
|
||||
* Include any error messages received in text (search does not work for images)
|
||||
* Was this a regression from previous behavior?
|
||||
-->
|
||||
**Runner type:**
|
||||
- [ ] Hosted
|
||||
- [ ] Self-hosted
|
||||
|
||||
**Repro steps:**
|
||||
A description with steps to reproduce the issue. If your have a public example or repo to share, please provide the link.
|
||||
|
||||
**Expected behavior:**
|
||||
A description of what you expected to happen.
|
||||
|
||||
**Actual behavior:**
|
||||
A description of what is actually happening.
|
|
@ -1,4 +1,4 @@
|
|||
blank_issues_enabled: true
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: .NET issues
|
||||
url: https://github.com/dotnet/runtime#filing-issues
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: feature request, needs triage
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
**Description:**
|
||||
Describe your proposal.
|
||||
|
||||
**Justification:**
|
||||
Justification or a use case for your proposal.
|
||||
|
||||
**Are you willing to submit a PR?**
|
||||
<!--- We accept contributions! -->
|
|
@ -0,0 +1,9 @@
|
|||
**Description:**
|
||||
Describe your changes.
|
||||
|
||||
**Related issue:**
|
||||
Add link to the related issue.
|
||||
|
||||
**Check list:**
|
||||
- [ ] Mark if documentation changes are required.
|
||||
- [ ] Mark if tests were added or updated to cover the changes.
|
|
@ -0,0 +1,28 @@
|
|||
name: Release new action version
|
||||
on:
|
||||
release:
|
||||
types: [released]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
TAG_NAME:
|
||||
description: 'Tag name that the major tag will point to'
|
||||
required: true
|
||||
|
||||
env:
|
||||
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
update_tag:
|
||||
name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} changes
|
||||
environment:
|
||||
name: releaseNewActionVersion
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Update the ${{ env.TAG_NAME }} tag
|
||||
id: update-major-tag
|
||||
uses: actions/publish-action@v0.1.0
|
||||
with:
|
||||
source-tag: ${{ env.TAG_NAME }}
|
||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
|
@ -0,0 +1,37 @@
|
|||
name: Validate dotnet
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- releases/*
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
jobs:
|
||||
setup-version:
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
dotnet-version: ['2.1', '2.2', '3.0', '3.1', '5.0']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Clear toolcache
|
||||
shell: pwsh
|
||||
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||
- name: Setup dotnet ${{ matrix.dotnet-version }}
|
||||
uses: ./
|
||||
with:
|
||||
dotnet-version: ${{ matrix.dotnet-version }}
|
||||
- name: Check installed version
|
||||
shell: pwsh
|
||||
run: |
|
||||
$version = & dotnet --version
|
||||
Write-Host "Installed version: $version"
|
||||
if (-not $version.StartsWith("${{ matrix.dotnet-version }}")) { throw "Unexpected version" }
|
|
@ -2,10 +2,14 @@ name: Main workflow
|
|||
|
||||
on:
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- releases/*
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
@ -29,7 +33,7 @@ jobs:
|
|||
if: runner.os != 'windows'
|
||||
run: __tests__/verify-no-unstaged-changes.sh
|
||||
|
||||
test:
|
||||
test-setup-full-version:
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
@ -38,25 +42,9 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Clear tool cache (macOS)
|
||||
if: runner.os == 'macos'
|
||||
run: |
|
||||
echo $PATH
|
||||
dotnet --info
|
||||
rm -rf "/Users/runner/.dotnet"
|
||||
- name: Clear tool cache (Ubuntu)
|
||||
if: runner.os == 'linux'
|
||||
run: |
|
||||
echo $PATH
|
||||
dotnet --info
|
||||
rm -rf "/usr/share/dotnet"
|
||||
- name: Clear tool cache (Windows)
|
||||
if: runner.os == 'windows'
|
||||
run: |
|
||||
echo $env:PATH
|
||||
dotnet --info
|
||||
Remove-Item $env:LocalAppData\Microsoft\dotnet/* -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item "$env:ProgramFiles\dotnet/*" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
- name: Clear toolcache
|
||||
shell: pwsh
|
||||
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||
# Side-by-side install of 2.2 and 3.1 used for the test project
|
||||
- name: Setup dotnet 2.2.402
|
||||
uses: ./
|
||||
|
@ -70,70 +58,86 @@ jobs:
|
|||
source-url: https://api.nuget.org/v3/index.json
|
||||
env:
|
||||
NUGET_AUTH_TOKEN: NOTATOKEN
|
||||
- name: Verify nuget config file
|
||||
shell: pwsh
|
||||
run: |
|
||||
if (-Not (Test-Path "../nuget.config")) { throw "nuget file not generated correctly" }
|
||||
- name: Verify dotnet
|
||||
if: runner.os != 'windows'
|
||||
run: __tests__/verify-dotnet.sh 3.1.201 2.2.402
|
||||
- name: Verify dotnet (Windows)
|
||||
if: runner.os == 'windows'
|
||||
shell: pwsh
|
||||
run: __tests__/verify-dotnet.ps1 3.1.201 2.2.402
|
||||
|
||||
# Set new cache before 2 digit install
|
||||
- name: Set new tool cache (macOS)
|
||||
if: runner.os == 'macos'
|
||||
run: |
|
||||
echo "DOTNET_INSTALL_DIR=/Users/runner/.dotnet2" >> $GITHUB_ENV
|
||||
- name: Set new tool cache (Ubuntu)
|
||||
if: runner.os == 'linux'
|
||||
run: |
|
||||
echo "DOTNET_INSTALL_DIR=/home/runner/.dotnet2" >> $GITHUB_ENV
|
||||
- name: Set new tool cache (Windows)
|
||||
if: runner.os == 'windows'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "DOTNET_INSTALL_DIR=$LocalAppData\Microsoft\dotnet2" >> $GITHUB_ENV
|
||||
test-setup-without-patch-version:
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Clear toolcache
|
||||
shell: pwsh
|
||||
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||
# 2.0, 3.0, 5.0 needs to be in single quotes to interpret as a string instead of as an integer
|
||||
- name: Setup dotnet '2.0'
|
||||
- name: Setup dotnet '3.1'
|
||||
uses: ./
|
||||
with:
|
||||
dotnet-version: '2.0'
|
||||
dotnet-version: '3.1'
|
||||
- name: Setup dotnet '2.2'
|
||||
uses: ./
|
||||
with:
|
||||
dotnet-version: '2.2'
|
||||
- name: Verify dotnet
|
||||
shell: pwsh
|
||||
run: __tests__/verify-dotnet.ps1 3.1 2.2
|
||||
|
||||
test-setup-latest-patch-version:
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Clear toolcache
|
||||
shell: pwsh
|
||||
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||
- name: Setup dotnet 3.1.x
|
||||
uses: ./
|
||||
with:
|
||||
dotnet-version: 3.1.x
|
||||
- name: Setup dotnet 2.2.x
|
||||
uses: ./
|
||||
with:
|
||||
dotnet-version: 2.2.x
|
||||
- name: Verify dotnet
|
||||
shell: pwsh
|
||||
run: __tests__/verify-dotnet.ps1 3.1 2.2
|
||||
|
||||
# Clear cache before .x version install
|
||||
- name: Set new tool cache (macOS)
|
||||
if: runner.os == 'macos'
|
||||
run: |
|
||||
echo "DOTNET_INSTALL_DIR=/Users/runner/.dotnet3" >> $GITHUB_ENV
|
||||
- name: Set new tool cache (Ubuntu)
|
||||
if: runner.os == 'linux'
|
||||
run: |
|
||||
echo "DOTNET_INSTALL_DIR=/home/runner/.dotnet3" >> $GITHUB_ENV
|
||||
- name: Set new tool cache (Windows)
|
||||
if: runner.os == 'windows'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "DOTNET_INSTALL_DIR=$LocalAppData\Microsoft\dotnet3" >> $GITHUB_ENV
|
||||
- name: Setup dotnet 2.0.x
|
||||
test-setup-with-wildcard:
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Clear toolcache
|
||||
shell: pwsh
|
||||
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||
- name: Setup dotnet 3.1.*
|
||||
uses: ./
|
||||
with:
|
||||
dotnet-version: 2.0.x
|
||||
|
||||
# Clear cache before .* version install
|
||||
- name: Set new tool cache (macOS)
|
||||
if: runner.os == 'macos'
|
||||
run: |
|
||||
echo "DOTNET_INSTALL_DIR=/Users/runner/.dotnet4" >> $GITHUB_ENV
|
||||
- name: Set new tool cache (Ubuntu)
|
||||
if: runner.os == 'linux'
|
||||
run: |
|
||||
echo "DOTNET_INSTALL_DIR=/home/runner/.dotnet4" >> $GITHUB_ENV
|
||||
- name: Set new tool cache (Windows)
|
||||
if: runner.os == 'windows'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "DOTNET_INSTALL_DIR=$LocalAppData\Microsoft\dotnet4" >> $GITHUB_ENV
|
||||
- name: Setup dotnet 2.0.*
|
||||
dotnet-version: 3.1.*
|
||||
- name: Setup dotnet 2.2.*
|
||||
uses: ./
|
||||
with:
|
||||
dotnet-version: 2.0.*
|
||||
dotnet-version: 2.2.*
|
||||
- name: Verify dotnet
|
||||
shell: pwsh
|
||||
run: __tests__/verify-dotnet.ps1 3.1 2.2
|
||||
|
||||
test-proxy:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
35
README.md
35
README.md
|
@ -13,7 +13,7 @@ This action sets up a [dotnet core cli](https://github.com/dotnet/cli) environme
|
|||
Please Note: GitHub hosted runners have some versions of the .NET SDK
|
||||
preinstalled. Installed versions are subject to change. Please refer to the
|
||||
documentation
|
||||
[software installed on github hosted runners](https://help.github.com/en/actions/reference/software-installed-on-github-hosted-runners)
|
||||
[software installed on github hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software)
|
||||
for .NET SDK versions that are currently available.
|
||||
|
||||
# Usage
|
||||
|
@ -23,13 +23,24 @@ See [action.yml](action.yml)
|
|||
Basic:
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel
|
||||
- run: dotnet build <my project>
|
||||
```
|
||||
|
||||
Preview version:
|
||||
```yml
|
||||
steps:
|
||||
- uses: actions@checkout@v2
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '6.0.x'
|
||||
include-prerelease: true
|
||||
- run: dotnet build <my project>
|
||||
```
|
||||
|
||||
Matrix Testing:
|
||||
```yaml
|
||||
jobs:
|
||||
|
@ -37,7 +48,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
dotnet: [ '2.2.103', '3.0', '3.1.x' ]
|
||||
dotnet: [ '2.1.x', '3.1.x', '5.0.x' ]
|
||||
name: Dotnet ${{ matrix.dotnet }} sample
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
@ -59,7 +70,7 @@ jobs:
|
|||
- name: Setup dotnet
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '2.2.103'
|
||||
dotnet-version: '2.1.x'
|
||||
- name: Setup dotnet
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
|
@ -82,10 +93,10 @@ steps:
|
|||
- run: dotnet build <my project>
|
||||
- name: Create the package
|
||||
run: dotnet pack --configuration Release <my project>
|
||||
- name: Publish the package to GPR
|
||||
- name: Publish the package to GPR
|
||||
run: dotnet nuget push <my project>/bin/Release/*.nupkg
|
||||
|
||||
# Authticates packages to push to Azure Artifacts
|
||||
# Authenticates packages to push to Azure Artifacts
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
source-url: https://pkgs.dev.azure.com/<your-organization>/_packaging/<your-feed-name>/nuget/v3/index.json
|
||||
|
@ -93,6 +104,16 @@ steps:
|
|||
NUGET_AUTH_TOKEN: ${{secrets.AZURE_DEVOPS_PAT}} # Note, create a secret with this name in Settings
|
||||
- name: Publish the package to Azure Artifacts
|
||||
run: dotnet nuget push <my project>/bin/Release/*.nupkg
|
||||
|
||||
# Authenticates packages to push to nuget.org.
|
||||
# It's only the way to push a package to nuget.org feed for macOS/Linux machines due to API key config store limitations.
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: 3.1.x
|
||||
- name: Publish the package to nuget.org
|
||||
run: dotnet nuget push */bin/Release/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
|
||||
env:
|
||||
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
|
||||
```
|
||||
|
||||
## Environment Variables to use with dotnet
|
||||
|
@ -113,7 +134,7 @@ build:
|
|||
- uses: actions/checkout@main
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '3.1.100' # SDK Version to use.
|
||||
dotnet-version: '3.1.x' # SDK Version to use.
|
||||
```
|
||||
|
||||
# License
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
$dotnetPaths = @{
|
||||
Linux = @("/usr/share/dotnet")
|
||||
macOS = @("$env:HOME/.dotnet")
|
||||
Windows = @("$env:ProgramFiles\dotnet/*",
|
||||
"$env:LocalAppData\Microsoft\dotnet/*")
|
||||
}
|
||||
|
||||
foreach ($path in $dotnetPaths[$args[0]]) {
|
||||
if (Test-Path $path) {
|
||||
Write-Host "Clear $path path"
|
||||
Remove-Item $path -Recurse -Force
|
||||
}
|
||||
}
|
|
@ -3,30 +3,34 @@ if (!$args[0])
|
|||
throw "Must supply dotnet version argument"
|
||||
}
|
||||
|
||||
if (-Not (Test-Path "../nuget.config"))
|
||||
{
|
||||
throw "nuget file not generated correctly"
|
||||
}
|
||||
|
||||
$dotnet = Get-Command dotnet | Select-Object -First 1 | ForEach-Object { $_.Path }
|
||||
Write-Host "Found '$dotnet'"
|
||||
|
||||
$version = & $dotnet --version | Out-String | ForEach-Object { $_.Trim() }
|
||||
Write-Host "Version $version"
|
||||
if ($version -ne $args[0])
|
||||
if (-not ($version.StartsWith($args[0].ToString())))
|
||||
{
|
||||
Write-Host "PATH='$env:path'"
|
||||
Write-Host "PATH='$env:PATH'"
|
||||
throw "Unexpected version"
|
||||
}
|
||||
|
||||
if ($args[1])
|
||||
{
|
||||
# SDKs are listed on multiple lines with the path afterwards in square brackets
|
||||
$version = & $dotnet --list-sdks | ForEach-Object { $_.SubString(0, $_.IndexOf('[')).Trim() }
|
||||
Write-Host "Version $version"
|
||||
if (-not ($version -contains $args[1]))
|
||||
$versions = & $dotnet --list-sdks | ForEach-Object { $_.SubString(0, $_.IndexOf('[')).Trim() }
|
||||
Write-Host "Installed versions: $versions"
|
||||
$isInstalledVersion = $false
|
||||
foreach ($version in $versions)
|
||||
{
|
||||
Write-Host "PATH='$env:path'"
|
||||
if ($version.StartsWith($args[1].ToString()))
|
||||
{
|
||||
$isInstalledVersion = $true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (-not $isInstalledVersion)
|
||||
{
|
||||
Write-Host "PATH='$env:PATH'"
|
||||
throw "Unexpected version"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ describe('version tests', () => {
|
|||
);
|
||||
|
||||
each([
|
||||
['3.x', '3.x'],
|
||||
['3.*', '3.*'],
|
||||
['3.1.x', '3.1'],
|
||||
['1.1.*', '1.1'],
|
||||
['2.0', '2.0']
|
||||
|
@ -42,7 +44,6 @@ describe('version tests', () => {
|
|||
'.2.3',
|
||||
'.2.x',
|
||||
'1',
|
||||
'2.x',
|
||||
'*.*.1',
|
||||
'*.1',
|
||||
'*.',
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
name: 'Setup .NET Core SDK'
|
||||
description: 'Set up a specific version of the .NET Core CLI in the PATH and set up authentication to a private NuGet repository'
|
||||
description: 'Used to build and publish .NET source. Set up a specific version of the .NET Core CLI in the PATH and set up authentication to a private NuGet repository'
|
||||
author: 'GitHub'
|
||||
branding:
|
||||
icon: play
|
||||
color: green
|
||||
inputs:
|
||||
dotnet-version:
|
||||
description: 'SDK version to use. Examples: 2.2.104, 3.1, 3.1.x'
|
||||
description: 'Optional SDK version to use. If not provided, will install global.json version when available. Examples: 2.2.104, 3.1, 3.1.x'
|
||||
source-url:
|
||||
description: 'Optional package source for which to set up authentication. Will consult any existing NuGet.config in the root of the repo and provide a temporary NuGet.config using the NUGET_AUTH_TOKEN environment variable as a ClearTextPassword'
|
||||
owner:
|
||||
description: 'Optional OWNER for using packages from GitHub Package Registry organizations/users other than the current repository''s owner. Only used if a GPR URL is also provided in source-url'
|
||||
config-file:
|
||||
description: 'Optional NuGet.config location, if your NuGet.config isn''t located in the root of the repo.'
|
||||
include-prerelease:
|
||||
description: 'Whether prerelease versions should be matched with non-exact versions (for example 5.0.0-preview.6 being matched by 5, 5.0, 5.x or 5.0.x). Defaults to false if not provided.'
|
||||
required: False
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
|
|
|
@ -4840,11 +4840,26 @@ const github = __importStar(__webpack_require__(469));
|
|||
const xmlbuilder = __importStar(__webpack_require__(312));
|
||||
const xmlParser = __importStar(__webpack_require__(989));
|
||||
function configAuthentication(feedUrl, existingFileLocation = '', processRoot = process.cwd()) {
|
||||
const existingNuGetConfig = path.resolve(processRoot, existingFileLocation == '' ? 'nuget.config' : existingFileLocation);
|
||||
const existingNuGetConfig = path.resolve(processRoot, existingFileLocation === ''
|
||||
? getExistingNugetConfig(processRoot)
|
||||
: existingFileLocation);
|
||||
const tempNuGetConfig = path.resolve(processRoot, '../', 'nuget.config');
|
||||
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
|
||||
}
|
||||
exports.configAuthentication = configAuthentication;
|
||||
function isValidKey(key) {
|
||||
return /^[\w\-\.]+$/i.test(key);
|
||||
}
|
||||
function getExistingNugetConfig(processRoot) {
|
||||
const defaultConfigName = 'nuget.config';
|
||||
const configFileNames = fs
|
||||
.readdirSync(processRoot)
|
||||
.filter(filename => filename.toLowerCase() === defaultConfigName);
|
||||
if (configFileNames.length) {
|
||||
return configFileNames[0];
|
||||
}
|
||||
return defaultConfigName;
|
||||
}
|
||||
function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) {
|
||||
console.log(`dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}`);
|
||||
let xml;
|
||||
|
@ -4910,8 +4925,8 @@ function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) {
|
|||
}
|
||||
xml = xml.ele('packageSourceCredentials');
|
||||
sourceKeys.forEach(key => {
|
||||
if (key.indexOf(' ') > -1) {
|
||||
throw new Error("This action currently can't handle source names with spaces. Remove the space from your repo's NuGet.config and try again.");
|
||||
if (!isValidKey(key)) {
|
||||
throw new Error("Source name can contain letters, numbers, and '-', '_', '.' symbols only. Please, fix source name in NuGet.config and try again.");
|
||||
}
|
||||
xml = xml
|
||||
.ele(key)
|
||||
|
@ -7814,14 +7829,18 @@ function run() {
|
|||
core.debug('No version found, trying to find version from global.json');
|
||||
const globalJsonPath = path.join(process.cwd(), 'global.json');
|
||||
if (fs.existsSync(globalJsonPath)) {
|
||||
const globalJson = JSON.parse(fs.readFileSync(globalJsonPath, { encoding: 'utf8' }));
|
||||
const globalJson = JSON.parse(
|
||||
// .trim() is necessary to strip BOM https://github.com/nodejs/node/issues/20649
|
||||
fs.readFileSync(globalJsonPath, { encoding: 'utf8' }).trim());
|
||||
if (globalJson.sdk && globalJson.sdk.version) {
|
||||
version = globalJson.sdk.version;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (version) {
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(version);
|
||||
const includePrerelease = (core.getInput('include-prerelease') || 'false').toLowerCase() ===
|
||||
'true';
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(version, includePrerelease);
|
||||
yield dotnetInstaller.installDotnet();
|
||||
}
|
||||
const sourceUrl = core.getInput('source-url');
|
||||
|
@ -16868,15 +16887,16 @@ class DotNetVersionInfo {
|
|||
this.isExactVersionSet = true;
|
||||
return;
|
||||
}
|
||||
//Note: No support for previews when using generic
|
||||
let parts = version.split('.');
|
||||
const parts = version.split('.');
|
||||
if (parts.length < 2 || parts.length > 3)
|
||||
this.throwInvalidVersionFormat();
|
||||
if (parts.length == 3 && parts[2] !== 'x' && parts[2] !== '*') {
|
||||
this.throwInvalidVersionFormat();
|
||||
}
|
||||
let major = this.getVersionNumberOrThrow(parts[0]);
|
||||
let minor = this.getVersionNumberOrThrow(parts[1]);
|
||||
const major = this.getVersionNumberOrThrow(parts[0]);
|
||||
const minor = ['x', '*'].includes(parts[1])
|
||||
? parts[1]
|
||||
: this.getVersionNumberOrThrow(parts[1]);
|
||||
this.fullversion = major + '.' + minor;
|
||||
}
|
||||
getVersionNumberOrThrow(input) {
|
||||
|
@ -16894,7 +16914,7 @@ class DotNetVersionInfo {
|
|||
}
|
||||
}
|
||||
throwInvalidVersionFormat() {
|
||||
throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*';
|
||||
throw new Error('Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*');
|
||||
}
|
||||
/**
|
||||
* If true exacatly one version should be resolved
|
||||
|
@ -16908,8 +16928,9 @@ class DotNetVersionInfo {
|
|||
}
|
||||
exports.DotNetVersionInfo = DotNetVersionInfo;
|
||||
class DotnetCoreInstaller {
|
||||
constructor(version) {
|
||||
constructor(version, includePrerelease = false) {
|
||||
this.version = version;
|
||||
this.includePrerelease = includePrerelease;
|
||||
}
|
||||
installDotnet() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
|
@ -16997,7 +17018,7 @@ class DotnetCoreInstaller {
|
|||
}
|
||||
console.log(process.env['PATH']);
|
||||
if (resultCode != 0) {
|
||||
throw `Failed to install dotnet ${resultCode}. ${output}`;
|
||||
throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -17016,16 +17037,24 @@ class DotnetCoreInstaller {
|
|||
const releasesResult = releasesResponse.result || {};
|
||||
let releasesInfo = releasesResult['releases'];
|
||||
releasesInfo = releasesInfo.filter((releaseInfo) => {
|
||||
return (semver.satisfies(releaseInfo['sdk']['version'], versionInfo.version()) ||
|
||||
semver.satisfies(releaseInfo['sdk']['version-display'], versionInfo.version()));
|
||||
return (semver.satisfies(releaseInfo['sdk']['version'], versionInfo.version(), {
|
||||
includePrerelease: this.includePrerelease
|
||||
}) ||
|
||||
semver.satisfies(releaseInfo['sdk']['version-display'], versionInfo.version(), {
|
||||
includePrerelease: this.includePrerelease
|
||||
}));
|
||||
});
|
||||
// Exclude versions that are newer than the latest if using not exact
|
||||
let latestSdk = releasesResult['latest-sdk'];
|
||||
releasesInfo = releasesInfo.filter((releaseInfo) => semver.lte(releaseInfo['sdk']['version'], latestSdk));
|
||||
releasesInfo = releasesInfo.filter((releaseInfo) => semver.lte(releaseInfo['sdk']['version'], latestSdk, {
|
||||
includePrerelease: this.includePrerelease
|
||||
}));
|
||||
// Sort for latest version
|
||||
releasesInfo = releasesInfo.sort((a, b) => semver.rcompare(a['sdk']['version'], b['sdk']['version']));
|
||||
releasesInfo = releasesInfo.sort((a, b) => semver.rcompare(a['sdk']['version'], b['sdk']['version'], {
|
||||
includePrerelease: this.includePrerelease
|
||||
}));
|
||||
if (releasesInfo.length == 0) {
|
||||
throw `Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`;
|
||||
throw new Error(`Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`);
|
||||
}
|
||||
let release = releasesInfo[0];
|
||||
return release['sdk']['version'];
|
||||
|
@ -17046,7 +17075,7 @@ class DotnetCoreInstaller {
|
|||
return versionParts[0] == sdkParts[0];
|
||||
});
|
||||
if (releasesInfo.length === 0) {
|
||||
throw `Could not find info for version ${versionParts.join('.')} at ${DotNetCoreIndexUrl}`;
|
||||
throw new Error(`Could not find info for version ${versionParts.join('.')} at ${DotNetCoreIndexUrl}`);
|
||||
}
|
||||
return releasesInfo[0]['releases.json'];
|
||||
});
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -5347,9 +5347,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"y18n": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz",
|
||||
"integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==",
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz",
|
||||
"integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==",
|
||||
"dev": true
|
||||
},
|
||||
"yallist": {
|
||||
|
|
|
@ -13,7 +13,9 @@ export function configAuthentication(
|
|||
) {
|
||||
const existingNuGetConfig: string = path.resolve(
|
||||
processRoot,
|
||||
existingFileLocation == '' ? 'nuget.config' : existingFileLocation
|
||||
existingFileLocation === ''
|
||||
? getExistingNugetConfig(processRoot)
|
||||
: existingFileLocation
|
||||
);
|
||||
|
||||
const tempNuGetConfig: string = path.resolve(
|
||||
|
@ -25,6 +27,21 @@ export function configAuthentication(
|
|||
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
|
||||
}
|
||||
|
||||
function isValidKey(key: string): boolean {
|
||||
return /^[\w\-\.]+$/i.test(key);
|
||||
}
|
||||
|
||||
function getExistingNugetConfig(processRoot: string) {
|
||||
const defaultConfigName = 'nuget.config';
|
||||
const configFileNames = fs
|
||||
.readdirSync(processRoot)
|
||||
.filter(filename => filename.toLowerCase() === defaultConfigName);
|
||||
if (configFileNames.length) {
|
||||
return configFileNames[0];
|
||||
}
|
||||
return defaultConfigName;
|
||||
}
|
||||
|
||||
function writeFeedToFile(
|
||||
feedUrl: string,
|
||||
existingFileLocation: string,
|
||||
|
@ -109,9 +126,9 @@ function writeFeedToFile(
|
|||
xml = xml.ele('packageSourceCredentials');
|
||||
|
||||
sourceKeys.forEach(key => {
|
||||
if (key.indexOf(' ') > -1) {
|
||||
if (!isValidKey(key)) {
|
||||
throw new Error(
|
||||
"This action currently can't handle source names with spaces. Remove the space from your repo's NuGet.config and try again."
|
||||
"Source name can contain letters, numbers, and '-', '_', '.' symbols only. Please, fix source name in NuGet.config and try again."
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,7 @@ export class DotNetVersionInfo {
|
|||
return;
|
||||
}
|
||||
|
||||
//Note: No support for previews when using generic
|
||||
let parts: string[] = version.split('.');
|
||||
const parts: string[] = version.split('.');
|
||||
|
||||
if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat();
|
||||
|
||||
|
@ -38,8 +37,10 @@ export class DotNetVersionInfo {
|
|||
this.throwInvalidVersionFormat();
|
||||
}
|
||||
|
||||
let major = this.getVersionNumberOrThrow(parts[0]);
|
||||
let minor = this.getVersionNumberOrThrow(parts[1]);
|
||||
const major = this.getVersionNumberOrThrow(parts[0]);
|
||||
const minor = ['x', '*'].includes(parts[1])
|
||||
? parts[1]
|
||||
: this.getVersionNumberOrThrow(parts[1]);
|
||||
|
||||
this.fullversion = major + '.' + minor;
|
||||
}
|
||||
|
@ -60,7 +61,9 @@ export class DotNetVersionInfo {
|
|||
}
|
||||
|
||||
private throwInvalidVersionFormat() {
|
||||
throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*';
|
||||
throw new Error(
|
||||
'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,8 +79,9 @@ export class DotNetVersionInfo {
|
|||
}
|
||||
|
||||
export class DotnetCoreInstaller {
|
||||
constructor(version: string) {
|
||||
constructor(version: string, includePrerelease: boolean = false) {
|
||||
this.version = version;
|
||||
this.includePrerelease = includePrerelease;
|
||||
}
|
||||
|
||||
public async installDotnet() {
|
||||
|
@ -187,7 +191,7 @@ export class DotnetCoreInstaller {
|
|||
console.log(process.env['PATH']);
|
||||
|
||||
if (resultCode != 0) {
|
||||
throw `Failed to install dotnet ${resultCode}. ${output}`;
|
||||
throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,13 +216,15 @@ export class DotnetCoreInstaller {
|
|||
let releasesInfo: any[] = releasesResult['releases'];
|
||||
releasesInfo = releasesInfo.filter((releaseInfo: any) => {
|
||||
return (
|
||||
semver.satisfies(
|
||||
releaseInfo['sdk']['version'],
|
||||
versionInfo.version()
|
||||
) ||
|
||||
semver.satisfies(releaseInfo['sdk']['version'], versionInfo.version(), {
|
||||
includePrerelease: this.includePrerelease
|
||||
}) ||
|
||||
semver.satisfies(
|
||||
releaseInfo['sdk']['version-display'],
|
||||
versionInfo.version()
|
||||
versionInfo.version(),
|
||||
{
|
||||
includePrerelease: this.includePrerelease
|
||||
}
|
||||
)
|
||||
);
|
||||
});
|
||||
|
@ -227,16 +233,22 @@ export class DotnetCoreInstaller {
|
|||
let latestSdk: string = releasesResult['latest-sdk'];
|
||||
|
||||
releasesInfo = releasesInfo.filter((releaseInfo: any) =>
|
||||
semver.lte(releaseInfo['sdk']['version'], latestSdk)
|
||||
semver.lte(releaseInfo['sdk']['version'], latestSdk, {
|
||||
includePrerelease: this.includePrerelease
|
||||
})
|
||||
);
|
||||
|
||||
// Sort for latest version
|
||||
releasesInfo = releasesInfo.sort((a, b) =>
|
||||
semver.rcompare(a['sdk']['version'], b['sdk']['version'])
|
||||
semver.rcompare(a['sdk']['version'], b['sdk']['version'], {
|
||||
includePrerelease: this.includePrerelease
|
||||
})
|
||||
);
|
||||
|
||||
if (releasesInfo.length == 0) {
|
||||
throw `Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`;
|
||||
throw new Error(
|
||||
`Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`
|
||||
);
|
||||
}
|
||||
|
||||
let release = releasesInfo[0];
|
||||
|
@ -264,15 +276,18 @@ export class DotnetCoreInstaller {
|
|||
});
|
||||
|
||||
if (releasesInfo.length === 0) {
|
||||
throw `Could not find info for version ${versionParts.join(
|
||||
'.'
|
||||
)} at ${DotNetCoreIndexUrl}`;
|
||||
throw new Error(
|
||||
`Could not find info for version ${versionParts.join(
|
||||
'.'
|
||||
)} at ${DotNetCoreIndexUrl}`
|
||||
);
|
||||
}
|
||||
|
||||
return releasesInfo[0]['releases.json'];
|
||||
}
|
||||
|
||||
private version: string;
|
||||
private includePrerelease: boolean;
|
||||
}
|
||||
|
||||
const DotNetCoreIndexUrl: string =
|
||||
|
|
|
@ -20,7 +20,8 @@ export async function run() {
|
|||
const globalJsonPath = path.join(process.cwd(), 'global.json');
|
||||
if (fs.existsSync(globalJsonPath)) {
|
||||
const globalJson = JSON.parse(
|
||||
fs.readFileSync(globalJsonPath, {encoding: 'utf8'})
|
||||
// .trim() is necessary to strip BOM https://github.com/nodejs/node/issues/20649
|
||||
fs.readFileSync(globalJsonPath, {encoding: 'utf8'}).trim()
|
||||
);
|
||||
if (globalJson.sdk && globalJson.sdk.version) {
|
||||
version = globalJson.sdk.version;
|
||||
|
@ -29,7 +30,14 @@ export async function run() {
|
|||
}
|
||||
|
||||
if (version) {
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(version);
|
||||
const includePrerelease: boolean =
|
||||
(core.getInput('include-prerelease') || 'false').toLowerCase() ===
|
||||
'true';
|
||||
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||
version,
|
||||
includePrerelease
|
||||
);
|
||||
await dotnetInstaller.installDotnet();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue