Skip to content

Commit af9211b

Browse files
Add dotnet-version: latest support with dotnet-channel input (#730)
* feat: add dotnet-version: latest keyword with dotnet-channel support (#497) * restore test-proxy container image * update e2e-tests.yml and documentation * fix(tests): correct release-type and support-phase values in latest-version test mocks
1 parent df991ae commit af9211b

9 files changed

Lines changed: 687 additions & 50 deletions

File tree

.github/workflows/e2e-tests.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,3 +649,44 @@ jobs:
649649
- name: Verify dotnet
650650
shell: pwsh
651651
run: __tests__/verify-dotnet.ps1 -Patterns "^8.0.416$", "^9.0.308$", "^10.0.101$", "^8.0"
652+
653+
test-setup-latest-version:
654+
runs-on: ${{ matrix.operating-system }}
655+
strategy:
656+
fail-fast: false
657+
matrix:
658+
operating-system: [ubuntu-latest]
659+
steps:
660+
- name: Checkout
661+
uses: actions/checkout@v6
662+
- name: Clear toolcache
663+
shell: pwsh
664+
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
665+
- name: Setup dotnet latest
666+
uses: ./
667+
with:
668+
dotnet-version: latest
669+
- name: Verify dotnet
670+
shell: pwsh
671+
run: __tests__/verify-dotnet.ps1 -Patterns "^\d+\.\d+\.\d+"
672+
673+
test-setup-latest-with-channel-abcxx:
674+
runs-on: ${{ matrix.operating-system }}
675+
strategy:
676+
fail-fast: false
677+
matrix:
678+
operating-system: [macos-latest]
679+
steps:
680+
- name: Checkout
681+
uses: actions/checkout@v6
682+
- name: Clear toolcache
683+
shell: pwsh
684+
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
685+
- name: Setup dotnet latest with A.B.Cxx channel
686+
uses: ./
687+
with:
688+
dotnet-version: latest
689+
dotnet-channel: '9.0.1xx'
690+
- name: Verify dotnet
691+
shell: pwsh
692+
run: __tests__/verify-dotnet.ps1 -Patterns "^9\.0\.1\d{2}"

README.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,30 @@ The `dotnet-version` input supports following syntax:
5757
- **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)
5858
- **A** or **A.x** (e.g. 8, 8.x) - installs the latest minor version of the specified major tag, including prerelease versions (preview, rc)
5959
- **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).
60+
- **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`.
6061

62+
## Using with `dotnet-channel` input
63+
64+
The optional `dotnet-channel` input specifies the source channel for the installation. Supported values:
65+
66+
| Value | Description |
67+
|-------|-------------|
68+
| `STS` | The most recent Standard Term Support release |
69+
| `LTS` | The most recent Long Term Support release |
70+
| `A.B` (e.g. `8.0`) | A specific release channel |
71+
| `A.B.Cxx` (e.g. `8.0.1xx`) | A specific SDK release (available since 5.0) |
72+
73+
> **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.
74+
75+
**Install latest LTS version:**
76+
```yaml
77+
steps:
78+
- uses: actions/checkout@v6
79+
- uses: actions/setup-dotnet@v5
80+
with:
81+
dotnet-version: latest
82+
dotnet-channel: LTS
83+
```
6184

6285
## Using the `architecture` input
6386
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).
@@ -77,9 +100,10 @@ steps:
77100
```
78101

79102
## Using the `dotnet-quality` input
80-
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**.
81103

82-
> **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.
104+
The `dotnet-quality` input installs the latest build of the specified quality in the channel. Supported values: `daily`, `preview`, `ga`.
105+
106+
> **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.
83107

84108
```yml
85109
steps:
@@ -91,6 +115,18 @@ steps:
91115
- run: dotnet build <my project>
92116
```
93117

118+
`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.
119+
120+
```yaml
121+
steps:
122+
- uses: actions/checkout@v6
123+
- uses: actions/setup-dotnet@v5
124+
with:
125+
dotnet-version: latest
126+
dotnet-channel: LTS
127+
dotnet-quality: daily
128+
```
129+
94130
## Using the `global-json-file` input
95131
`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.
96132

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

372408
## Contributions
373409

374-
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
410+
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)

__tests__/installer.test.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import * as io from '@actions/io';
99
import * as installer from '../src/installer';
1010

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

1413
describe('installer tests', () => {
1514
const env = process.env;
@@ -40,7 +39,7 @@ describe('installer tests', () => {
4039

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

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

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

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

9089
getExecOutputSpy.mockImplementation(() => {
@@ -122,7 +121,7 @@ describe('installer tests', () => {
122121

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

148147
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 () => {
149148
const inputVersion = '3.1';
150-
const inputQuality = 'ga' as QualityOptions;
149+
const inputQuality = 'ga';
151150
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;
152151

153152
getExecOutputSpy.mockImplementation(() => {
@@ -174,7 +173,7 @@ describe('installer tests', () => {
174173
each(['10', '10.0', '10.0.x', '10.0.*', '10.0.X']).test(
175174
`should supply 'quality' argument to the installation script if quality input is set and version (%s) is not in A.B.C syntax`,
176175
async inputVersion => {
177-
const inputQuality = 'ga' as QualityOptions;
176+
const inputQuality = 'ga';
178177
const exitCode = 0;
179178
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;
180179
getExecOutputSpy.mockImplementation(() => {
@@ -214,7 +213,7 @@ describe('installer tests', () => {
214213
each(['10', '10.0', '10.0.x', '10.0.*', '10.0.X']).test(
215214
`should supply 'channel' argument to the installation script if version (%s) isn't in A.B.C syntax`,
216215
async inputVersion => {
217-
const inputQuality = '' as QualityOptions;
216+
const inputQuality = '';
218217
const exitCode = 0;
219218
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;
220219
getExecOutputSpy.mockImplementation(() => {
@@ -255,7 +254,7 @@ describe('installer tests', () => {
255254
it(`should supply '-ProxyAddress' argument to the installation script if env.variable 'https_proxy' is set`, async () => {
256255
process.env['https_proxy'] = 'https://proxy.com';
257256
const inputVersion = '10.0.101';
258-
const inputQuality = '' as QualityOptions;
257+
const inputQuality = '';
259258
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;
260259

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

299298
getExecOutputSpy.mockImplementation(() => {
@@ -331,7 +330,7 @@ describe('installer tests', () => {
331330

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

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

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

371370
getExecOutputSpy.mockImplementation(() => {
@@ -395,7 +394,7 @@ describe('installer tests', () => {
395394

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

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

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

0 commit comments

Comments
 (0)