From b80fc554fbff3dfd5f164f08bead18433d181a3d Mon Sep 17 00:00:00 2001 From: actions-bot Date: Thu, 15 Oct 2020 01:14:42 +0000 Subject: [PATCH] chore: build dist --- dist/index.js | 136 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 98 insertions(+), 38 deletions(-) diff --git a/dist/index.js b/dist/index.js index 14a917b..c2b9060 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3168,7 +3168,6 @@ async function main () { // Next we check for PRs merged since the last release, and groom the // release PR: if (!command || command === 'release-pr') { - console.info(changelogSections) const release = ReleasePRFactory.buildStatic(releaseType, { monorepoTags, packageName, @@ -5701,7 +5700,7 @@ module.exports = require("vm"); /* 191 */ /***/ (function(module) { -module.exports = {"_args":[["release-please@6.4.2-candidate-0","/home/runner/work/release-please-action/release-please-action"]],"_from":"release-please@6.4.2-candidate-0","_id":"release-please@6.4.2-candidate-0","_inBundle":false,"_integrity":"sha512-mly1qOqAWGN298iV6QHQsFwmoO7H7cmTP3v7LnCL0/SeqOuHKc0I+8NSE6slYcr49A2bulc72OsamNINnqeIeg==","_location":"/release-please","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"release-please@6.4.2-candidate-0","name":"release-please","escapedName":"release-please","rawSpec":"6.4.2-candidate-0","saveSpec":null,"fetchSpec":"6.4.2-candidate-0"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/release-please/-/release-please-6.4.2-candidate-0.tgz","_spec":"6.4.2-candidate-0","_where":"/home/runner/work/release-please-action/release-please-action","author":{"name":"Google Inc."},"bin":{"release-please":"build/src/bin/release-please.js"},"bugs":{"url":"https://github.com/googleapis/release-please/issues"},"dependencies":{"@octokit/graphql":"^4.3.1","@octokit/request":"^5.3.4","@octokit/rest":"^18.0.4","chalk":"^4.0.0","code-suggester":"^1.4.0","concat-stream":"^2.0.0","conventional-changelog-conventionalcommits":"^4.4.0","conventional-changelog-writer":"^4.0.6","conventional-commits-filter":"^2.0.2","conventional-commits-parser":"^3.0.3","figures":"^3.0.0","parse-github-repo-url":"^1.4.1","semver":"^7.0.0","type-fest":"^0.17.0","yargs":"^16.0.0"},"description":"generate release PRs based on the conventionalcommits.org spec","devDependencies":{"@microsoft/api-documenter":"^7.8.10","@microsoft/api-extractor":"^7.8.10","@octokit/types":"^5.0.0","@types/chai":"^4.1.7","@types/mocha":"^8.0.0","@types/node":"^11.13.6","@types/pino":"^6.3.0","@types/semver":"^7.0.0","@types/sinon":"^9.0.5","@types/yargs":"^15.0.4","c8":"^7.0.0","chai":"^4.2.0","cross-env":"^7.0.0","gts":"^2.0.0","mocha":"^8.0.0","nock":"^13.0.0","sinon":"^9.0.3","snap-shot-it":"^7.0.0","typescript":"^3.8.3"},"engines":{"node":">=10.12.0"},"files":["build/src","templates","!build/src/**/*.map"],"homepage":"https://github.com/googleapis/release-please#readme","keywords":["release","conventional-commits"],"license":"Apache-2.0","main":"./build/src/index.js","name":"release-please","repository":{"type":"git","url":"git+https://github.com/googleapis/release-please.git"},"scripts":{"api-documenter":"api-documenter yaml --input-folder=temp","api-extractor":"api-extractor run --local","clean":"gts clean","compile":"tsc -p .","docs-test":"echo add docs tests","fix":"gts fix","lint":"gts check","prepare":"npm run compile","presystem-test":"npm run compile","pretest":"npm run compile","system-test":"echo 'no system tests'","test":"cross-env ENVIRONMENT=test c8 mocha --recursive --timeout=5000 build/test","test:all":"cross-env ENVIRONMENT=test c8 mocha --recursive --timeout=20000 build/system-test build/test","test:snap":"SNAPSHOT_UPDATE=1 npm test"},"version":"6.4.2-candidate-0"}; +module.exports = {"_args":[["release-please@6.4.2-candidate-2","/home/runner/work/release-please-action/release-please-action"]],"_from":"release-please@6.4.2-candidate-2","_id":"release-please@6.4.2-candidate-2","_inBundle":false,"_integrity":"sha512-cDL8C2S0nMp6u7g7yf58jG/Tg2N/+IwkcFLvfKfSh3HwD9X9Ys0CysdZpNLtMSdTwaP7F2+EJ+Ox+qfmChWgfg==","_location":"/release-please","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"release-please@6.4.2-candidate-2","name":"release-please","escapedName":"release-please","rawSpec":"6.4.2-candidate-2","saveSpec":null,"fetchSpec":"6.4.2-candidate-2"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/release-please/-/release-please-6.4.2-candidate-2.tgz","_spec":"6.4.2-candidate-2","_where":"/home/runner/work/release-please-action/release-please-action","author":{"name":"Google Inc."},"bin":{"release-please":"build/src/bin/release-please.js"},"bugs":{"url":"https://github.com/googleapis/release-please/issues"},"dependencies":{"@octokit/graphql":"^4.3.1","@octokit/request":"^5.3.4","@octokit/rest":"^18.0.4","chalk":"^4.0.0","code-suggester":"^1.4.0","concat-stream":"^2.0.0","conventional-changelog-conventionalcommits":"^4.4.0","conventional-changelog-writer":"^4.0.6","conventional-commits-filter":"^2.0.2","conventional-commits-parser":"^3.0.3","figures":"^3.0.0","parse-github-repo-url":"^1.4.1","semver":"^7.0.0","type-fest":"^0.17.0","yargs":"^16.0.0"},"description":"generate release PRs based on the conventionalcommits.org spec","devDependencies":{"@microsoft/api-documenter":"^7.8.10","@microsoft/api-extractor":"^7.8.10","@octokit/types":"^5.0.0","@types/chai":"^4.1.7","@types/mocha":"^8.0.0","@types/node":"^11.13.6","@types/pino":"^6.3.0","@types/semver":"^7.0.0","@types/sinon":"^9.0.5","@types/yargs":"^15.0.4","c8":"^7.0.0","chai":"^4.2.0","cross-env":"^7.0.0","gts":"^2.0.0","mocha":"^8.0.0","nock":"^13.0.0","sinon":"^9.0.3","snap-shot-it":"^7.0.0","typescript":"^3.8.3"},"engines":{"node":">=10.12.0"},"files":["build/src","templates","!build/src/**/*.map"],"homepage":"https://github.com/googleapis/release-please#readme","keywords":["release","conventional-commits"],"license":"Apache-2.0","main":"./build/src/index.js","name":"release-please","repository":{"type":"git","url":"git+https://github.com/googleapis/release-please.git"},"scripts":{"api-documenter":"api-documenter yaml --input-folder=temp","api-extractor":"api-extractor run --local","clean":"gts clean","compile":"tsc -p .","docs-test":"echo add docs tests","fix":"gts fix","lint":"gts check","prepare":"npm run compile","presystem-test":"npm run compile","pretest":"npm run compile","system-test":"echo 'no system tests'","test":"cross-env ENVIRONMENT=test c8 mocha --recursive --timeout=5000 build/test","test:all":"cross-env ENVIRONMENT=test c8 mocha --recursive --timeout=20000 build/system-test build/test","test:snap":"SNAPSHOT_UPDATE=1 npm test"},"version":"6.4.2-candidate-2"}; /***/ }), /* 192 */, @@ -43547,9 +43546,9 @@ class GitHub { if (!preRelease) regexpString = `^${regexpString}[^-]*$`; const regexp = regexpString ? new RegExp(regexpString) : null; - const pull = await this.findMergedReleasePR([], 100, regexp); + const pull = await this.findMergedReleasePR([], 1024, regexp); if (!pull) - return undefined; + return await this.latestTagFallback(prefix, preRelease); const tag = { name: `v${pull.version}`, sha: pull.sha, @@ -43557,41 +43556,102 @@ class GitHub { }; return tag; } - // The default matcher will rule out pre-releases. - async findMergedReleasePR(labels, perPage = 100, matcher = /[^-]*/) { - const baseLabel = await this.getBaseLabel(); - const pullsResponse = (await this.request(`GET /repos/:owner/:repo/pulls?state=closed&per_page=${perPage}${this.proxyKey ? `&key=${this.proxyKey}` : ''}&sort=updated&direction=desc`, { - owner: this.owner, - repo: this.repo, - })); - for (let i = 0, pull; i < pullsResponse.data.length; i++) { - pull = pullsResponse.data[i]; - if (labels.length === 0 || - this.hasAllLabels(labels, pull.labels.map(l => l.name))) { - // it's expected that a release PR will have a - // HEAD matching the format repo:release-v1.0.0. - if (!pull.head) - continue; - // Verify that this PR was based against our base branch of interest. - if (!pull.base || pull.base.label !== baseLabel) - continue; - const match = pull.head.label.match(VERSION_FROM_BRANCH_RE); - if (!match || !pull.merged_at) - continue; - // Make sure we did get a valid semver. - const version = match[1]; - const normalizedVersion = semver.valid(version); - if (!normalizedVersion) - continue; - // Does its name match any passed matcher? - if (matcher && !matcher.test(normalizedVersion)) - continue; - return { - number: pull.number, - sha: pull.merge_commit_sha, - version: normalizedVersion, - }; + // If we can't find a release branch (a common cause of this, as an example + // is that we might be dealing with the first relese), use the last semver + // tag that's available on the repository: + // TODO: it would be good to not need to maintain this logic, and the + // logic that introspects version based on the prior release PR. + async latestTagFallback(prefix, preRelease = false) { + const tags = await this.allTags(prefix); + const versions = Object.keys(tags).filter(t => { + // remove any pre-releases from the list: + return preRelease || !t.includes('-'); + }); + // no tags have been created yet. + if (versions.length === 0) + return undefined; + // We use a slightly modified version of semver's sorting algorithm, which + // prefixes the numeric part of a pre-release with '0's, so that + // 010 is greater than > 002. + versions.sort((v1, v2) => { + if (v1.includes('-')) { + const [prefix, suffix] = v1.split('-'); + v1 = prefix + '-' + suffix.replace(/[a-zA-Z.]/, '').padStart(6, '0'); } + if (v2.includes('-')) { + const [prefix, suffix] = v2.split('-'); + v2 = prefix + '-' + suffix.replace(/[a-zA-Z.]/, '').padStart(6, '0'); + } + return semver.rcompare(v1, v2); + }); + return { + name: tags[versions[0]].name, + sha: tags[versions[0]].sha, + version: tags[versions[0]].version, + }; + } + async allTags(prefix) { + const tags = {}; + for await (const response of this.octokit.paginate.iterator(this.decoratePaginateOpts({ + method: 'GET', + url: `/repos/${this.owner}/${this.repo}/tags?per_page=100${this.proxyKey ? `&key=${this.proxyKey}` : ''}`, + }))) { + response.data.forEach((data) => { + // For monorepos, a prefix can be provided, indicating that only tags + // matching the prefix should be returned: + if (prefix && !data.name.startsWith(prefix)) + return; + let version = data.name.replace(prefix, ''); + if ((version = semver.valid(version))) { + tags[version] = { sha: data.commit.sha, name: data.name, version }; + } + }); + } + return tags; + } + // The default matcher will rule out pre-releases. + async findMergedReleasePR(labels, maxPRsChecked = 100, matcher = /[^-]*/) { + const baseLabel = await this.getBaseLabel(); + let total = 0; + for await (const response of this.octokit.paginate.iterator(this.decoratePaginateOpts({ + method: 'GET', + url: `/repos/${this.owner}/${this.repo}/pulls?per_page=25${this.proxyKey ? `&key=${this.proxyKey}` : ''}&state=closed&sort=updated&direction=desc`, + }))) { + const pullsResponse = response; + console.info(response); + for (let i = 0, pull; i < pullsResponse.data.length; i++) { + total++; + pull = pullsResponse.data[i]; + if (labels.length === 0 || + this.hasAllLabels(labels, pull.labels.map(l => l.name))) { + // it's expected that a release PR will have a + // HEAD matching the format repo:release-v1.0.0. + if (!pull.head) + continue; + // Verify that this PR was based against our base branch of interest. + if (!pull.base || pull.base.label !== baseLabel) + continue; + const match = pull.head.label.match(VERSION_FROM_BRANCH_RE); + if (!match || !pull.merged_at) + continue; + // Make sure we did get a valid semver. + const version = match[1]; + const normalizedVersion = semver.valid(version); + if (!normalizedVersion) + continue; + // Does its name match any passed matcher? + if (matcher && !matcher.test(normalizedVersion)) + continue; + return { + number: pull.number, + sha: pull.merge_commit_sha, + version: normalizedVersion, + }; + } + } + console.info(total, maxPRsChecked); + if (total >= maxPRsChecked) + return undefined; } return undefined; }