From ba7e1e215534139b0ddff02eb65b2f2897a85c37 Mon Sep 17 00:00:00 2001 From: GGG KILLER Date: Thu, 16 Jul 2020 19:22:49 -0300 Subject: [PATCH 1/3] Include include-prerelease input in action.yml --- action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/action.yml b/action.yml index df5b215..ab0fe9e 100644 --- a/action.yml +++ b/action.yml @@ -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' config-file: 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: using: 'node12' main: 'dist/index.js' From 768b4eb7db215baebe4cbdb1e72ad73c00206679 Mon Sep 17 00:00:00 2001 From: GGG KILLER Date: Thu, 16 Jul 2020 19:23:46 -0300 Subject: [PATCH 2/3] Implement passing includePrerelase to semver --- dist/index.js | 24 +++++++++++++++++------- src/installer.ts | 25 ++++++++++++++++--------- src/setup-dotnet.ts | 9 ++++++++- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/dist/index.js b/dist/index.js index 15f8a3b..e51206f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7821,7 +7821,9 @@ function run() { } } 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(); } const sourceUrl = core.getInput('source-url'); @@ -16868,7 +16870,6 @@ class DotNetVersionInfo { this.isExactVersionSet = true; return; } - //Note: No support for previews when using generic let parts = version.split('.'); if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat(); @@ -16908,8 +16909,9 @@ class DotNetVersionInfo { } exports.DotNetVersionInfo = DotNetVersionInfo; class DotnetCoreInstaller { - constructor(version) { + constructor(version, includePrerelease = false) { this.version = version; + this.includePrerelease = includePrerelease; } installDotnet() { return __awaiter(this, void 0, void 0, function* () { @@ -17016,14 +17018,22 @@ class DotnetCoreInstaller { const releasesResult = releasesResponse.result || {}; let releasesInfo = releasesResult['releases']; releasesInfo = releasesInfo.filter((releaseInfo) => { - return (semver.satisfies(releaseInfo['sdk']['version'], versionInfo.version()) || - semver.satisfies(releaseInfo['sdk']['version-display'], versionInfo.version())); + return (semver.satisfies(releaseInfo['sdk']['version'], 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 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 - 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) { throw `Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`; } diff --git a/src/installer.ts b/src/installer.ts index f0b48a2..d36a24e 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -29,7 +29,6 @@ export class DotNetVersionInfo { return; } - //Note: No support for previews when using generic let parts: string[] = version.split('.'); if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat(); @@ -76,8 +75,9 @@ export class DotNetVersionInfo { } export class DotnetCoreInstaller { - constructor(version: string) { + constructor(version: string, includePrerelease: boolean = false) { this.version = version; + this.includePrerelease = includePrerelease; } public async installDotnet() { @@ -212,13 +212,15 @@ export class DotnetCoreInstaller { let releasesInfo: any[] = releasesResult['releases']; releasesInfo = releasesInfo.filter((releaseInfo: any) => { return ( - semver.satisfies( - releaseInfo['sdk']['version'], - versionInfo.version() - ) || + semver.satisfies(releaseInfo['sdk']['version'], versionInfo.version(), { + includePrerelease: this.includePrerelease + }) || semver.satisfies( releaseInfo['sdk']['version-display'], - versionInfo.version() + versionInfo.version(), + { + includePrerelease: this.includePrerelease + } ) ); }); @@ -227,12 +229,16 @@ export class DotnetCoreInstaller { let latestSdk: string = releasesResult['latest-sdk']; releasesInfo = releasesInfo.filter((releaseInfo: any) => - semver.lte(releaseInfo['sdk']['version'], latestSdk) + semver.lte(releaseInfo['sdk']['version'], latestSdk, { + includePrerelease: this.includePrerelease + }) ); // Sort for latest version 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) { @@ -273,6 +279,7 @@ export class DotnetCoreInstaller { } private version: string; + private includePrerelease: boolean; } const DotNetCoreIndexUrl: string = diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index ec804eb..51ace99 100644 --- a/src/setup-dotnet.ts +++ b/src/setup-dotnet.ts @@ -29,7 +29,14 @@ export async function run() { } 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(); } From 291588df6a18de26865f534622042f657f0db06d Mon Sep 17 00:00:00 2001 From: GGG KILLER Date: Thu, 22 Apr 2021 12:22:10 -0300 Subject: [PATCH 3/3] Rerun build --- dist/index.js | 65 +++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/dist/index.js b/dist/index.js index b55d7c6..e416010 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5048,7 +5048,7 @@ module.exports = {"name":"@octokit/rest","version":"16.28.9","publishConfig":{"a module.exports = XMLDummy = class XMLDummy extends XMLNode { // Initializes a new instance of `XMLDummy` - // `XMLDummy` is a special node representing a node with + // `XMLDummy` is a special node representing a node with // a null value. Dummy nodes are created while recursively // building the XML tree. Simply skipping null values doesn't // work because that would break the recursive chain. @@ -9151,7 +9151,7 @@ function escapeProperty(s) { }; - + // DOM level 1 Object.defineProperty(XMLNamedNodeMap.prototype, 'length', { get: function() { @@ -10956,7 +10956,7 @@ exports.FetchError = FetchError; document(doc, options) { var child, i, j, k, len1, len2, ref, ref1, results; ref = doc.children; - // set a flag so that we don't insert a newline after the last root level node + // set a flag so that we don't insert a newline after the last root level node for (i = j = 0, len1 = ref.length; j < len1; i = ++j) { child = ref[i]; child.isLastRootNode = i === doc.children.length - 1; @@ -12067,14 +12067,14 @@ function authenticationBeforeRequest (state, options) { } else { this.writerOptions.state = WriterState.OpenTag; chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ' 3) this.throwInvalidVersionFormat(); @@ -20470,7 +20469,7 @@ module.exports = set; return this.options.writer.attribute(this, this.options.writer.filterOptions(options)); } - + // Returns debug string for this node debugInfo(name) { name = name || this.name; @@ -22018,7 +22017,7 @@ const validator = __webpack_require__(971); exports.parse = function(xmlData, options, validationOption) { if( validationOption){ if(validationOption === true) validationOption = {} - + const result = validator.validate(xmlData, validationOption); if (result !== true) { throw Error( result.err.msg) @@ -22062,11 +22061,11 @@ function print(xmlNode, indentation){ //console.log(indentation + " \""+index+"\" : [") print(item, indentation2); }) - console.log(indentation + "],") + console.log(indentation + "],") }else{ console.log(indentation + " \""+key+"\" : {") print(node, indentation2); - console.log(indentation + "},") + console.log(indentation + "},") } }); console.log(indentation + "},") @@ -22077,4 +22076,4 @@ function print(xmlNode, indentation){ /***/ }) -/******/ }); +/******/ }); \ No newline at end of file