Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ jobs:
test-proxy:
runs-on: ubuntu-22.04
container:
image: mcr.microsoft.com/devcontainers/dotnet:10.0
image: ubuntu:22.04
options: --dns 127.0.0.1
services:
squid-proxy:
Expand All @@ -508,6 +508,15 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Powershell
run: |
apt-get update
apt-get install -y wget apt-transport-https software-properties-common
wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
Comment thread
mahabaleshwars marked this conversation as resolved.
Outdated
dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
apt-get update
apt-get install -y powershell
- name: Clear toolcache
shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
Expand Down Expand Up @@ -649,3 +658,44 @@ jobs:
- name: Verify dotnet
shell: pwsh
run: __tests__/verify-dotnet.ps1 -Patterns "^8.0.416$", "^9.0.308$", "^10.0.101$", "^8.0"

test-setup-latest-version:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Clear toolcache
shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
- name: Setup dotnet latest
uses: ./
with:
dotnet-version: latest
- name: Verify dotnet
shell: pwsh
run: __tests__/verify-dotnet.ps1 -Patterns "^\d+\.\d+\.\d+"

test-setup-latest-with-channel-abcxx:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Clear toolcache
shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
- name: Setup dotnet latest with A.B.Cxx channel
uses: ./
with:
dotnet-version: latest
dotnet-channel: '9.0.1xx'
- name: Verify dotnet
shell: pwsh
run: __tests__/verify-dotnet.ps1 -Patterns "^9\.0\.1\d{2}"
44 changes: 40 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,30 @@ The `dotnet-version` input supports following syntax:
- **A.B** or **A.B.x** (e.g. 8.0, 8.0.x) - installs the latest patch version of .NET SDK on the channel `8.0`, including prerelease versions (preview, rc)
- **A** or **A.x** (e.g. 8, 8.x) - installs the latest minor version of the specified major tag, including prerelease versions (preview, rc)
- **A.B.Cxx** (e.g. 8.0.4xx) - available since `.NET 5.0` release. Installs the latest version of the specific SDK release, including prerelease versions (preview, rc).
- **latest** - dynamically resolves to the highest active .NET SDK version. By default, it installs the latest **stable (GA)** version (excluding previews and end-of-life releases). Can be combined with `dotnet-channel` and `dotnet-quality`.

## Using with `dotnet-channel` input

The optional `dotnet-channel` input specifies the source channel for the installation. Supported values:

| Value | Description |
|-------|-------------|
| `STS` | The most recent Standard Term Support release |
| `LTS` | The most recent Long Term Support release |
| `A.B` (e.g. `8.0`) | A specific release channel |
| `A.B.Cxx` (e.g. `8.0.1xx`) | A specific SDK release (available since 5.0) |

> **Note**: The `dotnet-channel` input is only applied when `dotnet-version` is set to `latest`. If used with a specific version, a warning will be logged and the channel input will be ignored.

**Install latest LTS version:**
```yaml
steps:
- uses: actions/checkout@v6
- uses: actions/setup-dotnet@v5
with:
dotnet-version: latest
dotnet-channel: LTS
```

## Using the `architecture` input
Using the architecture input, it is possible to specify the required .NET SDK architecture. Possible values: `x64`, `x86`, `arm64`, `amd64`, `arm`, `s390x`, `ppc64le`, `riscv64`. If the input is not specified, the architecture defaults to the host OS architecture (not all of the architectures are available on all platforms).
Expand All @@ -77,20 +100,33 @@ steps:
```

## Using the `dotnet-quality` input
This input sets up the action to install the latest build of the specified quality in the channel. The possible values of `dotnet-quality` are: **daily**, **signed**, **validated**, **preview**, **ga**.

> **Note**: `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 version is higher than 5. In other cases, `dotnet-quality` input will be ignored.
The `dotnet-quality` input installs the latest build of the specified quality in the channel. Supported values: `daily`, `preview`, `ga`.

> **Note**: When used with a specific SDK version, `dotnet-quality` supports only `A.B`, `A.B.x`, `A`, `A.x`, and `A.B.Cxx` formats where the major version is higher than 5. For all other formats, `dotnet-quality` will be ignored.

```yml
steps:
- uses: actions/checkout@v6
- uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'
dotnet-quality: 'preview'
dotnet-quality: 'daily'
- run: dotnet build <my project>
```

`dotnet-quality` can also be combined with `dotnet-version: latest` and `dotnet-channel` to target specific builds such as the latest `daily` build from the `LTS` channel.

```yaml
steps:
- uses: actions/checkout@v6
- uses: actions/setup-dotnet@v5
with:
dotnet-version: latest
dotnet-channel: LTS
dotnet-quality: daily
```

## Using the `global-json-file` input
`setup-dotnet` action can read .NET SDK version from a `global.json` file. Input `global-json-file` is used for specifying the path to the `global.json`. If the file that was supplied to `global-json-file` input doesn't exist, the action will fail with error.

Expand Down Expand Up @@ -371,4 +407,4 @@ The scripts and documentation in this project are released under the [MIT Licens

## Contributions

Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
27 changes: 13 additions & 14 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import * as io from '@actions/io';
import * as installer from '../src/installer';

import {IS_WINDOWS} from '../src/utils';
import {QualityOptions} from '../src/setup-dotnet';

describe('installer tests', () => {
const env = process.env;
Expand Down Expand Up @@ -40,7 +39,7 @@ describe('installer tests', () => {

it('should throw the error in case of non-zero exit code of the installation script. The error message should contain logs.', async () => {
const inputVersion = '10.0.101';
const inputQuality = '' as QualityOptions;
const inputQuality = '';
const errorMessage = 'fictitious error message!';

getExecOutputSpy.mockImplementation(() => {
Expand All @@ -62,7 +61,7 @@ describe('installer tests', () => {

it('should return version of .NET SDK after installation complete', async () => {
const inputVersion = '10.0.101';
const inputQuality = '' as QualityOptions;
const inputQuality = '';
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;
getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
Expand All @@ -84,7 +83,7 @@ describe('installer tests', () => {

it(`should supply 'version' argument to the installation script if supplied version is in A.B.C syntax`, async () => {
const inputVersion = '10.0.101';
const inputQuality = '' as QualityOptions;
const inputQuality = '';
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;

getExecOutputSpy.mockImplementation(() => {
Expand Down Expand Up @@ -122,7 +121,7 @@ describe('installer tests', () => {

it(`should warn if the 'quality' input is set and the supplied version is in A.B.C syntax`, async () => {
const inputVersion = '10.0.101';
const inputQuality = 'ga' as QualityOptions;
const inputQuality = 'ga';
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;
getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
Expand All @@ -147,7 +146,7 @@ describe('installer tests', () => {

it(`should warn if the 'quality' input is set and version isn't in A.B.C syntax but major tag is lower then 6`, async () => {
const inputVersion = '3.1';
const inputQuality = 'ga' as QualityOptions;
const inputQuality = 'ga';
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;

getExecOutputSpy.mockImplementation(() => {
Expand All @@ -174,7 +173,7 @@ describe('installer tests', () => {
each(['10', '10.0', '10.0.x', '10.0.*', '10.0.X']).test(
`should supply 'quality' argument to the installation script if quality input is set and version (%s) is not in A.B.C syntax`,
async inputVersion => {
const inputQuality = 'ga' as QualityOptions;
const inputQuality = 'ga';
const exitCode = 0;
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;
getExecOutputSpy.mockImplementation(() => {
Expand Down Expand Up @@ -214,7 +213,7 @@ describe('installer tests', () => {
each(['10', '10.0', '10.0.x', '10.0.*', '10.0.X']).test(
`should supply 'channel' argument to the installation script if version (%s) isn't in A.B.C syntax`,
async inputVersion => {
const inputQuality = '' as QualityOptions;
const inputQuality = '';
const exitCode = 0;
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;
getExecOutputSpy.mockImplementation(() => {
Expand Down Expand Up @@ -255,7 +254,7 @@ describe('installer tests', () => {
it(`should supply '-ProxyAddress' argument to the installation script if env.variable 'https_proxy' is set`, async () => {
process.env['https_proxy'] = 'https://proxy.com';
const inputVersion = '10.0.101';
const inputQuality = '' as QualityOptions;
const inputQuality = '';
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;

getExecOutputSpy.mockImplementation(() => {
Expand Down Expand Up @@ -293,7 +292,7 @@ describe('installer tests', () => {
it(`should supply '-ProxyBypassList' argument to the installation script if env.variable 'no_proxy' is set`, async () => {
process.env['no_proxy'] = 'first.url,second.url';
const inputVersion = '10.0.101';
const inputQuality = '' as QualityOptions;
const inputQuality = '';
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;

getExecOutputSpy.mockImplementation(() => {
Expand Down Expand Up @@ -331,7 +330,7 @@ describe('installer tests', () => {

it(`should supply 'architecture' argument to the installation script when architecture is provided`, async () => {
const inputVersion = '10.0.101';
const inputQuality = '' as QualityOptions;
const inputQuality = '';
const inputArchitecture = 'x64';
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;

Expand Down Expand Up @@ -365,7 +364,7 @@ describe('installer tests', () => {

it(`should NOT supply 'architecture' argument when architecture is not provided`, async () => {
const inputVersion = '10.0.101';
const inputQuality = '' as QualityOptions;
const inputQuality = '';
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;

getExecOutputSpy.mockImplementation(() => {
Expand Down Expand Up @@ -395,7 +394,7 @@ describe('installer tests', () => {

it(`should supply 'install-dir' with arch subdirectory for cross-arch install`, async () => {
const inputVersion = '10.0.101';
const inputQuality = '' as QualityOptions;
const inputQuality = '';
const inputArchitecture = 'x64';
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;

Expand Down Expand Up @@ -436,7 +435,7 @@ describe('installer tests', () => {

it(`should NOT supply 'install-dir' when architecture matches runner's native arch`, async () => {
const inputVersion = '10.0.101';
const inputQuality = '' as QualityOptions;
const inputQuality = '';
const nativeArch = os.arch().toLowerCase();
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;

Expand Down
Loading
Loading