Compare commits

..

5 Commits
v4.1.0 ... v3

Author SHA1 Message Date
aparnajyothi-y
55ec9447dd V3 - Update the file name publish-immutable-actions to publish-immutable-action (#630)
* add Publish Immutable Action

* file name update
2025-04-17 13:21:33 -05:00
aparnajyothi-y
70918d1a1f add Publish Immutable Action (#627) 2025-04-17 09:04:29 -05:00
mahabaleshwars
a6d1e7b915 update actions/cache (#620) 2025-04-13 22:10:06 -05:00
Zachary Taylor
b2ace4b12f v3 - Remove azureedge.net fallback logic and update install scripts (#573)
* Remove logic for azureedge.net fallback in preparation for install script changes (v3)

* remove fallback in index.js

* fix ci

* add updated install scripts

* Update e2e-tests.yml

* Update e2e-tests.yml to remove outdated URLs in workflow

* Fix audit issues

* Revert audit fixes for heap memory failures

---------

Co-authored-by: HarithaVattikuti <73516759+HarithaVattikuti@users.noreply.github.com>
2025-02-20 12:23:35 -06:00
HarithaVattikuti
ea9897a6e5 V3 - Use new .NET CDN URLs and update to latest install scripts (#567)
* Update new cdn

* new cdn changes

* update latest install scripts

* Format install scripts

* Fix Ubuntu-latest issues

* Fallback logic

* Format check

* Update signed version
2024-12-26 15:42:59 -06:00
92 changed files with 38536 additions and 20782 deletions

View File

@@ -15,5 +15,3 @@ jobs:
call-basic-validation: call-basic-validation:
name: Basic validation name: Basic validation
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
with:
node-version: '20'

View File

@@ -15,5 +15,3 @@ jobs:
call-check-dist: call-check-dist:
name: Check dist/ name: Check dist/
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
with:
node-version: '20'

View File

@@ -17,10 +17,10 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -40,10 +40,10 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macos-13]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -69,10 +69,10 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -94,10 +94,10 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macos-13]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -114,10 +114,10 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -138,10 +138,10 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -159,10 +159,10 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -183,10 +183,10 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -209,10 +209,10 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -229,40 +229,15 @@ jobs:
shell: pwsh shell: pwsh
run: __tests__/verify-dotnet.ps1 -Patterns "^2.2" run: __tests__/verify-dotnet.ps1 -Patterns "^2.2"
test-global-json-with-comments:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Clear toolcache
shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
- name: Write global.json
shell: bash
run: |
mkdir subdirectory
echo '/* should support comments */ {"sdk":{"version": "2.2.207","rollForward": "latestFeature"}} // should support comments' > ./subdirectory/global.json
- name: Setup dotnet
uses: ./
with:
global-json-file: ./subdirectory/global.json
- name: Verify dotnet
shell: pwsh
run: __tests__/verify-dotnet.ps1 -Patterns "^2.2"
test-setup-with-dotnet-quality: test-setup-with-dotnet-quality:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -281,12 +256,12 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macos-latest]
env: env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -312,12 +287,12 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macos-latest]
env: env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -341,10 +316,10 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -367,10 +342,10 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -393,7 +368,7 @@ jobs:
test-proxy: test-proxy:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
container: container:
image: ubuntu:22.04 image: ubuntu:latest
options: --dns 127.0.0.1 options: --dns 127.0.0.1
services: services:
squid-proxy: squid-proxy:
@@ -405,7 +380,7 @@ jobs:
http_proxy: http://squid-proxy:3128 http_proxy: http://squid-proxy:3128
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Install Powershell - name: Install Powershell
run: | run: |
apt-get update apt-get update
@@ -431,13 +406,13 @@ jobs:
__tests__/verify-dotnet.ps1 -Patterns "^6.0" -CheckNugetConfig __tests__/verify-dotnet.ps1 -Patterns "^6.0" -CheckNugetConfig
test-bypass-proxy: test-bypass-proxy:
runs-on: ubuntu-latest runs-on: ubuntu-22.04
env: env:
https_proxy: http://no-such-proxy:3128 https_proxy: http://no-such-proxy:3128
no_proxy: github.com,dotnetcli.blob.core.windows.net,download.visualstudio.microsoft.com,api.nuget.org,dotnetcli.azureedge.net no_proxy: github.com,download.visualstudio.microsoft.com,api.nuget.org,builds.dotnet.microsoft.com,ci.dot.net
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@@ -451,33 +426,3 @@ jobs:
- name: Verify dotnet - name: Verify dotnet
shell: pwsh shell: pwsh
run: __tests__/verify-dotnet.ps1 -Patterns "^3.1.201$" -CheckNugetConfig run: __tests__/verify-dotnet.ps1 -Patterns "^3.1.201$" -CheckNugetConfig
test-sequential-version-installation:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13]
lower-version: ['3.1.426']
higher-version: ['7.0.203']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Clear toolcache
shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
# Install one version, use it for something, then switch to next version
- name: Setup dotnet (lower version)
uses: ./
with:
dotnet-version: ${{ matrix.lower-version }}
- name: Verify dotnet (lower version)
shell: pwsh
run: __tests__/verify-dotnet.ps1 -Patterns "^${{ matrix.lower-version }}$"
- name: Setup dotnet (higher version)
uses: ./
with:
dotnet-version: ${{ matrix.higher-version }}
- name: Verify dotnet (higher version)
shell: pwsh
run: __tests__/verify-dotnet.ps1 -Patterns "^${{ matrix.lower-version }}$", "^${{ matrix.higher-version }}$"

View File

@@ -0,0 +1,20 @@
name: 'Publish Immutable Action Version'
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- name: Checking out
uses: actions/checkout@v4
- name: Publish
id: publish
uses: actions/publish-immutable-action@v0.0.4

View File

@@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Publish - name: Publish
id: publish id: publish
uses: actions/publish-immutable-action@0.0.3 uses: actions/publish-immutable-action@v0.0.4

View File

@@ -17,11 +17,11 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-13] operating-system: [ubuntu-22.04, windows-latest, macOS-latest]
dotnet-version: ['2.1', '2.2', '3.0', '3.1', '5.0', '6.0', '7.0', '8.0'] dotnet-version: ['2.1', '2.2', '3.0', '3.1', '5.0', '6.0', '7.0', '8.0']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/@protobuf-ts/plugin.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/@protobuf-ts/protoc.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/@protobuf-ts/runtime.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/atob-lite.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/btoa-lite.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/cross-spawn.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/form-data-3.0.1.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/ip-regex.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/is-stream.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/isobject.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/lodash.get.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/lodash.set.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/lodash.uniq.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/macos-release.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/npm-run-path.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/os-name.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/path-key.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/psl.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/punycode.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/shebang-command.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/shebang-regex.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/signal-exit.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/strip-eof.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/tough-cookie.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/typescript.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/windows-release.dep.yml generated Normal file

Binary file not shown.

View File

@@ -12,7 +12,7 @@ This action sets up a [.NET CLI](https://github.com/dotnet/sdk) environment for
> **Note**: GitHub hosted runners have some versions of the .NET SDK > **Note**: GitHub hosted runners have some versions of the .NET SDK
preinstalled. Installed versions are subject to change. Please refer to the preinstalled. Installed versions are subject to change. Please refer to the
documentation: documentation:
[Software installed on github hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-software) [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. for .NET SDK versions that are currently available.
## Usage ## Usage
@@ -22,20 +22,20 @@ See [action.yml](action.yml)
**Basic**: **Basic**:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-dotnet@v4 - uses: actions/setup-dotnet@v3
with: with:
dotnet-version: '3.1.x' dotnet-version: '3.1.x'
- run: dotnet build <my project> - run: dotnet build <my project>
``` ```
> **Warning**: Unless a concrete version is specified in the [`global.json`](https://learn.microsoft.com/en-us/dotnet/core/tools/global-json) file, **_the latest .NET version installed on the runner (including preinstalled versions) will be used [by default](https://learn.microsoft.com/en-us/dotnet/core/versions/selection#the-sdk-uses-the-latest-installed-version)_**. Please refer to the [documentation](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-software) for the currently preinstalled .NET SDK versions. > **Warning**: Unless a concrete version is specified in the [`global.json`](https://learn.microsoft.com/en-us/dotnet/core/tools/global-json) file, **_the latest .NET version installed on the runner (including preinstalled versions) will be used [by default](https://learn.microsoft.com/en-us/dotnet/core/versions/selection#the-sdk-uses-the-latest-installed-version)_**. Please refer to the [documentation](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software) for the currently preinstalled .NET SDK versions.
**Multiple version installation**: **Multiple version installation**:
```yml ```yml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Setup dotnet - name: Setup dotnet
uses: actions/setup-dotnet@v4 uses: actions/setup-dotnet@v3
with: with:
dotnet-version: | dotnet-version: |
3.1.x 3.1.x
@@ -59,8 +59,8 @@ This input sets up the action to install the latest build of the specified quali
```yml ```yml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-dotnet@v4 - uses: actions/setup-dotnet@v3
with: with:
dotnet-version: '6.0.x' dotnet-version: '6.0.x'
dotnet-quality: 'preview' dotnet-quality: 'preview'
@@ -74,8 +74,8 @@ steps:
```yml ```yml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-dotnet@v4 - uses: actions/setup-dotnet@v3
with: with:
global-json-file: csharp/global.json global-json-file: csharp/global.json
- run: dotnet build <my project> - run: dotnet build <my project>
@@ -91,8 +91,8 @@ The action searches for [NuGet Lock files](https://learn.microsoft.com/nuget/con
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-dotnet@v4 - uses: actions/setup-dotnet@v3
with: with:
dotnet-version: 6.x dotnet-version: 6.x
cache: true cache: true
@@ -116,8 +116,8 @@ steps:
env: env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-dotnet@v4 - uses: actions/setup-dotnet@v3
with: with:
dotnet-version: 6.x dotnet-version: 6.x
cache: true cache: true
@@ -130,8 +130,8 @@ steps:
env: env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-dotnet@v4 - uses: actions/setup-dotnet@v3
with: with:
dotnet-version: 6.x dotnet-version: 6.x
cache: true cache: true
@@ -150,9 +150,9 @@ jobs:
dotnet: [ '2.1.x', '3.1.x', '5.0.x' ] dotnet: [ '2.1.x', '3.1.x', '5.0.x' ]
name: Dotnet ${{ matrix.dotnet }} sample name: Dotnet ${{ matrix.dotnet }} sample
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Setup dotnet - name: Setup dotnet
uses: actions/setup-dotnet@v4 uses: actions/setup-dotnet@v3
with: with:
dotnet-version: ${{ matrix.dotnet }} dotnet-version: ${{ matrix.dotnet }}
- name: Execute dotnet - name: Execute dotnet
@@ -170,9 +170,9 @@ jobs:
dotnet: [ '2.1.x', '3.1.x', '5.0.x' ] dotnet: [ '2.1.x', '3.1.x', '5.0.x' ]
name: Dotnet ${{ matrix.dotnet }} sample name: Dotnet ${{ matrix.dotnet }} sample
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Setup dotnet - name: Setup dotnet
uses: actions/setup-dotnet@v4 uses: actions/setup-dotnet@v3
id: stepid id: stepid
with: with:
dotnet-version: ${{ matrix.dotnet }} dotnet-version: ${{ matrix.dotnet }}
@@ -186,8 +186,8 @@ jobs:
### Github Package Registry (GPR) ### Github Package Registry (GPR)
```yml ```yml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-dotnet@v4 - uses: actions/setup-dotnet@v3
with: with:
dotnet-version: '3.1.x' dotnet-version: '3.1.x'
source-url: https://nuget.pkg.github.com/<owner>/index.json source-url: https://nuget.pkg.github.com/<owner>/index.json
@@ -202,7 +202,7 @@ steps:
### Azure Artifacts ### Azure Artifacts
```yml ```yml
- uses: actions/setup-dotnet@v4 - uses: actions/setup-dotnet@v3
with: with:
source-url: https://pkgs.dev.azure.com/<your-organization>/_packaging/<your-feed-name>/nuget/v3/index.json source-url: https://pkgs.dev.azure.com/<your-organization>/_packaging/<your-feed-name>/nuget/v3/index.json
env: env:
@@ -213,7 +213,7 @@ steps:
### nuget.org ### nuget.org
```yml ```yml
- uses: actions/setup-dotnet@v4 - uses: actions/setup-dotnet@v3
with: with:
dotnet-version: 3.1.x dotnet-version: 3.1.x
- name: Publish the package to nuget.org - name: Publish the package to nuget.org
@@ -236,7 +236,7 @@ Using the **dotnet-version** output it's possible to get the installed by the ac
In case of a single version installation, the `dotnet-version` output contains the version that is installed by the action. In case of a single version installation, the `dotnet-version` output contains the version that is installed by the action.
```yaml ```yaml
- uses: actions/setup-dotnet@v4 - uses: actions/setup-dotnet@v3
id: stepid id: stepid
with: with:
dotnet-version: 3.1.422 dotnet-version: 3.1.422
@@ -248,7 +248,7 @@ In case of a single version installation, the `dotnet-version` output contains t
In case of a multiple version installation, the `dotnet-version` output contains the latest version that is installed by the action. In case of a multiple version installation, the `dotnet-version` output contains the latest version that is installed by the action.
```yaml ```yaml
- uses: actions/setup-dotnet@v4 - uses: actions/setup-dotnet@v3
id: stepid id: stepid
with: with:
dotnet-version: | dotnet-version: |
@@ -261,7 +261,7 @@ In case of a multiple version installation, the `dotnet-version` output contains
When the `dotnet-version` input is used along with the `global-json-file` input, the `dotnet-version` output contains the version resolved from the `global.json`. When the `dotnet-version` input is used along with the `global-json-file` input, the `dotnet-version` output contains the version resolved from the `global.json`.
```yaml ```yaml
- uses: actions/setup-dotnet@v4 - uses: actions/setup-dotnet@v3
id: stepid id: stepid
with: with:
dotnet-version: | dotnet-version: |
@@ -302,7 +302,7 @@ build:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps: steps:
- uses: actions/checkout@main - uses: actions/checkout@main
- uses: actions/setup-dotnet@v4 - uses: actions/setup-dotnet@v3
with: with:
dotnet-version: '3.1.x' dotnet-version: '3.1.x'
cache: true cache: true

View File

@@ -1,184 +1,184 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`authutil tests existing config not in repo root, sets up a partial NuGet.config user/PAT for GPR 1`] = ` exports[`authutil tests existing config not in repo root, sets up a partial NuGet.config user/PAT for GPR 1`] = `
"<?xml version="1.0"?> "<?xml version=\\"1.0\\"?>
<configuration> <configuration>
<config> <config>
<add key="defaultPushSource" value="https://nuget.pkg.github.com/OwnerName/index.json"/> <add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
</config> </config>
<packageSourceCredentials> <packageSourceCredentials>
<GPR> <GPR>
<add key="Username" value="OwnerName"/> <add key=\\"Username\\" value=\\"OwnerName\\"/>
<add key="ClearTextPassword" value="TEST_FAKE_AUTH_TOKEN"/> <add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
</GPR> </GPR>
</packageSourceCredentials> </packageSourceCredentials>
</configuration>" </configuration>"
`; `;
exports[`authutil tests existing config w/ Azure Artifacts source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR 1`] = ` exports[`authutil tests existing config w/ Azure Artifacts source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR 1`] = `
"<?xml version="1.0"?> "<?xml version=\\"1.0\\"?>
<configuration> <configuration>
<config> <config>
<add key="defaultPushSource" value="https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json"/> <add key=\\"defaultPushSource\\" value=\\"https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json\\"/>
</config> </config>
<packageSourceCredentials> <packageSourceCredentials>
<AzureArtifacts> <AzureArtifacts>
<add key="Username" value="OwnerName"/> <add key=\\"Username\\" value=\\"OwnerName\\"/>
<add key="ClearTextPassword" value="TEST_FAKE_AUTH_TOKEN"/> <add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
</AzureArtifacts> </AzureArtifacts>
</packageSourceCredentials> </packageSourceCredentials>
</configuration>" </configuration>"
`; `;
exports[`authutil tests existing config w/ GPR source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR 1`] = ` exports[`authutil tests existing config w/ GPR source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR 1`] = `
"<?xml version="1.0"?> "<?xml version=\\"1.0\\"?>
<configuration> <configuration>
<config> <config>
<add key="defaultPushSource" value="https://nuget.pkg.github.com/OwnerName/index.json"/> <add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
</config> </config>
<packageSourceCredentials> <packageSourceCredentials>
<GPR> <GPR>
<add key="Username" value="OwnerName"/> <add key=\\"Username\\" value=\\"OwnerName\\"/>
<add key="ClearTextPassword" value="TEST_FAKE_AUTH_TOKEN"/> <add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
</GPR> </GPR>
</packageSourceCredentials> </packageSourceCredentials>
</configuration>" </configuration>"
`; `;
exports[`authutil tests existing config w/ no GPR sources, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = ` exports[`authutil tests existing config w/ no GPR sources, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = `
"<?xml version="1.0"?> "<?xml version=\\"1.0\\"?>
<configuration> <configuration>
<config> <config>
<add key="defaultPushSource" value="https://nuget.pkg.github.com/OwnerName/index.json"/> <add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
</config> </config>
<packageSources> <packageSources>
<add key="Source" value="https://nuget.pkg.github.com/OwnerName/index.json"/> <add key=\\"Source\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
</packageSources> </packageSources>
<packageSourceCredentials> <packageSourceCredentials>
<Source> <Source>
<add key="Username" value="OwnerName"/> <add key=\\"Username\\" value=\\"OwnerName\\"/>
<add key="ClearTextPassword" value="TEST_FAKE_AUTH_TOKEN"/> <add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
</Source> </Source>
</packageSourceCredentials> </packageSourceCredentials>
</configuration>" </configuration>"
`; `;
exports[`authutil tests existing config w/ no sources, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = ` exports[`authutil tests existing config w/ no sources, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = `
"<?xml version="1.0"?> "<?xml version=\\"1.0\\"?>
<configuration> <configuration>
<config> <config>
<add key="defaultPushSource" value="https://nuget.pkg.github.com/OwnerName/index.json"/> <add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
</config> </config>
<packageSources> <packageSources>
<add key="Source" value="https://nuget.pkg.github.com/OwnerName/index.json"/> <add key=\\"Source\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
</packageSources> </packageSources>
<packageSourceCredentials> <packageSourceCredentials>
<Source> <Source>
<add key="Username" value="OwnerName"/> <add key=\\"Username\\" value=\\"OwnerName\\"/>
<add key="ClearTextPassword" value="TEST_FAKE_AUTH_TOKEN"/> <add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
</Source> </Source>
</packageSourceCredentials> </packageSourceCredentials>
</configuration>" </configuration>"
`; `;
exports[`authutil tests existing config w/ only Azure Artifacts source, sets up a partial NuGet.config user/PAT for GPR 1`] = ` exports[`authutil tests existing config w/ only Azure Artifacts source, sets up a partial NuGet.config user/PAT for GPR 1`] = `
"<?xml version="1.0"?> "<?xml version=\\"1.0\\"?>
<configuration> <configuration>
<config> <config>
<add key="defaultPushSource" value="https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json"/> <add key=\\"defaultPushSource\\" value=\\"https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json\\"/>
</config> </config>
<packageSourceCredentials> <packageSourceCredentials>
<AzureArtifacts> <AzureArtifacts>
<add key="Username" value="OwnerName"/> <add key=\\"Username\\" value=\\"OwnerName\\"/>
<add key="ClearTextPassword" value="TEST_FAKE_AUTH_TOKEN"/> <add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
</AzureArtifacts> </AzureArtifacts>
</packageSourceCredentials> </packageSourceCredentials>
</configuration>" </configuration>"
`; `;
exports[`authutil tests existing config w/ only GPR source, sets up a partial NuGet.config user/PAT for GPR 1`] = ` exports[`authutil tests existing config w/ only GPR source, sets up a partial NuGet.config user/PAT for GPR 1`] = `
"<?xml version="1.0"?> "<?xml version=\\"1.0\\"?>
<configuration> <configuration>
<config> <config>
<add key="defaultPushSource" value="https://nuget.pkg.github.com/OwnerName/index.json"/> <add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
</config> </config>
<packageSourceCredentials> <packageSourceCredentials>
<GPR> <GPR>
<add key="Username" value="OwnerName"/> <add key=\\"Username\\" value=\\"OwnerName\\"/>
<add key="ClearTextPassword" value="TEST_FAKE_AUTH_TOKEN"/> <add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
</GPR> </GPR>
</packageSourceCredentials> </packageSourceCredentials>
</configuration>" </configuration>"
`; `;
exports[`authutil tests existing config w/ two GPR sources, sets up a partial NuGet.config user/PAT for GPR 1`] = ` exports[`authutil tests existing config w/ two GPR sources, sets up a partial NuGet.config user/PAT for GPR 1`] = `
"<?xml version="1.0"?> "<?xml version=\\"1.0\\"?>
<configuration> <configuration>
<config> <config>
<add key="defaultPushSource" value="https://nuget.pkg.github.com"/> <add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com\\"/>
</config> </config>
<packageSourceCredentials> <packageSourceCredentials>
<GPR-GitHub> <GPR-GitHub>
<add key="Username" value="OwnerName"/> <add key=\\"Username\\" value=\\"OwnerName\\"/>
<add key="ClearTextPassword" value="TEST_FAKE_AUTH_TOKEN"/> <add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
</GPR-GitHub> </GPR-GitHub>
<GPR-Actions> <GPR-Actions>
<add key="Username" value="OwnerName"/> <add key=\\"Username\\" value=\\"OwnerName\\"/>
<add key="ClearTextPassword" value="TEST_FAKE_AUTH_TOKEN"/> <add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
</GPR-Actions> </GPR-Actions>
</packageSourceCredentials> </packageSourceCredentials>
</configuration>" </configuration>"
`; `;
exports[`authutil tests no existing config, sets up a full NuGet.config with URL and other owner/PAT for GPR 1`] = ` exports[`authutil tests no existing config, sets up a full NuGet.config with URL and other owner/PAT for GPR 1`] = `
"<?xml version="1.0"?> "<?xml version=\\"1.0\\"?>
<configuration> <configuration>
<config> <config>
<add key="defaultPushSource" value="https://nuget.pkg.github.com/otherorg/index.json"/> <add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/otherorg/index.json\\"/>
</config> </config>
<packageSources> <packageSources>
<add key="Source" value="https://nuget.pkg.github.com/otherorg/index.json"/> <add key=\\"Source\\" value=\\"https://nuget.pkg.github.com/otherorg/index.json\\"/>
</packageSources> </packageSources>
<packageSourceCredentials> <packageSourceCredentials>
<Source> <Source>
<add key="Username" value="otherorg"/> <add key=\\"Username\\" value=\\"otherorg\\"/>
<add key="ClearTextPassword" value="TEST_FAKE_AUTH_TOKEN"/> <add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
</Source> </Source>
</packageSourceCredentials> </packageSourceCredentials>
</configuration>" </configuration>"
`; `;
exports[`authutil tests no existing config, sets up a full NuGet.config with URL and token for other source 1`] = ` exports[`authutil tests no existing config, sets up a full NuGet.config with URL and token for other source 1`] = `
"<?xml version="1.0"?> "<?xml version=\\"1.0\\"?>
<configuration> <configuration>
<config> <config>
<add key="defaultPushSource" value="https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json"/> <add key=\\"defaultPushSource\\" value=\\"https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json\\"/>
</config> </config>
<packageSources> <packageSources>
<add key="Source" value="https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json"/> <add key=\\"Source\\" value=\\"https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json\\"/>
</packageSources> </packageSources>
<packageSourceCredentials> <packageSourceCredentials>
<Source> <Source>
<add key="Username" value="OwnerName"/> <add key=\\"Username\\" value=\\"OwnerName\\"/>
<add key="ClearTextPassword" value="TEST_FAKE_AUTH_TOKEN"/> <add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
</Source> </Source>
</packageSourceCredentials> </packageSourceCredentials>
</configuration>" </configuration>"
`; `;
exports[`authutil tests no existing config, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = ` exports[`authutil tests no existing config, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = `
"<?xml version="1.0"?> "<?xml version=\\"1.0\\"?>
<configuration> <configuration>
<config> <config>
<add key="defaultPushSource" value="https://nuget.pkg.github.com/OwnerName/index.json"/> <add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
</config> </config>
<packageSources> <packageSources>
<add key="Source" value="https://nuget.pkg.github.com/OwnerName/index.json"/> <add key=\\"Source\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
</packageSources> </packageSources>
<packageSourceCredentials> <packageSourceCredentials>
<Source> <Source>
<add key="Username" value="OwnerName"/> <add key=\\"Username\\" value=\\"OwnerName\\"/>
<add key="ClearTextPassword" value="TEST_FAKE_AUTH_TOKEN"/> <add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
</Source> </Source>
</packageSourceCredentials> </packageSourceCredentials>
</configuration>" </configuration>"

View File

@@ -102,15 +102,8 @@ describe('installer tests', () => {
await dotnetInstaller.installDotnet(); await dotnetInstaller.installDotnet();
/**
* First time script would be called to
* install runtime, here we checking only the
* second one that installs actual SDK. i.e. 1
*/
const callIndex = 1;
const scriptArguments = ( const scriptArguments = (
getExecOutputSpy.mock.calls[callIndex][1] as string[] getExecOutputSpy.mock.calls[0][1] as string[]
).join(' '); ).join(' ');
const expectedArgument = IS_WINDOWS const expectedArgument = IS_WINDOWS
? `-Version ${inputVersion}` ? `-Version ${inputVersion}`
@@ -192,15 +185,8 @@ describe('installer tests', () => {
await dotnetInstaller.installDotnet(); await dotnetInstaller.installDotnet();
/**
* First time script would be called to
* install runtime, here we checking only the
* second one that installs actual SDK. i.e. 1
*/
const callIndex = 1;
const scriptArguments = ( const scriptArguments = (
getExecOutputSpy.mock.calls[callIndex][1] as string[] getExecOutputSpy.mock.calls[0][1] as string[]
).join(' '); ).join(' ');
const expectedArgument = IS_WINDOWS const expectedArgument = IS_WINDOWS
? `-Quality ${inputQuality}` ? `-Quality ${inputQuality}`
@@ -232,15 +218,8 @@ describe('installer tests', () => {
await dotnetInstaller.installDotnet(); await dotnetInstaller.installDotnet();
/**
* First time script would be called to
* install runtime, here we checking only the
* second one that installs actual SDK. i.e. 1
*/
const callIndex = 1;
const scriptArguments = ( const scriptArguments = (
getExecOutputSpy.mock.calls[callIndex][1] as string[] getExecOutputSpy.mock.calls[0][1] as string[]
).join(' '); ).join(' ');
const expectedArgument = IS_WINDOWS const expectedArgument = IS_WINDOWS
? `-Channel 6.0` ? `-Channel 6.0`
@@ -273,15 +252,8 @@ describe('installer tests', () => {
await dotnetInstaller.installDotnet(); await dotnetInstaller.installDotnet();
/**
* First time script would be called to
* install runtime, here we checking only the
* second one that installs actual SDK. i.e. 1
*/
const callIndex = 1;
const scriptArguments = ( const scriptArguments = (
getExecOutputSpy.mock.calls[callIndex][1] as string[] getExecOutputSpy.mock.calls[0][1] as string[]
).join(' '); ).join(' ');
expect(scriptArguments).toContain( expect(scriptArguments).toContain(
@@ -311,15 +283,8 @@ describe('installer tests', () => {
await dotnetInstaller.installDotnet(); await dotnetInstaller.installDotnet();
/**
* First time script would be called to
* install runtime, here we checking only the
* second one that installs actual SDK. i.e. 1
*/
const callIndex = 1;
const scriptArguments = ( const scriptArguments = (
getExecOutputSpy.mock.calls[callIndex][1] as string[] getExecOutputSpy.mock.calls[0][1] as string[]
).join(' '); ).join(' ');
expect(scriptArguments).toContain( expect(scriptArguments).toContain(
@@ -332,14 +297,14 @@ describe('installer tests', () => {
describe('addToPath() tests', () => { describe('addToPath() tests', () => {
it(`should export DOTNET_ROOT env.var with value from DOTNET_INSTALL_DIR env.var`, async () => { it(`should export DOTNET_ROOT env.var with value from DOTNET_INSTALL_DIR env.var`, async () => {
process.env['DOTNET_INSTALL_DIR'] = 'fictitious/dotnet/install/dir'; process.env['DOTNET_INSTALL_DIR'] = 'fictitious/dotnet/install/dir';
installer.DotnetInstallDir.addToPath(); installer.DotnetCoreInstaller.addToPath();
const dotnet_root = process.env['DOTNET_ROOT']; const dotnet_root = process.env['DOTNET_ROOT'];
expect(dotnet_root).toBe(process.env['DOTNET_INSTALL_DIR']); expect(dotnet_root).toBe(process.env['DOTNET_INSTALL_DIR']);
}); });
it(`should export value from DOTNET_INSTALL_DIR env.var to the PATH`, async () => { it(`should export value from DOTNET_INSTALL_DIR env.var to the PATH`, async () => {
process.env['DOTNET_INSTALL_DIR'] = 'fictitious/dotnet/install/dir'; process.env['DOTNET_INSTALL_DIR'] = 'fictitious/dotnet/install/dir';
installer.DotnetInstallDir.addToPath(); installer.DotnetCoreInstaller.addToPath();
const path = process.env['PATH']; const path = process.env['PATH'];
expect(path).toContain(process.env['DOTNET_INSTALL_DIR']); expect(path).toContain(process.env['DOTNET_INSTALL_DIR']);
}); });
@@ -347,7 +312,7 @@ describe('installer tests', () => {
}); });
describe('DotnetVersionResolver tests', () => { describe('DotnetVersionResolver tests', () => {
describe('createDotnetVersion() tests', () => { describe('createDotNetVersion() tests', () => {
each([ each([
'3.1', '3.1',
'3.x', '3.x',
@@ -364,7 +329,7 @@ describe('installer tests', () => {
version version
); );
const versionObject = const versionObject =
await dotnetVersionResolver.createDotnetVersion(); await dotnetVersionResolver.createDotNetVersion();
expect(!!versionObject.value).toBe(true); expect(!!versionObject.value).toBe(true);
} }
@@ -403,7 +368,7 @@ describe('installer tests', () => {
); );
await expect( await expect(
async () => await dotnetVersionResolver.createDotnetVersion() async () => await dotnetVersionResolver.createDotNetVersion()
).rejects.toThrow(); ).rejects.toThrow();
} }
); );
@@ -415,7 +380,7 @@ describe('installer tests', () => {
version version
); );
const versionObject = const versionObject =
await dotnetVersionResolver.createDotnetVersion(); await dotnetVersionResolver.createDotNetVersion();
expect(versionObject.type.toLowerCase().includes('channel')).toBe( expect(versionObject.type.toLowerCase().includes('channel')).toBe(
true true
@@ -430,7 +395,7 @@ describe('installer tests', () => {
version version
); );
const versionObject = const versionObject =
await dotnetVersionResolver.createDotnetVersion(); await dotnetVersionResolver.createDotNetVersion();
expect(versionObject.type.toLowerCase().includes('channel')).toBe( expect(versionObject.type.toLowerCase().includes('channel')).toBe(
true true
@@ -446,7 +411,7 @@ describe('installer tests', () => {
version version
); );
const versionObject = const versionObject =
await dotnetVersionResolver.createDotnetVersion(); await dotnetVersionResolver.createDotNetVersion();
expect(versionObject.type.toLowerCase().includes('version')).toBe( expect(versionObject.type.toLowerCase().includes('version')).toBe(
true true
@@ -462,7 +427,7 @@ describe('installer tests', () => {
version version
); );
const versionObject = const versionObject =
await dotnetVersionResolver.createDotnetVersion(); await dotnetVersionResolver.createDotNetVersion();
const windowsRegEx = new RegExp(/^-(Version|Channel)/); const windowsRegEx = new RegExp(/^-(Version|Channel)/);
const nonWindowsRegEx = new RegExp(/^--(version|channel)/); const nonWindowsRegEx = new RegExp(/^--(version|channel)/);
@@ -482,7 +447,7 @@ describe('installer tests', () => {
version version
); );
await expect( await expect(
async () => await dotnetVersionResolver.createDotnetVersion() async () => await dotnetVersionResolver.createDotNetVersion()
).rejects.toThrow( ).rejects.toThrow(
`'dotnet-version' was supplied in invalid format: ${version}! The A.B.Cxx syntax is available since the .NET 5.0 release.` `'dotnet-version' was supplied in invalid format: ${version}! The A.B.Cxx syntax is available since the .NET 5.0 release.`
); );

View File

@@ -4,7 +4,7 @@ import semver from 'semver';
import * as auth from '../src/authutil'; import * as auth from '../src/authutil';
import * as setup from '../src/setup-dotnet'; import * as setup from '../src/setup-dotnet';
import {DotnetCoreInstaller, DotnetInstallDir} from '../src/installer'; import {DotnetCoreInstaller} from '../src/installer';
import * as cacheUtils from '../src/cache-utils'; import * as cacheUtils from '../src/cache-utils';
import * as cacheRestore from '../src/cache-restore'; import * as cacheRestore from '../src/cache-restore';
@@ -28,25 +28,22 @@ describe('setup-dotnet tests', () => {
DotnetCoreInstaller.prototype, DotnetCoreInstaller.prototype,
'installDotnet' 'installDotnet'
); );
const addToPathSpy = jest.spyOn(DotnetCoreInstaller, 'addToPath');
const isCacheFeatureAvailableSpy = jest.spyOn( const isCacheFeatureAvailableSpy = jest.spyOn(
cacheUtils, cacheUtils,
'isCacheFeatureAvailable' 'isCacheFeatureAvailable'
); );
const restoreCacheSpy = jest.spyOn(cacheRestore, 'restoreCache'); const restoreCacheSpy = jest.spyOn(cacheRestore, 'restoreCache');
const configAuthenticationSpy = jest.spyOn(auth, 'configAuthentication'); const configAuthenticationSpy = jest.spyOn(auth, 'configAuthentication');
const addToPathOriginal = DotnetInstallDir.addToPath;
describe('run() tests', () => { describe('run() tests', () => {
beforeEach(() => { beforeEach(() => {
DotnetInstallDir.addToPath = jest.fn();
getMultilineInputSpy.mockImplementation(input => inputs[input as string]); getMultilineInputSpy.mockImplementation(input => inputs[input as string]);
getInputSpy.mockImplementation(input => inputs[input as string]); getInputSpy.mockImplementation(input => inputs[input as string]);
getBooleanInputSpy.mockImplementation(input => inputs[input as string]); getBooleanInputSpy.mockImplementation(input => inputs[input as string]);
}); });
afterEach(() => { afterEach(() => {
DotnetInstallDir.addToPath = addToPathOriginal;
jest.clearAllMocks(); jest.clearAllMocks();
jest.resetAllMocks(); jest.resetAllMocks();
}); });
@@ -107,9 +104,10 @@ describe('setup-dotnet tests', () => {
inputs['dotnet-quality'] = ''; inputs['dotnet-quality'] = '';
installDotnetSpy.mockImplementation(() => Promise.resolve('')); installDotnetSpy.mockImplementation(() => Promise.resolve(''));
addToPathSpy.mockImplementation(() => {});
await setup.run(); await setup.run();
expect(DotnetInstallDir.addToPath).toHaveBeenCalledTimes(1); expect(addToPathSpy).toHaveBeenCalledTimes(1);
}); });
it('should call auth.configAuthentication() if source-url input is provided', async () => { it('should call auth.configAuthentication() if source-url input is provided', async () => {
@@ -150,9 +148,10 @@ describe('setup-dotnet tests', () => {
installDotnetSpy.mockImplementation(() => installDotnetSpy.mockImplementation(() =>
Promise.resolve(`${inputs['dotnet-version']}`) Promise.resolve(`${inputs['dotnet-version']}`)
); );
addToPathSpy.mockImplementation(() => {});
await setup.run(); await setup.run();
expect(DotnetInstallDir.addToPath).toHaveBeenCalledTimes(1); expect(setOutputSpy).toHaveBeenCalledTimes(1);
}); });
it(`shouldn't call setOutput() if parsing dotnet-installer logs failed`, async () => { it(`shouldn't call setOutput() if parsing dotnet-installer logs failed`, async () => {
@@ -160,6 +159,7 @@ describe('setup-dotnet tests', () => {
const warningMessage = `Failed to output the installed version of .NET. The 'dotnet-version' output will not be set.`; const warningMessage = `Failed to output the installed version of .NET. The 'dotnet-version' output will not be set.`;
installDotnetSpy.mockImplementation(() => Promise.resolve(null)); installDotnetSpy.mockImplementation(() => Promise.resolve(null));
addToPathSpy.mockImplementation(() => {});
await setup.run(); await setup.run();
expect(warningSpy).toHaveBeenCalledWith(warningMessage); expect(warningSpy).toHaveBeenCalledWith(warningMessage);
@@ -170,6 +170,8 @@ describe('setup-dotnet tests', () => {
inputs['dotnet-version'] = []; inputs['dotnet-version'] = [];
const warningMessage = `The 'dotnet-version' output will not be set.`; const warningMessage = `The 'dotnet-version' output will not be set.`;
addToPathSpy.mockImplementation(() => {});
await setup.run(); await setup.run();
expect(infoSpy).toHaveBeenCalledWith(warningMessage); expect(infoSpy).toHaveBeenCalledWith(warningMessage);
@@ -183,6 +185,7 @@ describe('setup-dotnet tests', () => {
inputs['cache-dependency-path'] = 'fictitious.package.lock.json'; inputs['cache-dependency-path'] = 'fictitious.package.lock.json';
installDotnetSpy.mockImplementation(() => Promise.resolve('')); installDotnetSpy.mockImplementation(() => Promise.resolve(''));
addToPathSpy.mockImplementation(() => {});
isCacheFeatureAvailableSpy.mockImplementation(() => true); isCacheFeatureAvailableSpy.mockImplementation(() => true);
restoreCacheSpy.mockImplementation(() => Promise.resolve()); restoreCacheSpy.mockImplementation(() => Promise.resolve());
@@ -200,6 +203,7 @@ describe('setup-dotnet tests', () => {
inputs['cache'] = false; inputs['cache'] = false;
installDotnetSpy.mockImplementation(() => Promise.resolve('')); installDotnetSpy.mockImplementation(() => Promise.resolve(''));
addToPathSpy.mockImplementation(() => {});
isCacheFeatureAvailableSpy.mockImplementation(() => true); isCacheFeatureAvailableSpy.mockImplementation(() => true);
restoreCacheSpy.mockImplementation(() => Promise.resolve()); restoreCacheSpy.mockImplementation(() => Promise.resolve());
@@ -214,6 +218,7 @@ describe('setup-dotnet tests', () => {
inputs['cache'] = true; inputs['cache'] = true;
installDotnetSpy.mockImplementation(() => Promise.resolve('')); installDotnetSpy.mockImplementation(() => Promise.resolve(''));
addToPathSpy.mockImplementation(() => {});
isCacheFeatureAvailableSpy.mockImplementation(() => false); isCacheFeatureAvailableSpy.mockImplementation(() => false);
restoreCacheSpy.mockImplementation(() => Promise.resolve()); restoreCacheSpy.mockImplementation(() => Promise.resolve());

View File

@@ -30,7 +30,7 @@ outputs:
dotnet-version: dotnet-version:
description: 'Contains the installed by action .NET SDK version for reuse.' description: 'Contains the installed by action .NET SDK version for reuse.'
runs: runs:
using: 'node20' using: 'node16'
main: 'dist/setup/index.js' main: 'dist/setup/index.js'
post: 'dist/cache-save/index.js' post: 'dist/cache-save/index.js'
post-if: success() post-if: success()

14179
dist/cache-save/index.js vendored

File diff suppressed because it is too large Load Diff

30904
dist/setup/index.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -956,6 +956,37 @@ get_absolute_path() {
return 0 return 0
} }
# args:
# override - $1 (boolean, true or false)
get_cp_options() {
eval $invocation
local override="$1"
local override_switch=""
if [ "$override" = false ]; then
override_switch="-n"
# create temporary files to check if 'cp -u' is supported
tmp_dir="$(mktemp -d)"
tmp_file="$tmp_dir/testfile"
tmp_file2="$tmp_dir/testfile2"
touch "$tmp_file"
# use -u instead of -n if it's available
if cp -u "$tmp_file" "$tmp_file2" 2>/dev/null; then
override_switch="-u"
fi
# clean up
rm -f "$tmp_file" "$tmp_file2"
rm -rf "$tmp_dir"
fi
echo "$override_switch"
}
# args: # args:
# input_files - stdin # input_files - stdin
# root_path - $1 # root_path - $1
@@ -967,16 +998,7 @@ copy_files_or_dirs_from_list() {
local root_path="$(remove_trailing_slash "$1")" local root_path="$(remove_trailing_slash "$1")"
local out_path="$(remove_trailing_slash "$2")" local out_path="$(remove_trailing_slash "$2")"
local override="$3" local override="$3"
local override_switch="" local override_switch="$(get_cp_options "$override")"
if [ "$override" = false ]; then
override_switch="-n"
# use -u instead of -n when it's available
if cp -u --help >/dev/null 2>&1; then
override_switch="-u"
fi
fi
cat | uniq | while read -r file_path; do cat | uniq | while read -r file_path; do
local path="$(remove_beginning_slash "${file_path#$root_path}")" local path="$(remove_beginning_slash "${file_path#$root_path}")"
@@ -1250,6 +1272,61 @@ downloadwget() {
return 0 return 0
} }
extract_stem() {
local url="$1"
# extract the protocol
proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')"
# remove the protocol
url="${1/$proto/}"
# extract the path (if any) - since we know all of our feeds have a first path segment, we can skip the first one. otherwise we'd use -f2- to get the full path
full_path="$(echo $url | grep / | cut -d/ -f2-)"
path="$(echo $full_path | cut -d/ -f2-)"
echo $path
}
check_url_exists() {
eval $invocation
local url="$1"
local code=""
if machine_has "curl"
then
code=$(curl --head -o /dev/null -w "%{http_code}" -s --fail "$url");
elif machine_has "wget"
then
# get the http response, grab the status code
server_response=$(wget -qO- --method=HEAD --server-response "$url" 2>&1)
code=$(echo "$server_response" | grep "HTTP/" | awk '{print $2}')
fi
if [ $code = "200" ]; then
return 0
else
return 1
fi
}
sanitize_redirect_url() {
eval $invocation
local url_stem
url_stem=$(extract_stem "$1")
say_verbose "Checking configured feeds for the asset at ${yellow:-}$url_stem${normal:-}"
for feed in "${feeds[@]}"
do
local trial_url="$feed/$url_stem"
say_verbose "Checking ${yellow:-}$trial_url${normal:-}"
if check_url_exists "$trial_url"; then
say_verbose "Found a match at ${yellow:-}$trial_url${normal:-}"
echo "$trial_url"
return 0
else
say_verbose "No match at ${yellow:-}$trial_url${normal:-}"
fi
done
return 1
}
get_download_link_from_aka_ms() { get_download_link_from_aka_ms() {
eval $invocation eval $invocation
@@ -1302,6 +1379,11 @@ get_download_link_from_aka_ms() {
return 1 return 1
fi fi
sanitized_redirect_url=$(sanitize_redirect_url "$aka_ms_download_link")
if [[ -n "$sanitized_redirect_url" ]]; then
aka_ms_download_link="$sanitized_redirect_url"
fi
say_verbose "The redirect location retrieved: '$aka_ms_download_link'." say_verbose "The redirect location retrieved: '$aka_ms_download_link'."
return 0 return 0
else else
@@ -1313,23 +1395,16 @@ get_download_link_from_aka_ms() {
get_feeds_to_use() get_feeds_to_use()
{ {
feeds=( feeds=(
"https://dotnetcli.azureedge.net/dotnet" "https://builds.dotnet.microsoft.com/dotnet"
"https://dotnetbuilds.azureedge.net/public" "https://ci.dot.net/public"
) )
if [[ -n "$azure_feed" ]]; then if [[ -n "$azure_feed" ]]; then
feeds=("$azure_feed") feeds=("$azure_feed")
fi fi
if [[ "$no_cdn" == "true" ]]; then if [[ -n "$uncached_feed" ]]; then
feeds=( feeds=("$uncached_feed")
"https://dotnetcli.blob.core.windows.net/dotnet"
"https://dotnetbuilds.blob.core.windows.net/public"
)
if [[ -n "$uncached_feed" ]]; then
feeds=("$uncached_feed")
fi
fi fi
} }
@@ -1461,7 +1536,7 @@ generate_regular_links() {
link_types+=("legacy") link_types+=("legacy")
else else
legacy_download_link="" legacy_download_link=""
say_verbose "Cound not construct a legacy_download_link; omitting..." say_verbose "Could not construct a legacy_download_link; omitting..."
fi fi
# Check if the SDK version is already installed. # Check if the SDK version is already installed.
@@ -1564,7 +1639,7 @@ install_dotnet() {
say "The resource at $link_type link '$download_link' is not available." say "The resource at $link_type link '$download_link' is not available."
;; ;;
*) *)
say "Failed to download $link_type link '$download_link': $download_error_msg" say "Failed to download $link_type link '$download_link': $http_code $download_error_msg"
;; ;;
esac esac
rm -f "$zip_path" 2>&1 && say_verbose "Temporary archive file $zip_path was removed" rm -f "$zip_path" 2>&1 && say_verbose "Temporary archive file $zip_path was removed"
@@ -1625,7 +1700,6 @@ install_dir="<auto>"
architecture="<auto>" architecture="<auto>"
dry_run=false dry_run=false
no_path=false no_path=false
no_cdn=false
azure_feed="" azure_feed=""
uncached_feed="" uncached_feed=""
feed_credential="" feed_credential=""
@@ -1698,10 +1772,6 @@ do
verbose=true verbose=true
non_dynamic_parameters+=" $name" non_dynamic_parameters+=" $name"
;; ;;
--no-cdn|-[Nn]o[Cc]dn)
no_cdn=true
non_dynamic_parameters+=" $name"
;;
--azure-feed|-[Aa]zure[Ff]eed) --azure-feed|-[Aa]zure[Ff]eed)
shift shift
azure_feed="$1" azure_feed="$1"
@@ -1806,13 +1876,10 @@ do
echo " --verbose,-Verbose Display diagnostics information." echo " --verbose,-Verbose Display diagnostics information."
echo " --azure-feed,-AzureFeed For internal use only." echo " --azure-feed,-AzureFeed For internal use only."
echo " Allows using a different storage to download SDK archives from." echo " Allows using a different storage to download SDK archives from."
echo " This parameter is only used if --no-cdn is false."
echo " --uncached-feed,-UncachedFeed For internal use only." echo " --uncached-feed,-UncachedFeed For internal use only."
echo " Allows using a different storage to download SDK archives from." echo " Allows using a different storage to download SDK archives from."
echo " This parameter is only used if --no-cdn is true."
echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable." echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
echo " -SkipNonVersionedFiles" 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 " --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 " Note: global.json must have a value for 'SDK:Version'"
echo " --keep-zip,-KeepZip If set, downloaded file is kept." echo " --keep-zip,-KeepZip If set, downloaded file is kept."
@@ -1872,4 +1939,4 @@ fi
say "Note that the script does not resolve dependencies during installation." say "Note that the script does not resolve dependencies during installation."
say "To check the list of dependencies, go to https://learn.microsoft.com/dotnet/core/install, select your operating system and check the \"Dependencies\" section." say "To check the list of dependencies, go to https://learn.microsoft.com/dotnet/core/install, select your operating system and check the \"Dependencies\" section."
say "Installation finished successfully." say "Installation finished successfully."

10160
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "setup-dotnet", "name": "setup-dotnet",
"version": "4.0.0", "version": "3.0.2",
"private": true, "private": true,
"description": "setup dotnet action", "description": "setup dotnet action",
"main": "dist/setup/index.js", "main": "dist/setup/index.js",
@@ -26,35 +26,34 @@
"author": "GitHub", "author": "GitHub",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^3.2.4", "@actions/cache": "^4.0.3",
"@actions/core": "^1.10.0", "@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/github": "^6.0.0", "@actions/github": "^1.1.0",
"@actions/glob": "^0.4.0", "@actions/glob": "^0.3.0",
"@actions/http-client": "^2.2.1", "@actions/http-client": "^2.0.1",
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"fast-xml-parser": "^4.4.1", "fast-xml-parser": "^4.0.10",
"json5": "^2.2.3", "semver": "^6.3.0"
"semver": "^7.6.0"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.12", "@types/jest": "^27.5.2",
"@types/node": "^20.11.29", "@types/node": "^16.11.25",
"@types/semver": "^7.5.8", "@types/semver": "^6.2.2",
"@typescript-eslint/eslint-plugin": "^7.3.0", "@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^7.3.0", "@typescript-eslint/parser": "^5.54.0",
"@vercel/ncc": "^0.38.1", "@vercel/ncc": "^0.34.0",
"eslint": "^8.57.0", "eslint": "^8.35.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^8.6.0",
"eslint-plugin-jest": "^27.9.0", "eslint-plugin-jest": "^27.2.1",
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
"husky": "^8.0.1", "husky": "^8.0.1",
"jest": "^29.7.0", "jest": "^27.5.1",
"jest-circus": "^29.7.0", "jest-circus": "^27.5.1",
"jest-each": "^29.7.0", "jest-each": "^27.5.1",
"prettier": "^3.2.5", "prettier": "^2.8.4",
"ts-jest": "^29.1.2", "ts-jest": "^27.0.5",
"typescript": "^5.4.2", "typescript": "^4.8.4",
"wget-improved": "^3.2.1" "wget-improved": "^3.2.1"
}, },
"jest": { "jest": {

View File

@@ -90,16 +90,9 @@ export function isCacheFeatureAvailable(): boolean {
/** /**
* Returns this action runs on GitHub Enterprise Server or not. * Returns this action runs on GitHub Enterprise Server or not.
* (port from https://github.com/actions/toolkit/blob/457303960f03375db6f033e214b9f90d79c3fe5c/packages/cache/src/internal/cacheUtils.ts#L134)
*/ */
function isGhes(): boolean { function isGhes(): boolean {
const ghUrl = new URL( const url = process.env['GITHUB_SERVER_URL'] || 'https://github.com';
process.env['GITHUB_SERVER_URL'] || 'https://github.com' return new URL(url).hostname.toUpperCase() !== 'GITHUB.COM';
);
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
const isGitHubHost = hostname === 'GITHUB.COM';
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
const isLocalHost = hostname.endsWith('.LOCALHOST');
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
} }

View File

@@ -7,7 +7,7 @@ import {chmodSync} from 'fs';
import path from 'path'; import path from 'path';
import os from 'os'; import os from 'os';
import semver from 'semver'; import semver from 'semver';
import {IS_WINDOWS, PLATFORM} from './utils'; import {IS_LINUX, IS_WINDOWS} from './utils';
import {QualityOptions} from './setup-dotnet'; import {QualityOptions} from './setup-dotnet';
export interface DotnetVersion { export interface DotnetVersion {
@@ -81,7 +81,7 @@ export class DotnetVersionResolver {
parseInt(major) >= QUALITY_INPUT_MINIMAL_MAJOR_TAG ? true : false; parseInt(major) >= QUALITY_INPUT_MINIMAL_MAJOR_TAG ? true : false;
} }
public async createDotnetVersion(): Promise<DotnetVersion> { public async createDotNetVersion(): Promise<DotnetVersion> {
await this.resolveVersionInput(); await this.resolveVersionInput();
if (!this.resolvedArgument.type) { if (!this.resolvedArgument.type) {
return this.resolvedArgument; return this.resolvedArgument;
@@ -101,9 +101,11 @@ export class DotnetVersionResolver {
allowRetries: true, allowRetries: true,
maxRetries: 3 maxRetries: 3
}); });
const response = await httpClient.getJson<any>( const response = await httpClient.getJson<any>(
DotnetVersionResolver.DotnetCoreIndexUrl DotnetVersionResolver.DotNetCoreIndexUrl
); );
const result = response.result || {}; const result = response.result || {};
const releasesInfo: any[] = result['releases-index']; const releasesInfo: any[] = result['releases-index'];
@@ -114,37 +116,85 @@ export class DotnetVersionResolver {
if (!releaseInfo) { if (!releaseInfo) {
throw new Error( throw new Error(
`Could not find info for version with major tag: "${majorTag}" at ${DotnetVersionResolver.DotnetCoreIndexUrl}` `Could not find info for version with major tag: "${majorTag}" at ${DotnetVersionResolver.DotNetCoreIndexUrl}`
); );
} }
return releaseInfo['channel-version']; return releaseInfo['channel-version'];
} }
static DotnetCoreIndexUrl = static DotNetCoreIndexUrl =
'https://dotnetcli.azureedge.net/dotnet/release-metadata/releases-index.json'; 'https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json';
} }
export class DotnetInstallScript { export class DotnetCoreInstaller {
private scriptName = IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh'; private version: string;
private escapedScript: string; private quality: QualityOptions;
private scriptArguments: string[] = [];
constructor() { static {
this.escapedScript = path const installationDirectoryWindows = path.join(
.join(__dirname, '..', '..', 'externals', this.scriptName) process.env['PROGRAMFILES'] + '',
.replace(/'/g, "''"); 'dotnet'
);
if (IS_WINDOWS) { const installationDirectoryLinux = '/usr/share/dotnet';
this.setupScriptPowershell(); const installationDirectoryMac = path.join(
return; process.env['HOME'] + '',
'.dotnet'
);
const dotnetInstallDir: string | undefined =
process.env['DOTNET_INSTALL_DIR'];
if (dotnetInstallDir) {
process.env['DOTNET_INSTALL_DIR'] =
this.convertInstallPathToAbsolute(dotnetInstallDir);
} else {
if (IS_WINDOWS) {
process.env['DOTNET_INSTALL_DIR'] = installationDirectoryWindows;
} else {
process.env['DOTNET_INSTALL_DIR'] = IS_LINUX
? installationDirectoryLinux
: installationDirectoryMac;
}
} }
this.setupScriptBash();
} }
private setupScriptPowershell() { constructor(version: string, quality: QualityOptions) {
this.scriptArguments = [ this.version = version;
this.quality = quality;
}
private static convertInstallPathToAbsolute(installDir: string): string {
let transformedPath;
if (path.isAbsolute(installDir)) {
transformedPath = installDir;
} else {
transformedPath = installDir.startsWith('~')
? path.join(os.homedir(), installDir.slice(1))
: (transformedPath = path.join(process.cwd(), installDir));
}
return path.normalize(transformedPath);
}
static addToPath() {
core.addPath(process.env['DOTNET_INSTALL_DIR']!);
core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']);
}
private setQuality(
dotnetVersion: DotnetVersion,
scriptArguments: string[]
): void {
const option = IS_WINDOWS ? '-Quality' : '--quality';
if (dotnetVersion.qualityFlag) {
scriptArguments.push(option, this.quality);
} else {
core.warning(
`The 'dotnet-quality' input can be used only with .NET SDK version in A.B, A.B.x, A, A.x and A.B.Cxx formats where the major tag is higher than 5. You specified: ${this.version}. 'dotnet-quality' input is ignored.`
);
}
}
public async installDotnet(): Promise<string | null> {
const windowsDefaultOptions = [
'-NoLogo', '-NoLogo',
'-Sta', '-Sta',
'-NoProfile', '-NoProfile',
@@ -153,160 +203,68 @@ export class DotnetInstallScript {
'Unrestricted', 'Unrestricted',
'-Command' '-Command'
]; ];
const scriptName = IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh';
const escapedScript = path
.join(__dirname, '..', '..', 'externals', scriptName)
.replace(/'/g, "''");
let scriptArguments: string[];
let scriptPath = '';
this.scriptArguments.push('&', `'${this.escapedScript}'`); const versionResolver = new DotnetVersionResolver(this.version);
const dotnetVersion = await versionResolver.createDotNetVersion();
if (process.env['https_proxy'] != null) {
this.scriptArguments.push(`-ProxyAddress ${process.env['https_proxy']}`);
}
// This is not currently an option
if (process.env['no_proxy'] != null) {
this.scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`);
}
}
private setupScriptBash() {
chmodSync(this.escapedScript, '777');
}
private async getScriptPath() {
if (IS_WINDOWS) { if (IS_WINDOWS) {
return (await io.which('pwsh', false)) || io.which('powershell', true); scriptArguments = ['&', `'${escapedScript}'`];
if (dotnetVersion.type) {
scriptArguments.push(dotnetVersion.type, dotnetVersion.value);
}
if (this.quality) {
this.setQuality(dotnetVersion, scriptArguments);
}
if (process.env['https_proxy'] != null) {
scriptArguments.push(`-ProxyAddress ${process.env['https_proxy']}`);
}
// This is not currently an option
if (process.env['no_proxy'] != null) {
scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`);
}
scriptPath =
(await io.which('pwsh', false)) || (await io.which('powershell', true));
scriptArguments = windowsDefaultOptions.concat(scriptArguments);
} else {
chmodSync(escapedScript, '777');
scriptPath = await io.which(escapedScript, true);
scriptArguments = [];
if (dotnetVersion.type) {
scriptArguments.push(dotnetVersion.type, dotnetVersion.value);
}
if (this.quality) {
this.setQuality(dotnetVersion, scriptArguments);
}
} }
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
return io.which(this.escapedScript, true);
}
public useArguments(...args: string[]) {
this.scriptArguments.push(...args);
return this;
}
public useVersion(dotnetVersion: DotnetVersion, quality?: QualityOptions) {
if (dotnetVersion.type) {
this.useArguments(dotnetVersion.type, dotnetVersion.value);
}
if (quality && !dotnetVersion.qualityFlag) {
core.warning(
`The 'dotnet-quality' input can be used only with .NET SDK version in A.B, A.B.x, A, A.x and A.B.Cxx formats where the major tag is higher than 5. You specified: ${dotnetVersion.value}. 'dotnet-quality' input is ignored.`
);
return this;
}
if (quality) {
this.useArguments(IS_WINDOWS ? '-Quality' : '--quality', quality);
}
return this;
}
public async execute() {
const getExecOutputOptions = { const getExecOutputOptions = {
ignoreReturnCode: true, ignoreReturnCode: true,
env: process.env as {string: string} env: process.env as {string: string}
}; };
const {exitCode, stdout, stderr} = await exec.getExecOutput(
return exec.getExecOutput( `"${scriptPath}"`,
`"${await this.getScriptPath()}"`, scriptArguments,
this.scriptArguments,
getExecOutputOptions getExecOutputOptions
); );
} if (exitCode) {
}
export abstract class DotnetInstallDir {
private static readonly default = {
linux: '/usr/share/dotnet',
mac: path.join(process.env['HOME'] + '', '.dotnet'),
windows: path.join(process.env['PROGRAMFILES'] + '', 'dotnet')
};
public static readonly dirPath = process.env['DOTNET_INSTALL_DIR']
? DotnetInstallDir.convertInstallPathToAbsolute(
process.env['DOTNET_INSTALL_DIR']
)
: DotnetInstallDir.default[PLATFORM];
private static convertInstallPathToAbsolute(installDir: string): string {
if (path.isAbsolute(installDir)) return path.normalize(installDir);
const transformedPath = installDir.startsWith('~')
? path.join(os.homedir(), installDir.slice(1))
: path.join(process.cwd(), installDir);
return path.normalize(transformedPath);
}
public static addToPath() {
core.addPath(process.env['DOTNET_INSTALL_DIR']!);
core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']);
}
public static setEnvironmentVariable() {
process.env['DOTNET_INSTALL_DIR'] = DotnetInstallDir.dirPath;
}
}
export class DotnetCoreInstaller {
static {
DotnetInstallDir.setEnvironmentVariable();
}
constructor(
private version: string,
private quality: QualityOptions
) {}
public async installDotnet(): Promise<string | null> {
const versionResolver = new DotnetVersionResolver(this.version);
const dotnetVersion = await versionResolver.createDotnetVersion();
/**
* Install dotnet runitme first in order to get
* the latest stable version of dotnet CLI
*/
const runtimeInstallOutput = await new DotnetInstallScript()
// If dotnet CLI is already installed - avoid overwriting it
.useArguments(
IS_WINDOWS ? '-SkipNonVersionedFiles' : '--skip-non-versioned-files'
)
// Install only runtime + CLI
.useArguments(IS_WINDOWS ? '-Runtime' : '--runtime', 'dotnet')
// Use latest stable version
.useArguments(IS_WINDOWS ? '-Channel' : '--channel', 'LTS')
.execute();
if (runtimeInstallOutput.exitCode) {
/**
* dotnetInstallScript will install CLI and runtime even if previous script haven't succeded,
* so at this point it's too early to throw an error
*/
core.warning(
`Failed to install dotnet runtime + cli, exit code: ${runtimeInstallOutput.exitCode}. ${runtimeInstallOutput.stderr}`
);
}
/**
* Install dotnet over the latest version of
* dotnet CLI
*/
const dotnetInstallOutput = await new DotnetInstallScript()
// Don't overwrite CLI because it should be already installed
.useArguments(
IS_WINDOWS ? '-SkipNonVersionedFiles' : '--skip-non-versioned-files'
)
// Use version provided by user
.useVersion(dotnetVersion, this.quality)
.execute();
if (dotnetInstallOutput.exitCode) {
throw new Error( throw new Error(
`Failed to install dotnet, exit code: ${dotnetInstallOutput.exitCode}. ${dotnetInstallOutput.stderr}` `Failed to install dotnet, exit code: ${exitCode}. ${stderr}`
); );
} }
return this.parseInstalledVersion(dotnetInstallOutput.stdout); return this.parseInstalledVersion(stdout);
} }
private parseInstalledVersion(stdout: string): string | null { private parseInstalledVersion(stdout: string): string | null {

View File

@@ -1,5 +1,5 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import {DotnetCoreInstaller, DotnetInstallDir} from './installer'; import {DotnetCoreInstaller} from './installer';
import * as fs from 'fs'; import * as fs from 'fs';
import path from 'path'; import path from 'path';
import semver from 'semver'; import semver from 'semver';
@@ -7,7 +7,6 @@ import * as auth from './authutil';
import {isCacheFeatureAvailable} from './cache-utils'; import {isCacheFeatureAvailable} from './cache-utils';
import {restoreCache} from './cache-restore'; import {restoreCache} from './cache-restore';
import {Outputs} from './constants'; import {Outputs} from './constants';
import JSON5 from 'json5';
const qualityOptions = [ const qualityOptions = [
'daily', 'daily',
@@ -73,7 +72,7 @@ export async function run() {
const installedVersion = await dotnetInstaller.installDotnet(); const installedVersion = await dotnetInstaller.installDotnet();
installedDotnetVersions.push(installedVersion); installedDotnetVersions.push(installedVersion);
} }
DotnetInstallDir.addToPath(); DotnetCoreInstaller.addToPath();
} }
const sourceUrl: string = core.getInput('source-url'); const sourceUrl: string = core.getInput('source-url');
@@ -98,14 +97,9 @@ export async function run() {
function getVersionFromGlobalJson(globalJsonPath: string): string { function getVersionFromGlobalJson(globalJsonPath: string): string {
let version = ''; let version = '';
const globalJson = JSON5.parse( const globalJson = JSON.parse(
// .trim() is necessary to strip BOM https://github.com/nodejs/node/issues/20649 // .trim() is necessary to strip BOM https://github.com/nodejs/node/issues/20649
fs.readFileSync(globalJsonPath, {encoding: 'utf8'}).trim(), fs.readFileSync(globalJsonPath, {encoding: 'utf8'}).trim()
// is necessary as JSON5 supports wider variety of options for numbers: https://www.npmjs.com/package/json5#numbers
(key, value) => {
if (key === 'version' || key === 'rollForward') return String(value);
return value;
}
); );
if (globalJson.sdk && globalJson.sdk.version) { if (globalJson.sdk && globalJson.sdk.version) {
version = globalJson.sdk.version; version = globalJson.sdk.version;

View File

@@ -1,6 +1,2 @@
export const IS_WINDOWS = process.platform === 'win32'; export const IS_WINDOWS = process.platform === 'win32';
export const PLATFORM = ((): 'windows' | 'linux' | 'mac' => { export const IS_LINUX = process.platform === 'linux';
if (process.platform === 'win32') return 'windows';
if (process.platform === 'linux') return 'linux';
return 'mac';
})();