mirror of
https://github.com/actions/setup-dotnet.git
synced 2024-11-22 19:41:08 +07:00
Merge pull request #110 from GGG-KILLER/feature/include-prerelease
Include include-prerelease option to be able to match latest prerelease versions
This commit is contained in:
commit
7b2009794e
@ -13,6 +13,9 @@ inputs:
|
|||||||
description: 'Optional OWNER for using packages from GitHub Package Registry organizations/users other than the current repository''s owner. Only used if a GPR URL is also provided in source-url'
|
description: 'Optional OWNER for using packages from GitHub Package Registry organizations/users other than the current repository''s owner. Only used if a GPR URL is also provided in source-url'
|
||||||
config-file:
|
config-file:
|
||||||
description: 'Optional NuGet.config location, if your NuGet.config isn''t located in the root of the repo.'
|
description: 'Optional NuGet.config location, if your NuGet.config isn''t located in the root of the repo.'
|
||||||
|
include-prerelease:
|
||||||
|
description: 'Whether prerelease versions should be matched with non-exact versions (for example 5.0.0-preview.6 being matched by 5, 5.0, 5.x or 5.0.x). Defaults to false if not provided.'
|
||||||
|
required: False
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
24
dist/index.js
vendored
24
dist/index.js
vendored
@ -7838,7 +7838,9 @@ function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (version) {
|
if (version) {
|
||||||
const dotnetInstaller = new installer.DotnetCoreInstaller(version);
|
const includePrerelease = (core.getInput('include-prerelease') || 'false').toLowerCase() ===
|
||||||
|
'true';
|
||||||
|
const dotnetInstaller = new installer.DotnetCoreInstaller(version, includePrerelease);
|
||||||
yield dotnetInstaller.installDotnet();
|
yield dotnetInstaller.installDotnet();
|
||||||
}
|
}
|
||||||
const sourceUrl = core.getInput('source-url');
|
const sourceUrl = core.getInput('source-url');
|
||||||
@ -16885,7 +16887,6 @@ class DotNetVersionInfo {
|
|||||||
this.isExactVersionSet = true;
|
this.isExactVersionSet = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Note: No support for previews when using generic
|
|
||||||
const parts = version.split('.');
|
const parts = version.split('.');
|
||||||
if (parts.length < 2 || parts.length > 3)
|
if (parts.length < 2 || parts.length > 3)
|
||||||
this.throwInvalidVersionFormat();
|
this.throwInvalidVersionFormat();
|
||||||
@ -16927,8 +16928,9 @@ class DotNetVersionInfo {
|
|||||||
}
|
}
|
||||||
exports.DotNetVersionInfo = DotNetVersionInfo;
|
exports.DotNetVersionInfo = DotNetVersionInfo;
|
||||||
class DotnetCoreInstaller {
|
class DotnetCoreInstaller {
|
||||||
constructor(version) {
|
constructor(version, includePrerelease = false) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
this.includePrerelease = includePrerelease;
|
||||||
}
|
}
|
||||||
installDotnet() {
|
installDotnet() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
@ -17035,14 +17037,22 @@ class DotnetCoreInstaller {
|
|||||||
const releasesResult = releasesResponse.result || {};
|
const releasesResult = releasesResponse.result || {};
|
||||||
let releasesInfo = releasesResult['releases'];
|
let releasesInfo = releasesResult['releases'];
|
||||||
releasesInfo = releasesInfo.filter((releaseInfo) => {
|
releasesInfo = releasesInfo.filter((releaseInfo) => {
|
||||||
return (semver.satisfies(releaseInfo['sdk']['version'], versionInfo.version()) ||
|
return (semver.satisfies(releaseInfo['sdk']['version'], versionInfo.version(), {
|
||||||
semver.satisfies(releaseInfo['sdk']['version-display'], versionInfo.version()));
|
includePrerelease: this.includePrerelease
|
||||||
|
}) ||
|
||||||
|
semver.satisfies(releaseInfo['sdk']['version-display'], versionInfo.version(), {
|
||||||
|
includePrerelease: this.includePrerelease
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
// Exclude versions that are newer than the latest if using not exact
|
// Exclude versions that are newer than the latest if using not exact
|
||||||
let latestSdk = releasesResult['latest-sdk'];
|
let latestSdk = releasesResult['latest-sdk'];
|
||||||
releasesInfo = releasesInfo.filter((releaseInfo) => semver.lte(releaseInfo['sdk']['version'], latestSdk));
|
releasesInfo = releasesInfo.filter((releaseInfo) => semver.lte(releaseInfo['sdk']['version'], latestSdk, {
|
||||||
|
includePrerelease: this.includePrerelease
|
||||||
|
}));
|
||||||
// Sort for latest version
|
// Sort for latest version
|
||||||
releasesInfo = releasesInfo.sort((a, b) => semver.rcompare(a['sdk']['version'], b['sdk']['version']));
|
releasesInfo = releasesInfo.sort((a, b) => semver.rcompare(a['sdk']['version'], b['sdk']['version'], {
|
||||||
|
includePrerelease: this.includePrerelease
|
||||||
|
}));
|
||||||
if (releasesInfo.length == 0) {
|
if (releasesInfo.length == 0) {
|
||||||
throw new Error(`Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`);
|
throw new Error(`Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ export class DotNetVersionInfo {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Note: No support for previews when using generic
|
|
||||||
const parts: string[] = version.split('.');
|
const parts: string[] = version.split('.');
|
||||||
|
|
||||||
if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat();
|
if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat();
|
||||||
@ -80,8 +79,9 @@ export class DotNetVersionInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class DotnetCoreInstaller {
|
export class DotnetCoreInstaller {
|
||||||
constructor(version: string) {
|
constructor(version: string, includePrerelease: boolean = false) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
this.includePrerelease = includePrerelease;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async installDotnet() {
|
public async installDotnet() {
|
||||||
@ -216,13 +216,15 @@ export class DotnetCoreInstaller {
|
|||||||
let releasesInfo: any[] = releasesResult['releases'];
|
let releasesInfo: any[] = releasesResult['releases'];
|
||||||
releasesInfo = releasesInfo.filter((releaseInfo: any) => {
|
releasesInfo = releasesInfo.filter((releaseInfo: any) => {
|
||||||
return (
|
return (
|
||||||
semver.satisfies(
|
semver.satisfies(releaseInfo['sdk']['version'], versionInfo.version(), {
|
||||||
releaseInfo['sdk']['version'],
|
includePrerelease: this.includePrerelease
|
||||||
versionInfo.version()
|
}) ||
|
||||||
) ||
|
|
||||||
semver.satisfies(
|
semver.satisfies(
|
||||||
releaseInfo['sdk']['version-display'],
|
releaseInfo['sdk']['version-display'],
|
||||||
versionInfo.version()
|
versionInfo.version(),
|
||||||
|
{
|
||||||
|
includePrerelease: this.includePrerelease
|
||||||
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -231,12 +233,16 @@ export class DotnetCoreInstaller {
|
|||||||
let latestSdk: string = releasesResult['latest-sdk'];
|
let latestSdk: string = releasesResult['latest-sdk'];
|
||||||
|
|
||||||
releasesInfo = releasesInfo.filter((releaseInfo: any) =>
|
releasesInfo = releasesInfo.filter((releaseInfo: any) =>
|
||||||
semver.lte(releaseInfo['sdk']['version'], latestSdk)
|
semver.lte(releaseInfo['sdk']['version'], latestSdk, {
|
||||||
|
includePrerelease: this.includePrerelease
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// Sort for latest version
|
// Sort for latest version
|
||||||
releasesInfo = releasesInfo.sort((a, b) =>
|
releasesInfo = releasesInfo.sort((a, b) =>
|
||||||
semver.rcompare(a['sdk']['version'], b['sdk']['version'])
|
semver.rcompare(a['sdk']['version'], b['sdk']['version'], {
|
||||||
|
includePrerelease: this.includePrerelease
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
if (releasesInfo.length == 0) {
|
if (releasesInfo.length == 0) {
|
||||||
@ -281,6 +287,7 @@ export class DotnetCoreInstaller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private version: string;
|
private version: string;
|
||||||
|
private includePrerelease: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DotNetCoreIndexUrl: string =
|
const DotNetCoreIndexUrl: string =
|
||||||
|
@ -30,7 +30,14 @@ export async function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (version) {
|
if (version) {
|
||||||
const dotnetInstaller = new installer.DotnetCoreInstaller(version);
|
const includePrerelease: boolean =
|
||||||
|
(core.getInput('include-prerelease') || 'false').toLowerCase() ===
|
||||||
|
'true';
|
||||||
|
|
||||||
|
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||||
|
version,
|
||||||
|
includePrerelease
|
||||||
|
);
|
||||||
await dotnetInstaller.installDotnet();
|
await dotnetInstaller.installDotnet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user