Merge branch 'main' of https://github.com/actions/setup-dotnet into feature/include-prerelease

This commit is contained in:
GGG KILLER 2021-04-22 12:21:25 -03:00
commit 87189a16c7
7 changed files with 96 additions and 58 deletions

1
.github/CODEOWNERS vendored Normal file
View File

@ -0,0 +1 @@
* @actions/virtual-environments-owners

View File

@ -13,7 +13,7 @@ This action sets up a [dotnet core cli](https://github.com/dotnet/cli) environme
Please Note: GitHub hosted runners have some versions of the .NET SDK Please Note: GitHub hosted runners have some versions of the .NET SDK
preinstalled. Installed versions are subject to change. Please refer to the preinstalled. Installed versions are subject to change. Please refer to the
documentation documentation
[software installed on github hosted runners](https://help.github.com/en/actions/reference/software-installed-on-github-hosted-runners) [software installed on github hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software)
for .NET SDK versions that are currently available. for .NET SDK versions that are currently available.
# Usage # Usage
@ -37,7 +37,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
dotnet: [ '2.2.103', '3.0', '3.1.x' ] dotnet: [ '2.1.x', '3.1.x', '5.0.x' ]
name: Dotnet ${{ matrix.dotnet }} sample name: Dotnet ${{ matrix.dotnet }} sample
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -59,7 +59,7 @@ jobs:
- name: Setup dotnet - name: Setup dotnet
uses: actions/setup-dotnet@v1 uses: actions/setup-dotnet@v1
with: with:
dotnet-version: '2.2.103' dotnet-version: '2.1.x'
- name: Setup dotnet - name: Setup dotnet
uses: actions/setup-dotnet@v1 uses: actions/setup-dotnet@v1
with: with:
@ -113,7 +113,7 @@ build:
- uses: actions/checkout@main - uses: actions/checkout@main
- uses: actions/setup-dotnet@v1 - uses: actions/setup-dotnet@v1
with: with:
dotnet-version: '3.1.100' # SDK Version to use. dotnet-version: '3.1.x' # SDK Version to use.
``` ```
# License # License

View File

@ -13,6 +13,8 @@ describe('version tests', () => {
); );
each([ each([
['3.x', '3.x'],
['3.*', '3.*'],
['3.1.x', '3.1'], ['3.1.x', '3.1'],
['1.1.*', '1.1'], ['1.1.*', '1.1'],
['2.0', '2.0'] ['2.0', '2.0']
@ -42,7 +44,6 @@ describe('version tests', () => {
'.2.3', '.2.3',
'.2.x', '.2.x',
'1', '1',
'2.x',
'*.*.1', '*.*.1',
'*.1', '*.1',
'*.', '*.',

95
dist/index.js vendored
View File

@ -4840,11 +4840,23 @@ const github = __importStar(__webpack_require__(469));
const xmlbuilder = __importStar(__webpack_require__(312)); const xmlbuilder = __importStar(__webpack_require__(312));
const xmlParser = __importStar(__webpack_require__(989)); const xmlParser = __importStar(__webpack_require__(989));
function configAuthentication(feedUrl, existingFileLocation = '', processRoot = process.cwd()) { function configAuthentication(feedUrl, existingFileLocation = '', processRoot = process.cwd()) {
const existingNuGetConfig = path.resolve(processRoot, existingFileLocation == '' ? 'nuget.config' : existingFileLocation); const existingNuGetConfig = path.resolve(processRoot, existingFileLocation === ''
? getExistingNugetConfig(processRoot)
: existingFileLocation);
const tempNuGetConfig = path.resolve(processRoot, '../', 'nuget.config'); const tempNuGetConfig = path.resolve(processRoot, '../', 'nuget.config');
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig); writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
} }
exports.configAuthentication = configAuthentication; exports.configAuthentication = configAuthentication;
function getExistingNugetConfig(processRoot) {
const defaultConfigName = 'nuget.config';
const configFileNames = fs
.readdirSync(processRoot)
.filter(filename => filename.toLowerCase() === defaultConfigName);
if (configFileNames.length) {
return configFileNames[0];
}
return defaultConfigName;
}
function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) { function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) {
console.log(`dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}`); console.log(`dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}`);
let xml; let xml;
@ -5036,7 +5048,7 @@ module.exports = {"name":"@octokit/rest","version":"16.28.9","publishConfig":{"a
module.exports = XMLDummy = class XMLDummy extends XMLNode { module.exports = XMLDummy = class XMLDummy extends XMLNode {
// Initializes a new instance of `XMLDummy` // 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 // a null value. Dummy nodes are created while recursively
// building the XML tree. Simply skipping null values doesn't // building the XML tree. Simply skipping null values doesn't
// work because that would break the recursive chain. // work because that would break the recursive chain.
@ -9139,7 +9151,7 @@ function escapeProperty(s) {
}; };
// DOM level 1 // DOM level 1
Object.defineProperty(XMLNamedNodeMap.prototype, 'length', { Object.defineProperty(XMLNamedNodeMap.prototype, 'length', {
get: function() { get: function() {
@ -10944,7 +10956,7 @@ exports.FetchError = FetchError;
document(doc, options) { document(doc, options) {
var child, i, j, k, len1, len2, ref, ref1, results; var child, i, j, k, len1, len2, ref, ref1, results;
ref = doc.children; 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) { for (i = j = 0, len1 = ref.length; j < len1; i = ++j) {
child = ref[i]; child = ref[i];
child.isLastRootNode = i === doc.children.length - 1; child.isLastRootNode = i === doc.children.length - 1;
@ -12055,14 +12067,14 @@ function authenticationBeforeRequest (state, options) {
} else { } else {
this.writerOptions.state = WriterState.OpenTag; this.writerOptions.state = WriterState.OpenTag;
chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<!DOCTYPE ' + node.rootNodeName; chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<!DOCTYPE ' + node.rootNodeName;
// external identifier // external identifier
if (node.pubID && node.sysID) { if (node.pubID && node.sysID) {
chunk += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"'; chunk += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
} else if (node.sysID) { } else if (node.sysID) {
chunk += ' SYSTEM "' + node.sysID + '"'; chunk += ' SYSTEM "' + node.sysID + '"';
} }
// internal subset // internal subset
if (node.children) { if (node.children) {
chunk += ' ['; chunk += ' [';
@ -12467,9 +12479,9 @@ function addHook (state, kind, name, hook) {
// `feature` package name of the feature to test. In Level 1, the // `feature` package name of the feature to test. In Level 1, the
// legal values are "HTML" and "XML" (case-insensitive). // legal values are "HTML" and "XML" (case-insensitive).
// `version` version number of the package name to test. // `version` version number of the package name to test.
// In Level 1, this is the string "1.0". If the version is // In Level 1, this is the string "1.0". If the version is
// not specified, supporting any version of the feature will // not specified, supporting any version of the feature will
// cause the method to return true. // cause the method to return true.
hasFeature(feature, version) { hasFeature(feature, version) {
return true; return true;
@ -12500,7 +12512,7 @@ function addHook (state, kind, name, hook) {
throw new Error("This DOM method is not implemented."); throw new Error("This DOM method is not implemented.");
} }
// Returns a specialized object which implements the specialized APIs // Returns a specialized object which implements the specialized APIs
// of the specified feature and version. // of the specified feature and version.
// `feature` name of the feature requested. // `feature` name of the feature requested.
@ -14537,7 +14549,7 @@ module.exports = require("net");
this.value = ''; this.value = '';
} }
// Creates and returns a deep clone of `this` // Creates and returns a deep clone of `this`
clone() { clone() {
return Object.create(this); return Object.create(this);
@ -15507,7 +15519,7 @@ exports.convertToJson = convertToJson;
} }
} }
// Sets the parent node of this node and its children recursively // Sets the parent node of this node and its children recursively
// `parent` the parent node // `parent` the parent node
@ -15579,7 +15591,7 @@ exports.convertToJson = convertToJson;
// skip null and undefined nodes // skip null and undefined nodes
} else if (!this.options.keepNullNodes && (val == null)) { } else if (!this.options.keepNullNodes && (val == null)) {
lastChild = this.dummy(); lastChild = this.dummy();
// expand list by creating child nodes // expand list by creating child nodes
} else if (!this.options.separateArrayItems && Array.isArray(val)) { } else if (!this.options.separateArrayItems && Array.isArray(val)) {
for (k = 0, len1 = val.length; k < len1; k++) { for (k = 0, len1 = val.length; k < len1; k++) {
@ -15588,7 +15600,7 @@ exports.convertToJson = convertToJson;
childNode[key] = item; childNode[key] = item;
lastChild = this.element(childNode); lastChild = this.element(childNode);
} }
// expand child nodes under parent // expand child nodes under parent
} else if (isObject(val)) { } else if (isObject(val)) {
// if the key is #text expand child nodes under this node to support mixed content // if the key is #text expand child nodes under this node to support mixed content
@ -15599,7 +15611,7 @@ exports.convertToJson = convertToJson;
lastChild.element(val); lastChild.element(val);
} }
} else { } else {
// text node // text node
lastChild = this.element(key, val); lastChild = this.element(key, val);
} }
@ -15651,10 +15663,10 @@ exports.convertToJson = convertToJson;
// temporarily remove children starting *with* refChild // temporarily remove children starting *with* refChild
i = children.indexOf(refChild); i = children.indexOf(refChild);
removed = children.splice(i); removed = children.splice(i);
// add the new child // add the new child
children.push(newChild); children.push(newChild);
// add back removed children after new child // add back removed children after new child
Array.prototype.push.apply(children, removed); Array.prototype.push.apply(children, removed);
} else { } else {
@ -15665,14 +15677,14 @@ exports.convertToJson = convertToJson;
if (this.isRoot) { if (this.isRoot) {
throw new Error("Cannot insert elements at root level. " + this.debugInfo(name)); throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
} }
// temporarily remove children starting *with* this // temporarily remove children starting *with* this
i = this.parent.children.indexOf(this); i = this.parent.children.indexOf(this);
removed = this.parent.children.splice(i); removed = this.parent.children.splice(i);
// add the new child // add the new child
child = this.parent.element(name, attributes, text); child = this.parent.element(name, attributes, text);
// add back removed children after new child // add back removed children after new child
Array.prototype.push.apply(this.parent.children, removed); Array.prototype.push.apply(this.parent.children, removed);
return child; return child;
@ -15689,14 +15701,14 @@ exports.convertToJson = convertToJson;
if (this.isRoot) { if (this.isRoot) {
throw new Error("Cannot insert elements at root level. " + this.debugInfo(name)); throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
} }
// temporarily remove children starting *after* this // temporarily remove children starting *after* this
i = this.parent.children.indexOf(this); i = this.parent.children.indexOf(this);
removed = this.parent.children.splice(i + 1); removed = this.parent.children.splice(i + 1);
// add the new child // add the new child
child = this.parent.element(name, attributes, text); child = this.parent.element(name, attributes, text);
// add back removed children after new child // add back removed children after new child
Array.prototype.push.apply(this.parent.children, removed); Array.prototype.push.apply(this.parent.children, removed);
return child; return child;
@ -16031,7 +16043,7 @@ exports.convertToJson = convertToJson;
return this; return this;
} }
// Returns debug string for this node // Returns debug string for this node
debugInfo(name) { debugInfo(name) {
var ref1, ref2; var ref1, ref2;
@ -16252,7 +16264,7 @@ exports.convertToJson = convertToJson;
return other === this || this.isDescendant(other); return other === this || this.isDescendant(other);
} }
// An object A is called a descendant of an object B, if either A is // An object A is called a descendant of an object B, if either A is
// a child of B or A is a child of an object C that is a descendant of B. // a child of B or A is a child of an object C that is a descendant of B.
isDescendant(node) { isDescendant(node) {
var child, isDescendantChild, j, len, ref1; var child, isDescendantChild, j, len, ref1;
@ -16276,7 +16288,7 @@ exports.convertToJson = convertToJson;
return node.isDescendant(this); return node.isDescendant(this);
} }
// An object A is preceding an object B if A and B are in the // An object A is preceding an object B if A and B are in the
// same tree and A comes before B in tree order. // same tree and A comes before B in tree order.
isPreceding(node) { isPreceding(node) {
var nodePos, thisPos; var nodePos, thisPos;
@ -16289,7 +16301,7 @@ exports.convertToJson = convertToJson;
} }
} }
// An object A is folllowing an object B if A and B are in the // An object A is folllowing an object B if A and B are in the
// same tree and A comes after B in tree order. // same tree and A comes after B in tree order.
isFollowing(node) { isFollowing(node) {
var nodePos, thisPos; var nodePos, thisPos;
@ -16321,7 +16333,7 @@ exports.convertToJson = convertToJson;
} }
} }
// Depth-first preorder traversal through the XML tree // Depth-first preorder traversal through the XML tree
foreachTreeNode(node, func) { foreachTreeNode(node, func) {
var child, j, len, ref1, res; var child, j, len, ref1, res;
@ -16870,14 +16882,17 @@ class DotNetVersionInfo {
this.isExactVersionSet = true; this.isExactVersionSet = true;
return; return;
} }
let parts = version.split('.'); //Note: No support for previews when using generic
const parts = version.split('.');
if (parts.length < 2 || parts.length > 3) if (parts.length < 2 || parts.length > 3)
this.throwInvalidVersionFormat(); this.throwInvalidVersionFormat();
if (parts.length == 3 && parts[2] !== 'x' && parts[2] !== '*') { if (parts.length == 3 && parts[2] !== 'x' && parts[2] !== '*') {
this.throwInvalidVersionFormat(); this.throwInvalidVersionFormat();
} }
let major = this.getVersionNumberOrThrow(parts[0]); const major = this.getVersionNumberOrThrow(parts[0]);
let minor = this.getVersionNumberOrThrow(parts[1]); const minor = ['x', '*'].includes(parts[1])
? parts[1]
: this.getVersionNumberOrThrow(parts[1]);
this.fullversion = major + '.' + minor; this.fullversion = major + '.' + minor;
} }
getVersionNumberOrThrow(input) { getVersionNumberOrThrow(input) {
@ -16895,7 +16910,7 @@ class DotNetVersionInfo {
} }
} }
throwInvalidVersionFormat() { throwInvalidVersionFormat() {
throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'; throw new Error('Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*');
} }
/** /**
* If true exacatly one version should be resolved * If true exacatly one version should be resolved
@ -16999,7 +17014,7 @@ class DotnetCoreInstaller {
} }
console.log(process.env['PATH']); console.log(process.env['PATH']);
if (resultCode != 0) { if (resultCode != 0) {
throw `Failed to install dotnet ${resultCode}. ${output}`; throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
} }
}); });
} }
@ -17035,7 +17050,7 @@ class DotnetCoreInstaller {
includePrerelease: this.includePrerelease includePrerelease: this.includePrerelease
})); }));
if (releasesInfo.length == 0) { if (releasesInfo.length == 0) {
throw `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.`);
} }
let release = releasesInfo[0]; let release = releasesInfo[0];
return release['sdk']['version']; return release['sdk']['version'];
@ -17056,7 +17071,7 @@ class DotnetCoreInstaller {
return versionParts[0] == sdkParts[0]; return versionParts[0] == sdkParts[0];
}); });
if (releasesInfo.length === 0) { if (releasesInfo.length === 0) {
throw `Could not find info for version ${versionParts.join('.')} at ${DotNetCoreIndexUrl}`; throw new Error(`Could not find info for version ${versionParts.join('.')} at ${DotNetCoreIndexUrl}`);
} }
return releasesInfo[0]['releases.json']; return releasesInfo[0]['releases.json'];
}); });
@ -20455,7 +20470,7 @@ module.exports = set;
return this.options.writer.attribute(this, this.options.writer.filterOptions(options)); return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
} }
// Returns debug string for this node // Returns debug string for this node
debugInfo(name) { debugInfo(name) {
name = name || this.name; name = name || this.name;
@ -22003,7 +22018,7 @@ const validator = __webpack_require__(971);
exports.parse = function(xmlData, options, validationOption) { exports.parse = function(xmlData, options, validationOption) {
if( validationOption){ if( validationOption){
if(validationOption === true) validationOption = {} if(validationOption === true) validationOption = {}
const result = validator.validate(xmlData, validationOption); const result = validator.validate(xmlData, validationOption);
if (result !== true) { if (result !== true) {
throw Error( result.err.msg) throw Error( result.err.msg)
@ -22047,11 +22062,11 @@ function print(xmlNode, indentation){
//console.log(indentation + " \""+index+"\" : [") //console.log(indentation + " \""+index+"\" : [")
print(item, indentation2); print(item, indentation2);
}) })
console.log(indentation + "],") console.log(indentation + "],")
}else{ }else{
console.log(indentation + " \""+key+"\" : {") console.log(indentation + " \""+key+"\" : {")
print(node, indentation2); print(node, indentation2);
console.log(indentation + "},") console.log(indentation + "},")
} }
}); });
console.log(indentation + "},") console.log(indentation + "},")
@ -22062,4 +22077,4 @@ function print(xmlNode, indentation){
/***/ }) /***/ })
/******/ }); /******/ });

6
package-lock.json generated
View File

@ -5342,9 +5342,9 @@
"dev": true "dev": true
}, },
"y18n": { "y18n": {
"version": "4.0.0", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz",
"integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==",
"dev": true "dev": true
}, },
"yaml": { "yaml": {

View File

@ -13,7 +13,9 @@ export function configAuthentication(
) { ) {
const existingNuGetConfig: string = path.resolve( const existingNuGetConfig: string = path.resolve(
processRoot, processRoot,
existingFileLocation == '' ? 'nuget.config' : existingFileLocation existingFileLocation === ''
? getExistingNugetConfig(processRoot)
: existingFileLocation
); );
const tempNuGetConfig: string = path.resolve( const tempNuGetConfig: string = path.resolve(
@ -25,6 +27,17 @@ export function configAuthentication(
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig); writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
} }
function getExistingNugetConfig(processRoot: string) {
const defaultConfigName = 'nuget.config';
const configFileNames = fs
.readdirSync(processRoot)
.filter(filename => filename.toLowerCase() === defaultConfigName);
if (configFileNames.length) {
return configFileNames[0];
}
return defaultConfigName;
}
function writeFeedToFile( function writeFeedToFile(
feedUrl: string, feedUrl: string,
existingFileLocation: string, existingFileLocation: string,

View File

@ -29,7 +29,7 @@ export class DotNetVersionInfo {
return; return;
} }
let 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();
@ -37,8 +37,10 @@ export class DotNetVersionInfo {
this.throwInvalidVersionFormat(); this.throwInvalidVersionFormat();
} }
let major = this.getVersionNumberOrThrow(parts[0]); const major = this.getVersionNumberOrThrow(parts[0]);
let minor = this.getVersionNumberOrThrow(parts[1]); const minor = ['x', '*'].includes(parts[1])
? parts[1]
: this.getVersionNumberOrThrow(parts[1]);
this.fullversion = major + '.' + minor; this.fullversion = major + '.' + minor;
} }
@ -59,7 +61,9 @@ export class DotNetVersionInfo {
} }
private throwInvalidVersionFormat() { private throwInvalidVersionFormat() {
throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'; throw new Error(
'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'
);
} }
/** /**
@ -187,7 +191,7 @@ export class DotnetCoreInstaller {
console.log(process.env['PATH']); console.log(process.env['PATH']);
if (resultCode != 0) { if (resultCode != 0) {
throw `Failed to install dotnet ${resultCode}. ${output}`; throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
} }
} }
@ -242,7 +246,9 @@ export class DotnetCoreInstaller {
); );
if (releasesInfo.length == 0) { if (releasesInfo.length == 0) {
throw `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.`
);
} }
let release = releasesInfo[0]; let release = releasesInfo[0];
@ -270,9 +276,11 @@ export class DotnetCoreInstaller {
}); });
if (releasesInfo.length === 0) { if (releasesInfo.length === 0) {
throw `Could not find info for version ${versionParts.join( throw new Error(
'.' `Could not find info for version ${versionParts.join(
)} at ${DotNetCoreIndexUrl}`; '.'
)} at ${DotNetCoreIndexUrl}`
);
} }
return releasesInfo[0]['releases.json']; return releasesInfo[0]['releases.json'];