mirror of
https://github.com/actions/setup-dotnet.git
synced 2024-11-22 19:41:08 +07:00
feat: support rollForward latest variants
This commit is contained in:
parent
2216f56ae1
commit
bc45ec257e
77
.github/workflows/e2e-tests.yml
vendored
77
.github/workflows/e2e-tests.yml
vendored
@ -203,7 +203,82 @@ jobs:
|
|||||||
- name: Verify dotnet
|
- name: Verify dotnet
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: __tests__/verify-dotnet.ps1 -Patterns "^2.2", "^3.1"
|
run: __tests__/verify-dotnet.ps1 -Patterns "^2.2", "^3.1"
|
||||||
|
|
||||||
|
test-setup-global-json-rollforward-latestminor:
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
operating-system: [ ubuntu-latest, windows-latest, macOS-latest ]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Clear toolcache
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||||
|
- name: Write global.json
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir subdirectory
|
||||||
|
echo '{"sdk":{"version": "3.0.100","rollForward": "latestMinor"}}' > ./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 "^3.1"
|
||||||
|
|
||||||
|
test-setup-global-json-rollforward-latestfeature:
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
operating-system: [ ubuntu-latest, windows-latest, macOS-latest ]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Clear toolcache
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||||
|
- name: Write global.json
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir subdirectory
|
||||||
|
echo '{"sdk":{"version": "3.1.100","rollForward": "latestFeature"}}' > ./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 "^3.1.4"
|
||||||
|
|
||||||
|
test-setup-global-json-rollforward-latestpatch:
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
operating-system: [ ubuntu-latest, windows-latest, macOS-latest ]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Clear toolcache
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||||
|
- name: Write global.json
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir subdirectory
|
||||||
|
echo '{"sdk":{"version": "3.1.400","rollForward": "latestPatch"}}' > ./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 "^3.1.426$"
|
||||||
|
|
||||||
test-setup-global-json-only:
|
test-setup-global-json-only:
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
strategy:
|
strategy:
|
||||||
|
24
dist/setup/index.js
vendored
24
dist/setup/index.js
vendored
@ -73235,9 +73235,27 @@ function getVersionFromGlobalJson(globalJsonPath) {
|
|||||||
if (globalJson.sdk && globalJson.sdk.version) {
|
if (globalJson.sdk && globalJson.sdk.version) {
|
||||||
version = globalJson.sdk.version;
|
version = globalJson.sdk.version;
|
||||||
const rollForward = globalJson.sdk.rollForward;
|
const rollForward = globalJson.sdk.rollForward;
|
||||||
if (rollForward && rollForward === 'latestFeature') {
|
if (rollForward && rollForward.startsWith('latest')) {
|
||||||
const [major, minor] = version.split('.');
|
const [major, minor, featurePatch] = version.split('.');
|
||||||
version = `${major}.${minor}`;
|
const feature = featurePatch.substring(0, 1);
|
||||||
|
|
||||||
|
switch (rollForward) {
|
||||||
|
case 'latestMajor':
|
||||||
|
version = '';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'latestMinor':
|
||||||
|
version = `${major}`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'latestFeature':
|
||||||
|
version = `${major}.${minor}`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'latestPatch':
|
||||||
|
version = `${major}.${minor}.${feature}`
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
|
@ -110,9 +110,27 @@ function getVersionFromGlobalJson(globalJsonPath: string): string {
|
|||||||
if (globalJson.sdk && globalJson.sdk.version) {
|
if (globalJson.sdk && globalJson.sdk.version) {
|
||||||
version = globalJson.sdk.version;
|
version = globalJson.sdk.version;
|
||||||
const rollForward = globalJson.sdk.rollForward;
|
const rollForward = globalJson.sdk.rollForward;
|
||||||
if (rollForward && rollForward === 'latestFeature') {
|
if (rollForward && rollForward.startsWith('latest')) {
|
||||||
const [major, minor] = version.split('.');
|
const [major, minor, featurePatch] = version.split('.');
|
||||||
version = `${major}.${minor}`;
|
const feature = featurePatch.substring(0, 1);
|
||||||
|
|
||||||
|
switch (rollForward) {
|
||||||
|
case 'latestMajor':
|
||||||
|
version = '';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'latestMinor':
|
||||||
|
version = `${major}`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'latestFeature':
|
||||||
|
version = `${major}.${minor}`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'latestPatch':
|
||||||
|
version = `${major}.${minor}.${feature}`
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
|
Loading…
Reference in New Issue
Block a user