diff --git a/action.yml b/action.yml index 3f702f2..f62d018 100644 --- a/action.yml +++ b/action.yml @@ -4,7 +4,7 @@ author: 'GitHub' branding: icon: play color: green -inputs: +inputs: dotnet-version: description: 'SDK version to use. Examples: 2.2.104, 3.1, 3.1.x' source-url: @@ -13,10 +13,6 @@ 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.' - # Deprecated option, do not use. Will not be supported after October 1, 2019 - version: - description: 'Deprecated. Use dotnet-version instead. Will not be supported after October 1, 2019' - deprecationMessage: 'The version property will not be supported after October 1, 2019. Use dotnet-version instead' runs: using: 'node12' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index fca1445..4e27086 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4936,127 +4936,127 @@ module.exports = Parser; /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.configAuthentication = void 0; -const fs = __importStar(__webpack_require__(747)); -const path = __importStar(__webpack_require__(622)); -const core = __importStar(__webpack_require__(470)); -const github = __importStar(__webpack_require__(469)); -const xmlbuilder = __importStar(__webpack_require__(312)); -const xmlParser = __importStar(__webpack_require__(989)); -function configAuthentication(feedUrl, existingFileLocation = '') { - const existingNuGetConfig = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), existingFileLocation == '' ? 'nuget.config' : existingFileLocation); - const tempNuGetConfig = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '../', 'nuget.config'); - writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig); -} -exports.configAuthentication = configAuthentication; -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; - let sourceKeys = []; - let owner = core.getInput('owner'); - let sourceUrl = feedUrl; - if (!owner) { - owner = github.context.repo.owner; - } - if (!process.env.NUGET_AUTH_TOKEN || process.env.NUGET_AUTH_TOKEN == '') { - throw new Error('The NUGET_AUTH_TOKEN environment variable was not provided. In this step, add the following: \r\nenv:\r\n NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}'); - } - if (fs.existsSync(existingFileLocation)) { - // get key from existing NuGet.config so NuGet/dotnet can match credentials - const curContents = fs.readFileSync(existingFileLocation, 'utf8'); - var json = xmlParser.parse(curContents, { ignoreAttributes: false }); - if (typeof json.configuration == 'undefined') { - throw new Error(`The provided NuGet.config seems invalid.`); - } - if (typeof json.configuration.packageSources != 'undefined') { - if (typeof json.configuration.packageSources.add != 'undefined') { - // file has at least one - if (typeof json.configuration.packageSources.add[0] == 'undefined') { - // file has only one - if (json.configuration.packageSources.add['@_value'] - .toLowerCase() - .includes(feedUrl.toLowerCase())) { - let key = json.configuration.packageSources.add['@_key']; - sourceKeys.push(key); - core.debug(`Found a URL with key ${key}`); - } - } - else { - // file has 2+ - for (let i = 0; i < json.configuration.packageSources.add.length; i++) { - const source = json.configuration.packageSources.add[i]; - const value = source['@_value']; - core.debug(`source '${value}'`); - if (value.toLowerCase().includes(feedUrl.toLowerCase())) { - let key = source['@_key']; - sourceKeys.push(key); - core.debug(`Found a URL with key ${key}`); - } - } - } - } - } - } - xml = xmlbuilder - .create('configuration') - .ele('config') - .ele('add', { key: 'defaultPushSource', value: sourceUrl }) - .up() - .up(); - if (sourceKeys.length == 0) { - let keystring = 'Source'; - xml = xml - .ele('packageSources') - .ele('add', { key: keystring, value: sourceUrl }) - .up() - .up(); - sourceKeys.push(keystring); - } - xml = xml.ele('packageSourceCredentials'); - sourceKeys.forEach(key => { - if (key.indexOf(' ') > -1) { - throw new Error("This action currently can't handle source names with spaces. Remove the space from your repo's NuGet.config and try again."); - } - xml = xml - .ele(key) - .ele('add', { key: 'Username', value: owner }) - .up() - .ele('add', { - key: 'ClearTextPassword', - value: process.env.NUGET_AUTH_TOKEN - }) - .up() - .up(); - }); - // If NuGet fixes itself such that on Linux it can look for environment variables in the config file (it doesn't seem to work today), - // use this for the value above - // process.platform == 'win32' - // ? '%NUGET_AUTH_TOKEN%' - // : '$NUGET_AUTH_TOKEN' - var output = xml.end({ pretty: true }); - fs.writeFileSync(tempFileLocation, output); -} + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.configAuthentication = void 0; +const fs = __importStar(__webpack_require__(747)); +const path = __importStar(__webpack_require__(622)); +const core = __importStar(__webpack_require__(470)); +const github = __importStar(__webpack_require__(469)); +const xmlbuilder = __importStar(__webpack_require__(312)); +const xmlParser = __importStar(__webpack_require__(989)); +function configAuthentication(feedUrl, existingFileLocation = '') { + const existingNuGetConfig = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), existingFileLocation == '' ? 'nuget.config' : existingFileLocation); + const tempNuGetConfig = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '../', 'nuget.config'); + writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig); +} +exports.configAuthentication = configAuthentication; +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; + let sourceKeys = []; + let owner = core.getInput('owner'); + let sourceUrl = feedUrl; + if (!owner) { + owner = github.context.repo.owner; + } + if (!process.env.NUGET_AUTH_TOKEN || process.env.NUGET_AUTH_TOKEN == '') { + throw new Error('The NUGET_AUTH_TOKEN environment variable was not provided. In this step, add the following: \r\nenv:\r\n NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}'); + } + if (fs.existsSync(existingFileLocation)) { + // get key from existing NuGet.config so NuGet/dotnet can match credentials + const curContents = fs.readFileSync(existingFileLocation, 'utf8'); + var json = xmlParser.parse(curContents, { ignoreAttributes: false }); + if (typeof json.configuration == 'undefined') { + throw new Error(`The provided NuGet.config seems invalid.`); + } + if (typeof json.configuration.packageSources != 'undefined') { + if (typeof json.configuration.packageSources.add != 'undefined') { + // file has at least one + if (typeof json.configuration.packageSources.add[0] == 'undefined') { + // file has only one + if (json.configuration.packageSources.add['@_value'] + .toLowerCase() + .includes(feedUrl.toLowerCase())) { + let key = json.configuration.packageSources.add['@_key']; + sourceKeys.push(key); + core.debug(`Found a URL with key ${key}`); + } + } + else { + // file has 2+ + for (let i = 0; i < json.configuration.packageSources.add.length; i++) { + const source = json.configuration.packageSources.add[i]; + const value = source['@_value']; + core.debug(`source '${value}'`); + if (value.toLowerCase().includes(feedUrl.toLowerCase())) { + let key = source['@_key']; + sourceKeys.push(key); + core.debug(`Found a URL with key ${key}`); + } + } + } + } + } + } + xml = xmlbuilder + .create('configuration') + .ele('config') + .ele('add', { key: 'defaultPushSource', value: sourceUrl }) + .up() + .up(); + if (sourceKeys.length == 0) { + let keystring = 'Source'; + xml = xml + .ele('packageSources') + .ele('add', { key: keystring, value: sourceUrl }) + .up() + .up(); + sourceKeys.push(keystring); + } + xml = xml.ele('packageSourceCredentials'); + sourceKeys.forEach(key => { + if (key.indexOf(' ') > -1) { + throw new Error("This action currently can't handle source names with spaces. Remove the space from your repo's NuGet.config and try again."); + } + xml = xml + .ele(key) + .ele('add', { key: 'Username', value: owner }) + .up() + .ele('add', { + key: 'ClearTextPassword', + value: process.env.NUGET_AUTH_TOKEN + }) + .up() + .up(); + }); + // If NuGet fixes itself such that on Linux it can look for environment variables in the config file (it doesn't seem to work today), + // use this for the value above + // process.platform == 'win32' + // ? '%NUGET_AUTH_TOKEN%' + // : '$NUGET_AUTH_TOKEN' + var output = xml.end({ pretty: true }); + fs.writeFileSync(tempFileLocation, output); +} /***/ }), @@ -5142,7 +5142,7 @@ module.exports = require("https"); /***/ 215: /***/ (function(module) { -module.exports = {"name":"@octokit/rest","version":"16.28.9","publishConfig":{"access":"public"},"description":"GitHub REST API client for Node.js","keywords":["octokit","github","rest","api-client"],"author":"Gregor Martynus (https://github.com/gr2m)","contributors":[{"name":"Mike de Boer","email":"info@mikedeboer.nl"},{"name":"Fabian Jakobs","email":"fabian@c9.io"},{"name":"Joe Gallo","email":"joe@brassafrax.com"},{"name":"Gregor Martynus","url":"https://github.com/gr2m"}],"repository":"https://github.com/octokit/rest.js","dependencies":{"@octokit/request":"^5.0.0","@octokit/request-error":"^1.0.2","atob-lite":"^2.0.0","before-after-hook":"^2.0.0","btoa-lite":"^1.0.0","deprecation":"^2.0.0","lodash.get":"^4.4.2","lodash.set":"^4.3.2","lodash.uniq":"^4.5.0","octokit-pagination-methods":"^1.1.0","once":"^1.4.0","universal-user-agent":"^4.0.0"},"devDependencies":{"@gimenete/type-writer":"^0.1.3","@octokit/fixtures-server":"^5.0.1","@octokit/routes":"20.9.2","@types/node":"^12.0.0","bundlesize":"^0.18.0","chai":"^4.1.2","compression-webpack-plugin":"^3.0.0","coveralls":"^3.0.0","glob":"^7.1.2","http-proxy-agent":"^2.1.0","lodash.camelcase":"^4.3.0","lodash.merge":"^4.6.1","lodash.upperfirst":"^4.3.1","mkdirp":"^0.5.1","mocha":"^6.0.0","mustache":"^3.0.0","nock":"^10.0.0","npm-run-all":"^4.1.2","nyc":"^14.0.0","prettier":"^1.14.2","proxy":"^0.2.4","semantic-release":"^15.0.0","sinon":"^7.2.4","sinon-chai":"^3.0.0","sort-keys":"^4.0.0","standard":"^14.0.2","string-to-arraybuffer":"^1.0.0","string-to-jsdoc-comment":"^1.0.0","typescript":"^3.3.1","webpack":"^4.0.0","webpack-bundle-analyzer":"^3.0.0","webpack-cli":"^3.0.0"},"types":"index.d.ts","scripts":{"coverage":"nyc report --reporter=html && open coverage/index.html","pretest":"standard","test":"nyc mocha test/mocha-node-setup.js \"test/*/**/*-test.js\"","test:browser":"cypress run --browser chrome","test:memory":"mocha test/memory-test","build":"npm-run-all build:*","build:ts":"node scripts/generate-types","prebuild:browser":"mkdirp dist/","build:browser":"npm-run-all build:browser:*","build:browser:development":"webpack --mode development --entry . --output-library=Octokit --output=./dist/octokit-rest.js --profile --json > dist/bundle-stats.json","build:browser:production":"webpack --mode production --entry . --plugin=compression-webpack-plugin --output-library=Octokit --output-path=./dist --output-filename=octokit-rest.min.js --devtool source-map","generate-bundle-report":"webpack-bundle-analyzer dist/bundle-stats.json --mode=static --no-open --report dist/bundle-report.html","generate-routes":"node scripts/generate-routes","prevalidate:ts":"npm run -s build:ts","validate:ts":"tsc --target es6 --noImplicitAny index.d.ts","postvalidate:ts":"tsc --noEmit --target es6 test/typescript-validate.ts","start-fixtures-server":"octokit-fixtures-server"},"license":"MIT","files":["index.js","index.d.ts","lib","plugins"],"nyc":{"ignore":["test"]},"release":{"publish":["@semantic-release/npm",{"path":"@semantic-release/github","assets":["dist/*","!dist/*.map.gz"]}]},"standard":{"globals":["describe","before","beforeEach","afterEach","after","it","expect","cy"],"ignore":["/docs"]},"bundlesize":[{"path":"./dist/octokit-rest.min.js.gz","maxSize":"33 kB"}],"_resolved":"https://registry.npmjs.org/@octokit/rest/-/rest-16.28.9.tgz","_integrity":"sha512-IKGnX+Tvzt7XHhs8f4ajqxyJvYAMNX5nWfoJm4CQj8LZToMiaJgutf5KxxpxoC3y5w7JTJpW5rnWnF4TsIvCLA==","_from":"@octokit/rest@16.28.9"}; +module.exports = {"_args":[["@octokit/rest@16.28.9","C:\\Users\\malioto\\git\\setup-dotnet"]],"_from":"@octokit/rest@16.28.9","_id":"@octokit/rest@16.28.9","_inBundle":false,"_integrity":"sha512-IKGnX+Tvzt7XHhs8f4ajqxyJvYAMNX5nWfoJm4CQj8LZToMiaJgutf5KxxpxoC3y5w7JTJpW5rnWnF4TsIvCLA==","_location":"/@octokit/rest","_phantomChildren":{"os-name":"3.1.0"},"_requested":{"type":"version","registry":true,"raw":"@octokit/rest@16.28.9","name":"@octokit/rest","escapedName":"@octokit%2frest","scope":"@octokit","rawSpec":"16.28.9","saveSpec":null,"fetchSpec":"16.28.9"},"_requiredBy":["/@actions/github"],"_resolved":"https://registry.npmjs.org/@octokit/rest/-/rest-16.28.9.tgz","_spec":"16.28.9","_where":"C:\\Users\\malioto\\git\\setup-dotnet","author":{"name":"Gregor Martynus","url":"https://github.com/gr2m"},"bugs":{"url":"https://github.com/octokit/rest.js/issues"},"bundlesize":[{"path":"./dist/octokit-rest.min.js.gz","maxSize":"33 kB"}],"contributors":[{"name":"Mike de Boer","email":"info@mikedeboer.nl"},{"name":"Fabian Jakobs","email":"fabian@c9.io"},{"name":"Joe Gallo","email":"joe@brassafrax.com"},{"name":"Gregor Martynus","url":"https://github.com/gr2m"}],"dependencies":{"@octokit/request":"^5.0.0","@octokit/request-error":"^1.0.2","atob-lite":"^2.0.0","before-after-hook":"^2.0.0","btoa-lite":"^1.0.0","deprecation":"^2.0.0","lodash.get":"^4.4.2","lodash.set":"^4.3.2","lodash.uniq":"^4.5.0","octokit-pagination-methods":"^1.1.0","once":"^1.4.0","universal-user-agent":"^4.0.0"},"description":"GitHub REST API client for Node.js","devDependencies":{"@gimenete/type-writer":"^0.1.3","@octokit/fixtures-server":"^5.0.1","@octokit/routes":"20.9.2","@types/node":"^12.0.0","bundlesize":"^0.18.0","chai":"^4.1.2","compression-webpack-plugin":"^3.0.0","coveralls":"^3.0.0","glob":"^7.1.2","http-proxy-agent":"^2.1.0","lodash.camelcase":"^4.3.0","lodash.merge":"^4.6.1","lodash.upperfirst":"^4.3.1","mkdirp":"^0.5.1","mocha":"^6.0.0","mustache":"^3.0.0","nock":"^10.0.0","npm-run-all":"^4.1.2","nyc":"^14.0.0","prettier":"^1.14.2","proxy":"^0.2.4","semantic-release":"^15.0.0","sinon":"^7.2.4","sinon-chai":"^3.0.0","sort-keys":"^4.0.0","standard":"^14.0.2","string-to-arraybuffer":"^1.0.0","string-to-jsdoc-comment":"^1.0.0","typescript":"^3.3.1","webpack":"^4.0.0","webpack-bundle-analyzer":"^3.0.0","webpack-cli":"^3.0.0"},"files":["index.js","index.d.ts","lib","plugins"],"homepage":"https://github.com/octokit/rest.js#readme","keywords":["octokit","github","rest","api-client"],"license":"MIT","name":"@octokit/rest","nyc":{"ignore":["test"]},"publishConfig":{"access":"public"},"release":{"publish":["@semantic-release/npm",{"path":"@semantic-release/github","assets":["dist/*","!dist/*.map.gz"]}]},"repository":{"type":"git","url":"git+https://github.com/octokit/rest.js.git"},"scripts":{"build":"npm-run-all build:*","build:browser":"npm-run-all build:browser:*","build:browser:development":"webpack --mode development --entry . --output-library=Octokit --output=./dist/octokit-rest.js --profile --json > dist/bundle-stats.json","build:browser:production":"webpack --mode production --entry . --plugin=compression-webpack-plugin --output-library=Octokit --output-path=./dist --output-filename=octokit-rest.min.js --devtool source-map","build:ts":"node scripts/generate-types","coverage":"nyc report --reporter=html && open coverage/index.html","generate-bundle-report":"webpack-bundle-analyzer dist/bundle-stats.json --mode=static --no-open --report dist/bundle-report.html","generate-routes":"node scripts/generate-routes","postvalidate:ts":"tsc --noEmit --target es6 test/typescript-validate.ts","prebuild:browser":"mkdirp dist/","pretest":"standard","prevalidate:ts":"npm run -s build:ts","start-fixtures-server":"octokit-fixtures-server","test":"nyc mocha test/mocha-node-setup.js \"test/*/**/*-test.js\"","test:browser":"cypress run --browser chrome","test:memory":"mocha test/memory-test","validate:ts":"tsc --target es6 --noImplicitAny index.d.ts"},"standard":{"globals":["describe","before","beforeEach","afterEach","after","it","expect","cy"],"ignore":["/docs"]},"types":"index.d.ts","version":"16.28.9"}; /***/ }), @@ -7511,7 +7511,7 @@ function octokitRestNormalizeGitReferenceResponses (octokit) { /***/ 314: /***/ (function(module) { -module.exports = {"name":"@octokit/graphql","version":"2.1.3","publishConfig":{"access":"public"},"description":"GitHub GraphQL API client for browsers and Node","main":"index.js","scripts":{"prebuild":"mkdirp dist/","build":"npm-run-all build:*","build:development":"webpack --mode development --entry . --output-library=octokitGraphql --output=./dist/octokit-graphql.js --profile --json > dist/bundle-stats.json","build:production":"webpack --mode production --entry . --plugin=compression-webpack-plugin --output-library=octokitGraphql --output-path=./dist --output-filename=octokit-graphql.min.js --devtool source-map","bundle-report":"webpack-bundle-analyzer dist/bundle-stats.json --mode=static --no-open --report dist/bundle-report.html","coverage":"nyc report --reporter=html && open coverage/index.html","coverage:upload":"nyc report --reporter=text-lcov | coveralls","pretest":"standard","test":"nyc mocha test/*-test.js","test:browser":"cypress run --browser chrome"},"repository":{"type":"git","url":"https://github.com/octokit/graphql.js.git"},"keywords":["octokit","github","api","graphql"],"author":"Gregor Martynus (https://github.com/gr2m)","license":"MIT","bugs":{"url":"https://github.com/octokit/graphql.js/issues"},"homepage":"https://github.com/octokit/graphql.js#readme","dependencies":{"@octokit/request":"^5.0.0","universal-user-agent":"^2.0.3"},"devDependencies":{"chai":"^4.2.0","compression-webpack-plugin":"^2.0.0","coveralls":"^3.0.3","cypress":"^3.1.5","fetch-mock":"^7.3.1","mkdirp":"^0.5.1","mocha":"^6.0.0","npm-run-all":"^4.1.3","nyc":"^14.0.0","semantic-release":"^15.13.3","simple-mock":"^0.8.0","standard":"^12.0.1","webpack":"^4.29.6","webpack-bundle-analyzer":"^3.1.0","webpack-cli":"^3.2.3"},"bundlesize":[{"path":"./dist/octokit-graphql.min.js.gz","maxSize":"5KB"}],"release":{"publish":["@semantic-release/npm",{"path":"@semantic-release/github","assets":["dist/*","!dist/*.map.gz"]}]},"standard":{"globals":["describe","before","beforeEach","afterEach","after","it","expect"]},"files":["lib"],"_resolved":"https://registry.npmjs.org/@octokit/graphql/-/graphql-2.1.3.tgz","_integrity":"sha512-XoXJqL2ondwdnMIW3wtqJWEwcBfKk37jO/rYkoxNPEVeLBDGsGO1TCWggrAlq3keGt/O+C/7VepXnukUxwt5vA==","_from":"@octokit/graphql@2.1.3"}; +module.exports = {"_args":[["@octokit/graphql@2.1.3","C:\\Users\\malioto\\git\\setup-dotnet"]],"_from":"@octokit/graphql@2.1.3","_id":"@octokit/graphql@2.1.3","_inBundle":false,"_integrity":"sha512-XoXJqL2ondwdnMIW3wtqJWEwcBfKk37jO/rYkoxNPEVeLBDGsGO1TCWggrAlq3keGt/O+C/7VepXnukUxwt5vA==","_location":"/@octokit/graphql","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"@octokit/graphql@2.1.3","name":"@octokit/graphql","escapedName":"@octokit%2fgraphql","scope":"@octokit","rawSpec":"2.1.3","saveSpec":null,"fetchSpec":"2.1.3"},"_requiredBy":["/@actions/github"],"_resolved":"https://registry.npmjs.org/@octokit/graphql/-/graphql-2.1.3.tgz","_spec":"2.1.3","_where":"C:\\Users\\malioto\\git\\setup-dotnet","author":{"name":"Gregor Martynus","url":"https://github.com/gr2m"},"bugs":{"url":"https://github.com/octokit/graphql.js/issues"},"bundlesize":[{"path":"./dist/octokit-graphql.min.js.gz","maxSize":"5KB"}],"dependencies":{"@octokit/request":"^5.0.0","universal-user-agent":"^2.0.3"},"description":"GitHub GraphQL API client for browsers and Node","devDependencies":{"chai":"^4.2.0","compression-webpack-plugin":"^2.0.0","coveralls":"^3.0.3","cypress":"^3.1.5","fetch-mock":"^7.3.1","mkdirp":"^0.5.1","mocha":"^6.0.0","npm-run-all":"^4.1.3","nyc":"^14.0.0","semantic-release":"^15.13.3","simple-mock":"^0.8.0","standard":"^12.0.1","webpack":"^4.29.6","webpack-bundle-analyzer":"^3.1.0","webpack-cli":"^3.2.3"},"files":["lib"],"homepage":"https://github.com/octokit/graphql.js#readme","keywords":["octokit","github","api","graphql"],"license":"MIT","main":"index.js","name":"@octokit/graphql","publishConfig":{"access":"public"},"release":{"publish":["@semantic-release/npm",{"path":"@semantic-release/github","assets":["dist/*","!dist/*.map.gz"]}]},"repository":{"type":"git","url":"git+https://github.com/octokit/graphql.js.git"},"scripts":{"build":"npm-run-all build:*","build:development":"webpack --mode development --entry . --output-library=octokitGraphql --output=./dist/octokit-graphql.js --profile --json > dist/bundle-stats.json","build:production":"webpack --mode production --entry . --plugin=compression-webpack-plugin --output-library=octokitGraphql --output-path=./dist --output-filename=octokit-graphql.min.js --devtool source-map","bundle-report":"webpack-bundle-analyzer dist/bundle-stats.json --mode=static --no-open --report dist/bundle-report.html","coverage":"nyc report --reporter=html && open coverage/index.html","coverage:upload":"nyc report --reporter=text-lcov | coveralls","prebuild":"mkdirp dist/","pretest":"standard","test":"nyc mocha test/*-test.js","test:browser":"cypress run --browser chrome"},"standard":{"globals":["describe","before","beforeEach","afterEach","after","it","expect"]},"version":"2.1.3"}; /***/ }), @@ -7832,83 +7832,83 @@ module.exports = require("assert"); /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.run = void 0; -const core = __importStar(__webpack_require__(470)); -const installer = __importStar(__webpack_require__(749)); -const fs = __importStar(__webpack_require__(747)); -const path = __importStar(__webpack_require__(622)); -const auth = __importStar(__webpack_require__(202)); -function run() { - return __awaiter(this, void 0, void 0, function* () { - try { - // - // Version is optional. If supplied, install / use from the tool cache - // If not supplied then task is still used to setup proxy, auth, etc... - // - let version = core.getInput('version'); - if (!version) { - version = core.getInput('dotnet-version'); - } - if (!version) { - // Try to fall back to global.json - core.debug('No version found, trying to find version from global.json'); - const globalJsonPath = path.join(process.cwd(), 'global.json'); - if (fs.existsSync(globalJsonPath)) { - const globalJson = JSON.parse(fs.readFileSync(globalJsonPath, { encoding: 'utf8' })); - if (globalJson.sdk && globalJson.sdk.version) { - version = globalJson.sdk.version; - } - } - } - if (version) { - const dotnetInstaller = new installer.DotnetCoreInstaller(version); - yield dotnetInstaller.installDotnet(); - } - const sourceUrl = core.getInput('source-url'); - const configFile = core.getInput('config-file'); - if (sourceUrl) { - auth.configAuthentication(sourceUrl, configFile); - } - const matchersPath = path.join(__dirname, '..', '.github'); - console.log(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`); - } - catch (error) { - core.setFailed(error.message); - } - }); -} -exports.run = run; -run(); + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.run = void 0; +const core = __importStar(__webpack_require__(470)); +const installer = __importStar(__webpack_require__(749)); +const fs = __importStar(__webpack_require__(747)); +const path = __importStar(__webpack_require__(622)); +const auth = __importStar(__webpack_require__(202)); +function run() { + return __awaiter(this, void 0, void 0, function* () { + try { + // + // dotnet-version is optional, but needs to be provided for most use cases. + // If supplied, install / use from the tool cache. + // If not supplied, look for version in ./global.json. + // If a valid version still can't be identified, nothing will be installed. + // Proxy, auth, (etc) are still set up, even if no version is identified + // + let version = core.getInput('dotnet-version'); + if (!version) { + // Try to fall back to global.json + core.debug('No version found, trying to find version from global.json'); + const globalJsonPath = path.join(process.cwd(), 'global.json'); + if (fs.existsSync(globalJsonPath)) { + const globalJson = JSON.parse(fs.readFileSync(globalJsonPath, { encoding: 'utf8' })); + if (globalJson.sdk && globalJson.sdk.version) { + version = globalJson.sdk.version; + } + } + } + if (version) { + const dotnetInstaller = new installer.DotnetCoreInstaller(version); + yield dotnetInstaller.installDotnet(); + } + const sourceUrl = core.getInput('source-url'); + const configFile = core.getInput('config-file'); + if (sourceUrl) { + auth.configAuthentication(sourceUrl, configFile); + } + const matchersPath = path.join(__dirname, '..', '.github'); + console.log(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`); + } + catch (error) { + core.setFailed(error.message); + } + }); +} +exports.run = run; +run(); /***/ }), @@ -17362,426 +17362,426 @@ module.exports = require("fs"); /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.DotnetCoreInstaller = exports.DotNetVersionInfo = void 0; -// Load tempDirectory before it gets wiped by tool-cache -let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || ''; -const core = __importStar(__webpack_require__(470)); -const exec = __importStar(__webpack_require__(986)); -const io = __importStar(__webpack_require__(1)); -const tc = __importStar(__webpack_require__(533)); -const hc = __webpack_require__(539); -const fs_1 = __webpack_require__(747); -const os = __importStar(__webpack_require__(87)); -const path = __importStar(__webpack_require__(622)); -const semver = __importStar(__webpack_require__(280)); -const IS_WINDOWS = process.platform === 'win32'; -if (!tempDirectory) { - let baseLocation; - if (IS_WINDOWS) { - // On windows use the USERPROFILE env variable - baseLocation = process.env['USERPROFILE'] || 'C:\\'; - } - else { - if (process.platform === 'darwin') { - baseLocation = '/Users'; - } - else { - baseLocation = '/home'; - } - } - tempDirectory = path.join(baseLocation, 'actions', 'temp'); -} -/** - * Represents the inputted version information - */ -class DotNetVersionInfo { - constructor(version) { - this.isExactVersionSet = false; - // Check for exact match - if (semver.valid(semver.clean(version) || '') != null) { - this.fullversion = semver.clean(version); - 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(); - if (parts.length == 3 && parts[2] !== 'x' && parts[2] !== '*') { - this.throwInvalidVersionFormat(); - } - let major = this.getVersionNumberOrThrow(parts[0]); - let minor = this.getVersionNumberOrThrow(parts[1]); - this.fullversion = major + '.' + minor; - } - getVersionNumberOrThrow(input) { - try { - if (!input || input.trim() === '') - this.throwInvalidVersionFormat(); - let number = Number(input); - if (Number.isNaN(number) || number < 0) - this.throwInvalidVersionFormat(); - return number; - } - catch (_a) { - this.throwInvalidVersionFormat(); - return -1; - } - } - throwInvalidVersionFormat() { - throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'; - } - /** - * If true exacatly one version should be resolved - */ - isExactVersion() { - return this.isExactVersionSet; - } - version() { - return this.fullversion; - } -} -exports.DotNetVersionInfo = DotNetVersionInfo; -/** - * Represents a resolved version from the Web-Api - */ -class ResolvedVersionInfo { - constructor(downloadUrls, resolvedVersion) { - if (downloadUrls.length === 0) { - throw 'DownloadUrls can not be empty'; - } - if (!resolvedVersion) { - throw 'Resolved version is invalid'; - } - this.downloadUrls = downloadUrls; - this.resolvedVersion = resolvedVersion; - } -} -class DotnetCoreInstaller { - constructor(version) { - this.versionInfo = new DotNetVersionInfo(version); - this.cachedToolName = 'dncs'; - this.arch = 'x64'; - } - installDotnet() { - return __awaiter(this, void 0, void 0, function* () { - // Check cache - let toolPath = ''; - let osSuffixes = yield this.detectMachineOS(); - let parts = osSuffixes[0].split('-'); - if (parts.length > 1) { - this.arch = parts[1]; - } - // If version is not generic -> look up cache - if (this.versionInfo.isExactVersion()) - toolPath = this.getLocalTool(this.versionInfo.version()); - if (!toolPath) { - // download, extract, cache - console.log('Getting a download url', this.versionInfo.version()); - let resolvedVersionInfo = yield this.resolveInfos(osSuffixes, this.versionInfo); - //Check if cache exists for resolved version - toolPath = this.getLocalTool(resolvedVersionInfo.resolvedVersion); - if (!toolPath) { - //If not exists install it - toolPath = yield this.downloadAndInstall(resolvedVersionInfo); - } - else { - console.log('Using cached tool'); - } - } - else { - console.log('Using cached tool'); - } - // Need to set this so that .NET Core global tools find the right locations. - core.exportVariable('DOTNET_ROOT', toolPath); - // Prepend the tools path. instructs the agent to prepend for future tasks - core.addPath(toolPath); - }); - } - getLocalTool(version) { - console.log('Checking tool cache', version); - return tc.find(this.cachedToolName, version, this.arch); - } - detectMachineOS() { - return __awaiter(this, void 0, void 0, function* () { - let osSuffix = []; - let output = ''; - let resultCode = 0; - if (IS_WINDOWS) { - let escapedScript = path - .join(__dirname, '..', 'externals', 'get-os-platform.ps1') - .replace(/'/g, "''"); - let command = `& '${escapedScript}'`; - const powershellPath = yield io.which('powershell', true); - resultCode = yield exec.exec(`"${powershellPath}"`, [ - '-NoLogo', - '-Sta', - '-NoProfile', - '-NonInteractive', - '-ExecutionPolicy', - 'Unrestricted', - '-Command', - command - ], { - listeners: { - stdout: (data) => { - output += data.toString(); - } - } - }); - } - else { - let scriptPath = path.join(__dirname, '..', 'externals', 'get-os-distro.sh'); - fs_1.chmodSync(scriptPath, '777'); - const toolPath = yield io.which(scriptPath, true); - resultCode = yield exec.exec(`"${toolPath}"`, [], { - listeners: { - stdout: (data) => { - output += data.toString(); - } - } - }); - } - if (resultCode != 0) { - throw `Failed to detect os with result code ${resultCode}. Output: ${output}`; - } - let index; - if ((index = output.indexOf('Primary:')) >= 0) { - let primary = output.substr(index + 'Primary:'.length).split(os.EOL)[0]; - osSuffix.push(primary); - } - if ((index = output.indexOf('Legacy:')) >= 0) { - let legacy = output.substr(index + 'Legacy:'.length).split(os.EOL)[0]; - osSuffix.push(legacy); - } - if (osSuffix.length == 0) { - throw 'Could not detect platform'; - } - return osSuffix; - }); - } - downloadAndInstall(resolvedVersionInfo) { - return __awaiter(this, void 0, void 0, function* () { - let downloaded = false; - let downloadPath = ''; - for (const url of resolvedVersionInfo.downloadUrls) { - try { - downloadPath = yield tc.downloadTool(url); - downloaded = true; - break; - } - catch (error) { - console.log('Could not Download', url, JSON.stringify(error)); - } - } - if (!downloaded) { - throw 'Failed to download package'; - } - // extract - console.log('Extracting Package', downloadPath); - let extPath = IS_WINDOWS - ? yield tc.extractZip(downloadPath) - : yield tc.extractTar(downloadPath); - // cache tool - console.log('Caching tool'); - let cachedDir = yield tc.cacheDir(extPath, this.cachedToolName, resolvedVersionInfo.resolvedVersion, this.arch); - console.log('Successfully installed', resolvedVersionInfo.resolvedVersion); - return cachedDir; - }); - } - // OsSuffixes - The suffix which is a part of the file name ex- linux-x64, windows-x86 - // Type - SDK / Runtime - // versionInfo - versionInfo of the SDK/Runtime - resolveInfos(osSuffixes, versionInfo) { - return __awaiter(this, void 0, void 0, function* () { - const httpClient = new hc.HttpClient('actions/setup-dotnet', [], { - allowRetries: true, - maxRetries: 3 - }); - const releasesJsonUrl = yield this.getReleasesJsonUrl(httpClient, versionInfo.version().split('.')); - const releasesResponse = yield httpClient.getJson(releasesJsonUrl); - 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())); - }); - // Exclude versions that are newer than the latest if using not exact - if (!versionInfo.isExactVersion()) { - let latestSdk = releasesResult['latest-sdk']; - releasesInfo = releasesInfo.filter((releaseInfo) => semver.lte(releaseInfo['sdk']['version'], latestSdk)); - } - // Sort for latest version - releasesInfo = releasesInfo.sort((a, b) => semver.rcompare(a['sdk']['version'], b['sdk']['version'])); - let downloadedVersion = ''; - let downloadUrls = []; - if (releasesInfo.length != 0) { - let release = releasesInfo[0]; - downloadedVersion = release['sdk']['version']; - let files = release['sdk']['files']; - files = files.filter((file) => { - if (file['rid'] == osSuffixes[0] || file['rid'] == osSuffixes[1]) { - return (file['url'].endsWith('.zip') || file['url'].endsWith('.tar.gz')); - } - }); - if (files.length > 0) { - files.forEach((file) => { - downloadUrls.push(file['url']); - }); - } - else { - throw `The specified version's download links are not correctly formed in the supported versions document => ${releasesJsonUrl}`; - } - } - else { - console.log(`Could not fetch download information for version ${versionInfo.version()}`); - if (versionInfo.isExactVersion()) { - console.log('Using fallback'); - downloadUrls = yield this.getFallbackDownloadUrls(versionInfo.version()); - downloadedVersion = versionInfo.version(); - } - else { - console.log('Unable to use fallback, version is generic!'); - } - } - if (downloadUrls.length == 0) { - throw `Could not construct download URL. Please ensure that specified version ${versionInfo.version()}/${downloadedVersion} is valid.`; - } - core.debug(`Got download urls ${downloadUrls}`); - return new ResolvedVersionInfo(downloadUrls, downloadedVersion); - }); - } - getReleasesJsonUrl(httpClient, versionParts) { - return __awaiter(this, void 0, void 0, function* () { - const response = yield httpClient.getJson(DotNetCoreIndexUrl); - const result = response.result || {}; - let releasesInfo = result['releases-index']; - releasesInfo = releasesInfo.filter((info) => { - // channel-version is the first 2 elements of the version (e.g. 2.1), filter out versions that don't match 2.1.x. - const sdkParts = info['channel-version'].split('.'); - if (versionParts.length >= 2 && versionParts[1] != 'x') { - return versionParts[0] == sdkParts[0] && versionParts[1] == sdkParts[1]; - } - return versionParts[0] == sdkParts[0]; - }); - if (releasesInfo.length === 0) { - throw `Could not find info for version ${versionParts.join('.')} at ${DotNetCoreIndexUrl}`; - } - return releasesInfo[0]['releases.json']; - }); - } - getFallbackDownloadUrls(version) { - return __awaiter(this, void 0, void 0, function* () { - let primaryUrlSearchString; - let legacyUrlSearchString; - let output = ''; - let resultCode = 0; - if (IS_WINDOWS) { - let escapedScript = path - .join(__dirname, '..', 'externals', 'install-dotnet.ps1') - .replace(/'/g, "''"); - let command = `& '${escapedScript}' -Version ${version} -DryRun`; - const powershellPath = yield io.which('powershell', true); - resultCode = yield exec.exec(`"${powershellPath}"`, [ - '-NoLogo', - '-Sta', - '-NoProfile', - '-NonInteractive', - '-ExecutionPolicy', - 'Unrestricted', - '-Command', - command - ], { - listeners: { - stdout: (data) => { - output += data.toString(); - } - } - }); - primaryUrlSearchString = 'dotnet-install: Primary named payload URL: '; - legacyUrlSearchString = 'dotnet-install: Legacy named payload URL: '; - } - else { - let escapedScript = path - .join(__dirname, '..', 'externals', 'install-dotnet.sh') - .replace(/'/g, "''"); - fs_1.chmodSync(escapedScript, '777'); - const scriptPath = yield io.which(escapedScript, true); - resultCode = yield exec.exec(`"${scriptPath}"`, ['--version', version, '--dry-run'], { - listeners: { - stdout: (data) => { - output += data.toString(); - } - } - }); - primaryUrlSearchString = 'dotnet-install: Primary named payload URL: '; - legacyUrlSearchString = 'dotnet-install: Legacy named payload URL: '; - } - if (resultCode != 0) { - throw `Failed to get download urls with result code ${resultCode}. ${output}`; - } - let primaryUrl = ''; - let legacyUrl = ''; - if (!!output && output.length > 0) { - let lines = output.split(os.EOL); - // Fallback to \n if initial split doesn't work (not consistent across versions) - if (lines.length === 1) { - lines = output.split('\n'); - } - if (!!lines && lines.length > 0) { - lines.forEach((line) => { - if (!line) { - return; - } - var primarySearchStringIndex = line.indexOf(primaryUrlSearchString); - if (primarySearchStringIndex > -1) { - primaryUrl = line.substring(primarySearchStringIndex + primaryUrlSearchString.length); - return; - } - var legacySearchStringIndex = line.indexOf(legacyUrlSearchString); - if (legacySearchStringIndex > -1) { - legacyUrl = line.substring(legacySearchStringIndex + legacyUrlSearchString.length); - return; - } - }); - } - } - return [primaryUrl, legacyUrl]; - }); - } -} -exports.DotnetCoreInstaller = DotnetCoreInstaller; -const DotNetCoreIndexUrl = 'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json'; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DotnetCoreInstaller = exports.DotNetVersionInfo = void 0; +// Load tempDirectory before it gets wiped by tool-cache +let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || ''; +const core = __importStar(__webpack_require__(470)); +const exec = __importStar(__webpack_require__(986)); +const io = __importStar(__webpack_require__(1)); +const tc = __importStar(__webpack_require__(533)); +const hc = __webpack_require__(539); +const fs_1 = __webpack_require__(747); +const os = __importStar(__webpack_require__(87)); +const path = __importStar(__webpack_require__(622)); +const semver = __importStar(__webpack_require__(280)); +const IS_WINDOWS = process.platform === 'win32'; +if (!tempDirectory) { + let baseLocation; + if (IS_WINDOWS) { + // On windows use the USERPROFILE env variable + baseLocation = process.env['USERPROFILE'] || 'C:\\'; + } + else { + if (process.platform === 'darwin') { + baseLocation = '/Users'; + } + else { + baseLocation = '/home'; + } + } + tempDirectory = path.join(baseLocation, 'actions', 'temp'); +} +/** + * Represents the inputted version information + */ +class DotNetVersionInfo { + constructor(version) { + this.isExactVersionSet = false; + // Check for exact match + if (semver.valid(semver.clean(version) || '') != null) { + this.fullversion = semver.clean(version); + 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(); + if (parts.length == 3 && parts[2] !== 'x' && parts[2] !== '*') { + this.throwInvalidVersionFormat(); + } + let major = this.getVersionNumberOrThrow(parts[0]); + let minor = this.getVersionNumberOrThrow(parts[1]); + this.fullversion = major + '.' + minor; + } + getVersionNumberOrThrow(input) { + try { + if (!input || input.trim() === '') + this.throwInvalidVersionFormat(); + let number = Number(input); + if (Number.isNaN(number) || number < 0) + this.throwInvalidVersionFormat(); + return number; + } + catch (_a) { + this.throwInvalidVersionFormat(); + return -1; + } + } + throwInvalidVersionFormat() { + throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'; + } + /** + * If true exacatly one version should be resolved + */ + isExactVersion() { + return this.isExactVersionSet; + } + version() { + return this.fullversion; + } +} +exports.DotNetVersionInfo = DotNetVersionInfo; +/** + * Represents a resolved version from the Web-Api + */ +class ResolvedVersionInfo { + constructor(downloadUrls, resolvedVersion) { + if (downloadUrls.length === 0) { + throw 'DownloadUrls can not be empty'; + } + if (!resolvedVersion) { + throw 'Resolved version is invalid'; + } + this.downloadUrls = downloadUrls; + this.resolvedVersion = resolvedVersion; + } +} +class DotnetCoreInstaller { + constructor(version) { + this.versionInfo = new DotNetVersionInfo(version); + this.cachedToolName = 'dncs'; + this.arch = 'x64'; + } + installDotnet() { + return __awaiter(this, void 0, void 0, function* () { + // Check cache + let toolPath = ''; + let osSuffixes = yield this.detectMachineOS(); + let parts = osSuffixes[0].split('-'); + if (parts.length > 1) { + this.arch = parts[1]; + } + // If version is not generic -> look up cache + if (this.versionInfo.isExactVersion()) + toolPath = this.getLocalTool(this.versionInfo.version()); + if (!toolPath) { + // download, extract, cache + console.log('Getting a download url', this.versionInfo.version()); + let resolvedVersionInfo = yield this.resolveInfos(osSuffixes, this.versionInfo); + //Check if cache exists for resolved version + toolPath = this.getLocalTool(resolvedVersionInfo.resolvedVersion); + if (!toolPath) { + //If not exists install it + toolPath = yield this.downloadAndInstall(resolvedVersionInfo); + } + else { + console.log('Using cached tool'); + } + } + else { + console.log('Using cached tool'); + } + // Need to set this so that .NET Core global tools find the right locations. + core.exportVariable('DOTNET_ROOT', toolPath); + // Prepend the tools path. instructs the agent to prepend for future tasks + core.addPath(toolPath); + }); + } + getLocalTool(version) { + console.log('Checking tool cache', version); + return tc.find(this.cachedToolName, version, this.arch); + } + detectMachineOS() { + return __awaiter(this, void 0, void 0, function* () { + let osSuffix = []; + let output = ''; + let resultCode = 0; + if (IS_WINDOWS) { + let escapedScript = path + .join(__dirname, '..', 'externals', 'get-os-platform.ps1') + .replace(/'/g, "''"); + let command = `& '${escapedScript}'`; + const powershellPath = yield io.which('powershell', true); + resultCode = yield exec.exec(`"${powershellPath}"`, [ + '-NoLogo', + '-Sta', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command', + command + ], { + listeners: { + stdout: (data) => { + output += data.toString(); + } + } + }); + } + else { + let scriptPath = path.join(__dirname, '..', 'externals', 'get-os-distro.sh'); + fs_1.chmodSync(scriptPath, '777'); + const toolPath = yield io.which(scriptPath, true); + resultCode = yield exec.exec(`"${toolPath}"`, [], { + listeners: { + stdout: (data) => { + output += data.toString(); + } + } + }); + } + if (resultCode != 0) { + throw `Failed to detect os with result code ${resultCode}. Output: ${output}`; + } + let index; + if ((index = output.indexOf('Primary:')) >= 0) { + let primary = output.substr(index + 'Primary:'.length).split(os.EOL)[0]; + osSuffix.push(primary); + } + if ((index = output.indexOf('Legacy:')) >= 0) { + let legacy = output.substr(index + 'Legacy:'.length).split(os.EOL)[0]; + osSuffix.push(legacy); + } + if (osSuffix.length == 0) { + throw 'Could not detect platform'; + } + return osSuffix; + }); + } + downloadAndInstall(resolvedVersionInfo) { + return __awaiter(this, void 0, void 0, function* () { + let downloaded = false; + let downloadPath = ''; + for (const url of resolvedVersionInfo.downloadUrls) { + try { + downloadPath = yield tc.downloadTool(url); + downloaded = true; + break; + } + catch (error) { + console.log('Could not Download', url, JSON.stringify(error)); + } + } + if (!downloaded) { + throw 'Failed to download package'; + } + // extract + console.log('Extracting Package', downloadPath); + let extPath = IS_WINDOWS + ? yield tc.extractZip(downloadPath) + : yield tc.extractTar(downloadPath); + // cache tool + console.log('Caching tool'); + let cachedDir = yield tc.cacheDir(extPath, this.cachedToolName, resolvedVersionInfo.resolvedVersion, this.arch); + console.log('Successfully installed', resolvedVersionInfo.resolvedVersion); + return cachedDir; + }); + } + // OsSuffixes - The suffix which is a part of the file name ex- linux-x64, windows-x86 + // Type - SDK / Runtime + // versionInfo - versionInfo of the SDK/Runtime + resolveInfos(osSuffixes, versionInfo) { + return __awaiter(this, void 0, void 0, function* () { + const httpClient = new hc.HttpClient('actions/setup-dotnet', [], { + allowRetries: true, + maxRetries: 3 + }); + const releasesJsonUrl = yield this.getReleasesJsonUrl(httpClient, versionInfo.version().split('.')); + const releasesResponse = yield httpClient.getJson(releasesJsonUrl); + 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())); + }); + // Exclude versions that are newer than the latest if using not exact + if (!versionInfo.isExactVersion()) { + let latestSdk = releasesResult['latest-sdk']; + releasesInfo = releasesInfo.filter((releaseInfo) => semver.lte(releaseInfo['sdk']['version'], latestSdk)); + } + // Sort for latest version + releasesInfo = releasesInfo.sort((a, b) => semver.rcompare(a['sdk']['version'], b['sdk']['version'])); + let downloadedVersion = ''; + let downloadUrls = []; + if (releasesInfo.length != 0) { + let release = releasesInfo[0]; + downloadedVersion = release['sdk']['version']; + let files = release['sdk']['files']; + files = files.filter((file) => { + if (file['rid'] == osSuffixes[0] || file['rid'] == osSuffixes[1]) { + return (file['url'].endsWith('.zip') || file['url'].endsWith('.tar.gz')); + } + }); + if (files.length > 0) { + files.forEach((file) => { + downloadUrls.push(file['url']); + }); + } + else { + throw `The specified version's download links are not correctly formed in the supported versions document => ${releasesJsonUrl}`; + } + } + else { + console.log(`Could not fetch download information for version ${versionInfo.version()}`); + if (versionInfo.isExactVersion()) { + console.log('Using fallback'); + downloadUrls = yield this.getFallbackDownloadUrls(versionInfo.version()); + downloadedVersion = versionInfo.version(); + } + else { + console.log('Unable to use fallback, version is generic!'); + } + } + if (downloadUrls.length == 0) { + throw `Could not construct download URL. Please ensure that specified version ${versionInfo.version()}/${downloadedVersion} is valid.`; + } + core.debug(`Got download urls ${downloadUrls}`); + return new ResolvedVersionInfo(downloadUrls, downloadedVersion); + }); + } + getReleasesJsonUrl(httpClient, versionParts) { + return __awaiter(this, void 0, void 0, function* () { + const response = yield httpClient.getJson(DotNetCoreIndexUrl); + const result = response.result || {}; + let releasesInfo = result['releases-index']; + releasesInfo = releasesInfo.filter((info) => { + // channel-version is the first 2 elements of the version (e.g. 2.1), filter out versions that don't match 2.1.x. + const sdkParts = info['channel-version'].split('.'); + if (versionParts.length >= 2 && versionParts[1] != 'x') { + return versionParts[0] == sdkParts[0] && versionParts[1] == sdkParts[1]; + } + return versionParts[0] == sdkParts[0]; + }); + if (releasesInfo.length === 0) { + throw `Could not find info for version ${versionParts.join('.')} at ${DotNetCoreIndexUrl}`; + } + return releasesInfo[0]['releases.json']; + }); + } + getFallbackDownloadUrls(version) { + return __awaiter(this, void 0, void 0, function* () { + let primaryUrlSearchString; + let legacyUrlSearchString; + let output = ''; + let resultCode = 0; + if (IS_WINDOWS) { + let escapedScript = path + .join(__dirname, '..', 'externals', 'install-dotnet.ps1') + .replace(/'/g, "''"); + let command = `& '${escapedScript}' -Version ${version} -DryRun`; + const powershellPath = yield io.which('powershell', true); + resultCode = yield exec.exec(`"${powershellPath}"`, [ + '-NoLogo', + '-Sta', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command', + command + ], { + listeners: { + stdout: (data) => { + output += data.toString(); + } + } + }); + primaryUrlSearchString = 'dotnet-install: Primary named payload URL: '; + legacyUrlSearchString = 'dotnet-install: Legacy named payload URL: '; + } + else { + let escapedScript = path + .join(__dirname, '..', 'externals', 'install-dotnet.sh') + .replace(/'/g, "''"); + fs_1.chmodSync(escapedScript, '777'); + const scriptPath = yield io.which(escapedScript, true); + resultCode = yield exec.exec(`"${scriptPath}"`, ['--version', version, '--dry-run'], { + listeners: { + stdout: (data) => { + output += data.toString(); + } + } + }); + primaryUrlSearchString = 'dotnet-install: Primary named payload URL: '; + legacyUrlSearchString = 'dotnet-install: Legacy named payload URL: '; + } + if (resultCode != 0) { + throw `Failed to get download urls with result code ${resultCode}. ${output}`; + } + let primaryUrl = ''; + let legacyUrl = ''; + if (!!output && output.length > 0) { + let lines = output.split(os.EOL); + // Fallback to \n if initial split doesn't work (not consistent across versions) + if (lines.length === 1) { + lines = output.split('\n'); + } + if (!!lines && lines.length > 0) { + lines.forEach((line) => { + if (!line) { + return; + } + var primarySearchStringIndex = line.indexOf(primaryUrlSearchString); + if (primarySearchStringIndex > -1) { + primaryUrl = line.substring(primarySearchStringIndex + primaryUrlSearchString.length); + return; + } + var legacySearchStringIndex = line.indexOf(legacyUrlSearchString); + if (legacySearchStringIndex > -1) { + legacyUrl = line.substring(legacySearchStringIndex + legacyUrlSearchString.length); + return; + } + }); + } + } + return [primaryUrl, legacyUrl]; + }); + } +} +exports.DotnetCoreInstaller = DotnetCoreInstaller; +const DotNetCoreIndexUrl = 'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json'; /***/ }), diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index b4fe690..ec804eb 100644 --- a/src/setup-dotnet.ts +++ b/src/setup-dotnet.ts @@ -7,13 +7,13 @@ import * as auth from './authutil'; export async function run() { try { // - // Version is optional. If supplied, install / use from the tool cache - // If not supplied then task is still used to setup proxy, auth, etc... + // dotnet-version is optional, but needs to be provided for most use cases. + // If supplied, install / use from the tool cache. + // If not supplied, look for version in ./global.json. + // If a valid version still can't be identified, nothing will be installed. + // Proxy, auth, (etc) are still set up, even if no version is identified // - let version: string = core.getInput('version'); - if (!version) { - version = core.getInput('dotnet-version'); - } + let version = core.getInput('dotnet-version'); if (!version) { // Try to fall back to global.json core.debug('No version found, trying to find version from global.json');