diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..e230aaa --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @actions/virtual-environments-owners diff --git a/README.md b/README.md index 66af02f..18e2c06 100644 --- a/README.md +++ b/README.md @@ -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 preinstalled. Installed versions are subject to change. Please refer to the 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. # Usage @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest strategy: 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 steps: - uses: actions/checkout@v2 @@ -59,7 +59,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v1 with: - dotnet-version: '2.2.103' + dotnet-version: '2.1.x' - name: Setup dotnet uses: actions/setup-dotnet@v1 with: @@ -113,7 +113,7 @@ build: - uses: actions/checkout@main - uses: actions/setup-dotnet@v1 with: - dotnet-version: '3.1.100' # SDK Version to use. + dotnet-version: '3.1.x' # SDK Version to use. ``` # License diff --git a/__tests__/versionutil.test.ts b/__tests__/versionutil.test.ts index a238688..69681da 100644 --- a/__tests__/versionutil.test.ts +++ b/__tests__/versionutil.test.ts @@ -13,6 +13,8 @@ describe('version tests', () => { ); each([ + ['3.x', '3.x'], + ['3.*', '3.*'], ['3.1.x', '3.1'], ['1.1.*', '1.1'], ['2.0', '2.0'] @@ -42,7 +44,6 @@ describe('version tests', () => { '.2.3', '.2.x', '1', - '2.x', '*.*.1', '*.1', '*.', diff --git a/dist/index.js b/dist/index.js index e51206f..b55d7c6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4840,11 +4840,23 @@ const github = __importStar(__webpack_require__(469)); const xmlbuilder = __importStar(__webpack_require__(312)); const xmlParser = __importStar(__webpack_require__(989)); 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'); writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig); } 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) { console.log(`dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}`); let xml; @@ -5036,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. @@ -9139,7 +9151,7 @@ function escapeProperty(s) { }; - + // DOM level 1 Object.defineProperty(XMLNamedNodeMap.prototype, 'length', { get: function() { @@ -10944,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; @@ -12055,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(); if (parts.length == 3 && parts[2] !== 'x' && parts[2] !== '*') { this.throwInvalidVersionFormat(); } - let major = this.getVersionNumberOrThrow(parts[0]); - let minor = this.getVersionNumberOrThrow(parts[1]); + const major = this.getVersionNumberOrThrow(parts[0]); + const minor = ['x', '*'].includes(parts[1]) + ? parts[1] + : this.getVersionNumberOrThrow(parts[1]); this.fullversion = major + '.' + minor; } getVersionNumberOrThrow(input) { @@ -16895,7 +16910,7 @@ class DotNetVersionInfo { } } 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 @@ -16999,7 +17014,7 @@ class DotnetCoreInstaller { } console.log(process.env['PATH']); 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 })); 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]; return release['sdk']['version']; @@ -17056,7 +17071,7 @@ class DotnetCoreInstaller { return versionParts[0] == sdkParts[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']; }); @@ -20455,7 +20470,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; @@ -22003,7 +22018,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) @@ -22047,11 +22062,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 + "},") @@ -22062,4 +22077,4 @@ function print(xmlNode, indentation){ /***/ }) -/******/ }); \ No newline at end of file +/******/ }); diff --git a/package-lock.json b/package-lock.json index da3c738..e5a85ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5342,9 +5342,9 @@ "dev": true }, "y18n": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", - "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", + "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==", "dev": true }, "yaml": { diff --git a/src/authutil.ts b/src/authutil.ts index 463f0d3..d8ddef0 100644 --- a/src/authutil.ts +++ b/src/authutil.ts @@ -13,7 +13,9 @@ export function configAuthentication( ) { const existingNuGetConfig: string = path.resolve( processRoot, - existingFileLocation == '' ? 'nuget.config' : existingFileLocation + existingFileLocation === '' + ? getExistingNugetConfig(processRoot) + : existingFileLocation ); const tempNuGetConfig: string = path.resolve( @@ -25,6 +27,17 @@ export function configAuthentication( 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( feedUrl: string, existingFileLocation: string, diff --git a/src/installer.ts b/src/installer.ts index d36a24e..aa2b45c 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -29,7 +29,7 @@ export class DotNetVersionInfo { return; } - let parts: string[] = version.split('.'); + const parts: string[] = version.split('.'); if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat(); @@ -37,8 +37,10 @@ export class DotNetVersionInfo { this.throwInvalidVersionFormat(); } - let major = this.getVersionNumberOrThrow(parts[0]); - let minor = this.getVersionNumberOrThrow(parts[1]); + const major = this.getVersionNumberOrThrow(parts[0]); + const minor = ['x', '*'].includes(parts[1]) + ? parts[1] + : this.getVersionNumberOrThrow(parts[1]); this.fullversion = major + '.' + minor; } @@ -59,7 +61,9 @@ export class DotNetVersionInfo { } 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']); 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) { - 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]; @@ -270,9 +276,11 @@ export class DotnetCoreInstaller { }); 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'];