diff --git a/dist/commit.hbs b/dist/commit.hbs index fe003a0..28d9293 100644 --- a/dist/commit.hbs +++ b/dist/commit.hbs @@ -1,2 +1,56 @@ -* {{#if subject}} {{~subject}} {{~else}} {{~header}} {{~/if}}{{#if body}} -{{body}}{{~/if}} +* {{header}} + +{{~!-- commit link --}} {{#if @root.linkReferences~}} + ([{{hash}}]( + {{~#if @root.repository}} + {{~#if @root.host}} + {{~@root.host}}/ + {{~/if}} + {{~#if @root.owner}} + {{~@root.owner}}/ + {{~/if}} + {{~@root.repository}} + {{~else}} + {{~@root.repoUrl}} + {{~/if}}/ + {{~@root.commit}}/{{hash}})) +{{~else}} + {{~hash}} +{{~/if}} + +{{~!-- commit references --}} +{{~#if references~}} + , closes + {{~#each references}} {{#if @root.linkReferences~}} + [ + {{~#if this.owner}} + {{~this.owner}}/ + {{~/if}} + {{~this.repository}}#{{this.issue}}]( + {{~#if @root.repository}} + {{~#if @root.host}} + {{~@root.host}}/ + {{~/if}} + {{~#if this.repository}} + {{~#if this.owner}} + {{~this.owner}}/ + {{~/if}} + {{~this.repository}} + {{~else}} + {{~#if @root.owner}} + {{~@root.owner}}/ + {{~/if}} + {{~@root.repository}} + {{~/if}} + {{~else}} + {{~@root.repoUrl}} + {{~/if}}/ + {{~@root.issue}}/{{this.issue}}) + {{~else}} + {{~#if this.owner}} + {{~this.owner}}/ + {{~/if}} + {{~this.repository}}#{{this.issue}} + {{~/if}}{{/each}} +{{~/if}} + diff --git a/dist/commit1.hbs b/dist/commit1.hbs index 28d9293..641c2f3 100644 --- a/dist/commit1.hbs +++ b/dist/commit1.hbs @@ -1,23 +1,16 @@ -* {{header}} - -{{~!-- commit link --}} {{#if @root.linkReferences~}} - ([{{hash}}]( - {{~#if @root.repository}} - {{~#if @root.host}} - {{~@root.host}}/ - {{~/if}} - {{~#if @root.owner}} - {{~@root.owner}}/ - {{~/if}} - {{~@root.repository}} - {{~else}} - {{~@root.repoUrl}} - {{~/if}}/ - {{~@root.commit}}/{{hash}})) +*{{#if scope}} **{{scope}}:** +{{~/if}} {{#if subject}} + {{~subject}} {{~else}} - {{~hash}} + {{~header}} {{~/if}} +{{~!-- commit link --}}{{~#if hash}} {{#if @root.linkReferences~}} + ([{{shortHash}}]({{commitUrlFormat}})) +{{~else}} + {{~shortHash}} +{{~/if}}{{~/if}} + {{~!-- commit references --}} {{~#if references~}} , closes @@ -26,31 +19,12 @@ {{~#if this.owner}} {{~this.owner}}/ {{~/if}} - {{~this.repository}}#{{this.issue}}]( - {{~#if @root.repository}} - {{~#if @root.host}} - {{~@root.host}}/ - {{~/if}} - {{~#if this.repository}} - {{~#if this.owner}} - {{~this.owner}}/ - {{~/if}} - {{~this.repository}} - {{~else}} - {{~#if @root.owner}} - {{~@root.owner}}/ - {{~/if}} - {{~@root.repository}} - {{~/if}} - {{~else}} - {{~@root.repoUrl}} - {{~/if}}/ - {{~@root.issue}}/{{this.issue}}) + {{~this.repository}}{{this.prefix}}{{this.issue}}]({{issueUrlFormat}}) {{~else}} {{~#if this.owner}} {{~this.owner}}/ {{~/if}} - {{~this.repository}}#{{this.issue}} + {{~this.repository}}{{this.prefix}}{{this.issue}} {{~/if}}{{/each}} {{~/if}} diff --git a/dist/commit2.hbs b/dist/commit2.hbs index 641c2f3..fe003a0 100644 --- a/dist/commit2.hbs +++ b/dist/commit2.hbs @@ -1,30 +1,2 @@ -*{{#if scope}} **{{scope}}:** -{{~/if}} {{#if subject}} - {{~subject}} -{{~else}} - {{~header}} -{{~/if}} - -{{~!-- commit link --}}{{~#if hash}} {{#if @root.linkReferences~}} - ([{{shortHash}}]({{commitUrlFormat}})) -{{~else}} - {{~shortHash}} -{{~/if}}{{~/if}} - -{{~!-- commit references --}} -{{~#if references~}} - , closes - {{~#each references}} {{#if @root.linkReferences~}} - [ - {{~#if this.owner}} - {{~this.owner}}/ - {{~/if}} - {{~this.repository}}{{this.prefix}}{{this.issue}}]({{issueUrlFormat}}) - {{~else}} - {{~#if this.owner}} - {{~this.owner}}/ - {{~/if}} - {{~this.repository}}{{this.prefix}}{{this.issue}} - {{~/if}}{{/each}} -{{~/if}} - +* {{#if subject}} {{~subject}} {{~else}} {{~header}} {{~/if}}{{#if body}} +{{body}}{{~/if}} diff --git a/dist/header.hbs b/dist/header.hbs index c5ed4d2..49f5607 100644 --- a/dist/header.hbs +++ b/dist/header.hbs @@ -1,9 +1,9 @@ -### {{#if @root.linkCompare~}} - [{{version}}]({{compareUrlFormat}}) -{{~else}} - {{~version}} -{{~/if}} -{{~#if title}} "{{title}}" -{{~/if}} -{{~#if date}} / {{date}} -{{/if}} +## {{#if isPatch~}} + {{~/if~}} {{version}} + {{~#if title}} "{{title}}" + {{~/if~}} + {{~#if date}} ({{date}}) + {{~/if~}} + {{~#if isPatch~}} + {{~/if}} + diff --git a/dist/header1.hbs b/dist/header1.hbs index 49f5607..a4d6ec4 100644 --- a/dist/header1.hbs +++ b/dist/header1.hbs @@ -1,9 +1,13 @@ -## {{#if isPatch~}} - {{~/if~}} {{version}} - {{~#if title}} "{{title}}" - {{~/if~}} - {{~#if date}} ({{date}}) - {{~/if~}} - {{~#if isPatch~}} - {{~/if}} - +{{#if isPatch~}} + ### +{{~else~}} + ## +{{~/if}} {{#if @root.linkCompare~}} + [{{version}}]({{compareUrlFormat}}) +{{~else}} + {{~version}} +{{~/if}} +{{~#if title}} "{{title}}" +{{~/if}} +{{~#if date}} ({{date}}) +{{/if}} diff --git a/dist/header2.hbs b/dist/header2.hbs index a4d6ec4..c5ed4d2 100644 --- a/dist/header2.hbs +++ b/dist/header2.hbs @@ -1,13 +1,9 @@ -{{#if isPatch~}} - ### -{{~else~}} - ## -{{~/if}} {{#if @root.linkCompare~}} +### {{#if @root.linkCompare~}} [{{version}}]({{compareUrlFormat}}) {{~else}} {{~version}} {{~/if}} {{~#if title}} "{{title}}" {{~/if}} -{{~#if date}} ({{date}}) +{{~#if date}} / {{date}} {{/if}} diff --git a/dist/index.js b/dist/index.js index 38aad10..01669d8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -18757,9 +18757,9 @@ module.exports = function (config) { }) return Q.all([ - readFile(__nccwpck_require__.ab + "template2.hbs", 'utf-8'), - readFile(__nccwpck_require__.ab + "header2.hbs", 'utf-8'), - readFile(__nccwpck_require__.ab + "commit2.hbs", 'utf-8'), + readFile(__nccwpck_require__.ab + "template1.hbs", 'utf-8'), + readFile(__nccwpck_require__.ab + "header1.hbs", 'utf-8'), + readFile(__nccwpck_require__.ab + "commit1.hbs", 'utf-8'), readFile(__nccwpck_require__.ab + "footer1.hbs", 'utf-8') ]) .spread((template, header, commit, footer) => { @@ -18979,9 +18979,9 @@ function conventionalChangelogWriterInit (context, options) { includeDetails: false, ignoreReverted: true, doFlush: true, - mainTemplate: readFileSync(__nccwpck_require__.ab + "template1.hbs", 'utf-8'), - headerPartial: readFileSync(__nccwpck_require__.ab + "header1.hbs", 'utf-8'), - commitPartial: readFileSync(__nccwpck_require__.ab + "commit1.hbs", 'utf-8'), + mainTemplate: readFileSync(__nccwpck_require__.ab + "template.hbs", 'utf-8'), + headerPartial: readFileSync(__nccwpck_require__.ab + "header.hbs", 'utf-8'), + commitPartial: readFileSync(__nccwpck_require__.ab + "commit.hbs", 'utf-8'), footerPartial: readFileSync(__nccwpck_require__.ab + "footer.hbs", 'utf-8') }, options) @@ -76614,21 +76614,27 @@ const cargo_workspace_1 = __nccwpck_require__(77430); const github_1 = __nccwpck_require__(88433); const default_2 = __nccwpck_require__(71480); const linked_versions_1 = __nccwpck_require__(59641); +const dotnet_yoshi_1 = __nccwpck_require__(98175); +const java_1 = __nccwpck_require__(46892); +const maven_1 = __nccwpck_require__(60899); // Factory shared by GitHub Action and CLI for creating Release PRs // and GitHub Releases: // add any new releasers you create to this type as well as the `releasers` // object below. const allReleaseTypes = [ 'dart', + 'dotnet-yoshi', 'elixir', 'go', 'go-yoshi', 'helm', + 'java', 'java-backport', 'java-bom', 'java-lts', 'java-yoshi', 'krm-blueprint', + 'maven', 'node', 'ocaml', 'php', @@ -76641,9 +76647,9 @@ const allReleaseTypes = [ 'terraform-module', ]; const releasers = { + 'dotnet-yoshi': options => new dotnet_yoshi_1.DotnetYoshi(options), go: options => new go_1.Go(options), 'go-yoshi': options => new go_yoshi_1.GoYoshi(options), - 'java-yoshi': options => new java_yoshi_1.JavaYoshi(options), 'krm-blueprint': options => new krm_blueprint_1.KRMBlueprint(options), node: options => new node_1.Node(options), ocaml: options => new ocaml_1.OCaml(options), @@ -76713,6 +76719,24 @@ async function buildStrategy(options) { versionFile: options.versionFile, }); } + case 'java': { + return new java_1.Java({ + ...strategyOptions, + snapshotLabels: options.snapshotLabels, + }); + } + case 'maven': { + return new maven_1.Maven({ + ...strategyOptions, + snapshotLabels: options.snapshotLabels, + }); + } + case 'java-yoshi': { + return new java_yoshi_1.JavaYoshi({ + ...strategyOptions, + snapshotLabels: options.snapshotLabels, + }); + } case 'java-backport': { return new java_yoshi_1.JavaYoshi({ ...strategyOptions, @@ -77804,7 +77828,7 @@ const wrapAsync = (fn, errorHandler) => { // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.Manifest = exports.MANIFEST_PULL_REQUEST_TITLE_PATTERN = exports.ROOT_PROJECT_PATH = exports.DEFAULT_RELEASE_PLEASE_MANIFEST = exports.DEFAULT_RELEASE_PLEASE_CONFIG = void 0; +exports.Manifest = exports.MANIFEST_PULL_REQUEST_TITLE_PATTERN = exports.SNOOZE_LABEL = exports.DEFAULT_SNAPSHOT_LABELS = exports.DEFAULT_RELEASE_LABELS = exports.DEFAULT_LABELS = exports.DEFAULT_COMPONENT_NAME = exports.ROOT_PROJECT_PATH = exports.DEFAULT_RELEASE_PLEASE_MANIFEST = exports.DEFAULT_RELEASE_PLEASE_CONFIG = void 0; const version_1 = __nccwpck_require__(17348); const logger_1 = __nccwpck_require__(68809); const commit_split_1 = __nccwpck_require__(6941); @@ -77819,9 +77843,11 @@ const errors_1 = __nccwpck_require__(93637); exports.DEFAULT_RELEASE_PLEASE_CONFIG = 'release-please-config.json'; exports.DEFAULT_RELEASE_PLEASE_MANIFEST = '.release-please-manifest.json'; exports.ROOT_PROJECT_PATH = '.'; -const DEFAULT_COMPONENT_NAME = ''; -const DEFAULT_LABELS = ['autorelease: pending']; -const DEFAULT_RELEASE_LABELS = ['autorelease: tagged']; +exports.DEFAULT_COMPONENT_NAME = ''; +exports.DEFAULT_LABELS = ['autorelease: pending']; +exports.DEFAULT_RELEASE_LABELS = ['autorelease: tagged']; +exports.DEFAULT_SNAPSHOT_LABELS = ['autorelease: snapshot']; +exports.SNOOZE_LABEL = 'autorelease: snooze'; exports.MANIFEST_PULL_REQUEST_TITLE_PATTERN = 'chore: release ${branch}'; class Manifest { /** @@ -77863,8 +77889,10 @@ class Manifest { this.fork = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.fork) || false; this.signoffUser = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.signoff; this.releaseLabels = - (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.releaseLabels) || DEFAULT_RELEASE_LABELS; - this.labels = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.labels) || DEFAULT_LABELS; + (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.releaseLabels) || exports.DEFAULT_RELEASE_LABELS; + this.labels = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.labels) || exports.DEFAULT_LABELS; + this.snapshotLabels = + (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.snapshotLabels) || exports.DEFAULT_SNAPSHOT_LABELS; this.bootstrapSha = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.bootstrapSha; this.lastReleaseSha = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.lastReleaseSha; this.draft = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.draft; @@ -77878,11 +77906,12 @@ class Manifest { * @param {string} targetBranch The releaseable base branch * @param {string} configFile Optional. The path to the manifest config file * @param {string} manifestFile Optional. The path to the manifest versions file + * @param {string} path The single path to check. Optional * @returns {Manifest} */ - static async fromManifest(github, targetBranch, configFile = exports.DEFAULT_RELEASE_PLEASE_CONFIG, manifestFile = exports.DEFAULT_RELEASE_PLEASE_MANIFEST, manifestOptionOverrides = {}) { + static async fromManifest(github, targetBranch, configFile = exports.DEFAULT_RELEASE_PLEASE_CONFIG, manifestFile = exports.DEFAULT_RELEASE_PLEASE_MANIFEST, manifestOptionOverrides = {}, path, releaseAs) { const [{ config: repositoryConfig, options: manifestOptions }, releasedVersions,] = await Promise.all([ - parseConfig(github, configFile, targetBranch), + parseConfig(github, configFile, targetBranch, path, releaseAs), parseReleasedVersions(github, manifestFile, targetBranch), ]); return new Manifest(github, targetBranch, repositoryConfig, releasedVersions, { @@ -77925,7 +77954,7 @@ class Manifest { }); const component = await strategy.getComponent(); const releasedVersions = {}; - const latestVersion = await latestReleaseVersion(github, targetBranch, config.includeComponentInTag ? component : '', config.pullRequestTitlePattern); + const latestVersion = await latestReleaseVersion(github, targetBranch, version => isPublishedVersion(strategy, version), config.includeComponentInTag ? component : '', config.pullRequestTitlePattern); if (latestVersion) { releasedVersions[path] = latestVersion; } @@ -77963,7 +77992,7 @@ class Manifest { logger_1.logger.warn(`Unable to parse release name: ${release.name}`); continue; } - const component = tagName.component || DEFAULT_COMPONENT_NAME; + const component = tagName.component || exports.DEFAULT_COMPONENT_NAME; const path = pathsByComponent[component]; if (!path) { logger_1.logger.warn(`Found release tag with component '${component}', but not configured in manifest`); @@ -78111,7 +78140,9 @@ class Manifest { const latestRelease = releasesByPath[path]; const releasePullRequest = await strategy.buildReleasePullRequest(pathCommits, latestRelease, (_a = config.draftPullRequest) !== null && _a !== void 0 ? _a : this.draftPullRequest, this.labels); if (releasePullRequest) { - if (releasePullRequest.version) { + // Update manifest, but only for valid release version - this will skip SNAPSHOT from java strategy + if (releasePullRequest.version && + isPublishedVersion(strategy, releasePullRequest.version)) { const versionsMap = new Map(); versionsMap.set(path, releasePullRequest.version); releasePullRequest.updates.push({ @@ -78150,7 +78181,7 @@ class Manifest { continue; } const component = await strategiesByPath[path].getComponent(); - const expectedTag = new tag_name_1.TagName(expectedVersion, component, this.repositoryConfig[path].tagSeparator); + const expectedTag = new tag_name_1.TagName(expectedVersion, component, this.repositoryConfig[path].tagSeparator, this.repositoryConfig[path].includeVInTag); logger_1.logger.debug(`looking for tagName: ${expectedTag.toString()}`); const foundTag = allTags[expectedTag.toString()]; if (foundTag) { @@ -78189,46 +78220,90 @@ class Manifest { logger_1.logger.warn('There are untagged, merged release PRs outstanding - aborting'); return []; } - // collect open release pull requests + // collect open and snoozed release pull requests + const openPullRequests = await this.findOpenReleasePullRequests(); + const snoozedPullRequests = await this.findSnoozedReleasePullRequests(); + const promises = []; + for (const pullRequest of candidatePullRequests) { + promises.push(this.createOrUpdatePullRequest(pullRequest, openPullRequests, snoozedPullRequests)); + } + const pullNumbers = await Promise.all(promises); + // reject any pull numbers that were not created or updated + return pullNumbers.filter(number => !!number); + } + async findOpenReleasePullRequests() { logger_1.logger.info('Looking for open release pull requests'); const openPullRequests = []; const generator = this.github.pullRequestIterator(this.targetBranch, 'OPEN'); for await (const openPullRequest of generator) { - if (hasAllLabels(this.labels, openPullRequest.labels) && + if ((hasAllLabels(this.labels, openPullRequest.labels) || + hasAllLabels(this.snapshotLabels, openPullRequest.labels)) && branch_name_1.BranchName.parse(openPullRequest.headBranchName) && pull_request_body_1.PullRequestBody.parse(openPullRequest.body)) { openPullRequests.push(openPullRequest); } } logger_1.logger.info(`found ${openPullRequests.length} open release pull requests.`); - const promises = []; - for (const pullRequest of candidatePullRequests) { - promises.push(this.createOrUpdatePullRequest(pullRequest, openPullRequests)); - } - return await Promise.all(promises); + return openPullRequests; } - async createOrUpdatePullRequest(pullRequest, openPullRequests) { - // look for existing, open pull rquest + async findSnoozedReleasePullRequests() { + logger_1.logger.info('Looking for snoozed release pull requests'); + const snoozedPullRequests = []; + const closedGenerator = this.github.pullRequestIterator(this.targetBranch, 'CLOSED'); + for await (const closedPullRequest of closedGenerator) { + if (hasAllLabels([exports.SNOOZE_LABEL], closedPullRequest.labels) && + branch_name_1.BranchName.parse(closedPullRequest.headBranchName) && + pull_request_body_1.PullRequestBody.parse(closedPullRequest.body)) { + snoozedPullRequests.push(closedPullRequest); + } + } + logger_1.logger.info(`found ${snoozedPullRequests.length} snoozed release pull requests.`); + return snoozedPullRequests; + } + async createOrUpdatePullRequest(pullRequest, openPullRequests, snoozedPullRequests) { + // look for existing, open pull request const existing = openPullRequests.find(openPullRequest => openPullRequest.headBranchName === pullRequest.headRefName); if (existing) { - // If unchanged, no need to push updates - if (existing.body === pullRequest.body.toString()) { - logger_1.logger.info(`PR https://github.com/${this.repository.owner}/${this.repository.repo}/pull/${existing.number} remained the same`); - return undefined; - } - const updatedPullRequest = await this.github.updatePullRequest(existing.number, pullRequest, this.targetBranch, { - fork: this.fork, - signoffUser: this.signoffUser, - }); - return updatedPullRequest; + return await this.maybeUpdateExistingPullRequest(existing, pullRequest); } - else { - const newPullRequest = await this.github.createReleasePullRequest(pullRequest, this.targetBranch, { - fork: this.fork, - signoffUser: this.signoffUser, - }); - return newPullRequest; + // look for closed, snoozed pull request + const snoozed = snoozedPullRequests.find(openPullRequest => openPullRequest.headBranchName === pullRequest.headRefName); + if (snoozed) { + return await this.maybeUpdateSnoozedPullRequest(snoozed, pullRequest); } + const newPullRequest = await this.github.createReleasePullRequest(pullRequest, this.targetBranch, { + fork: this.fork, + signoffUser: this.signoffUser, + }); + return newPullRequest; + } + /// only update an existing pull request if it has release note changes + async maybeUpdateExistingPullRequest(existing, pullRequest) { + // If unchanged, no need to push updates + if (existing.body === pullRequest.body.toString()) { + logger_1.logger.info(`PR https://github.com/${this.repository.owner}/${this.repository.repo}/pull/${existing.number} remained the same`); + return undefined; + } + const updatedPullRequest = await this.github.updatePullRequest(existing.number, pullRequest, this.targetBranch, { + fork: this.fork, + signoffUser: this.signoffUser, + }); + return updatedPullRequest; + } + /// only update an snoozed pull request if it has release note changes + async maybeUpdateSnoozedPullRequest(snoozed, pullRequest) { + // If unchanged, no need to push updates + if (snoozed.body === pullRequest.body.toString()) { + logger_1.logger.info(`PR https://github.com/${this.repository.owner}/${this.repository.repo}/pull/${snoozed.number} remained the same`); + return undefined; + } + const updatedPullRequest = await this.github.updatePullRequest(snoozed.number, pullRequest, this.targetBranch, { + fork: this.fork, + signoffUser: this.signoffUser, + }); + // TODO: consider leaving the snooze label + await this.github.removeIssueLabels([exports.SNOOZE_LABEL], snoozed.number); + return updatedPullRequest; } async *findMergedReleasePullRequests() { // Find merged release pull requests @@ -78418,6 +78493,7 @@ function extractReleaserConfig(config) { versionFile: config['version-file'], extraFiles: config['extra-files'], includeComponentInTag: config['include-component-in-tag'], + includeVInTag: config['include-v-in-tag'], changelogType: config['changelog-type'], pullRequestTitlePattern: config['pull-request-title-pattern'], tagSeparator: config['tag-separator'], @@ -78430,16 +78506,24 @@ function extractReleaserConfig(config) { * @param {GitHub} github GitHub client * @param {string} configFile Path in the repository to the manifest config * @param {string} branch Branch to fetch the config file from + * @param {string} onlyPath Optional. Use only the given package + * @param {string} releaseAs Optional. Override release-as and use the given version */ -async function parseConfig(github, configFile, branch) { +async function parseConfig(github, configFile, branch, onlyPath, releaseAs) { const config = await github.getFileJson(configFile, branch); const defaultConfig = extractReleaserConfig(config); const repositoryConfig = {}; for (const path in config.packages) { + if (onlyPath && onlyPath !== path) + continue; repositoryConfig[path] = mergeReleaserConfig(defaultConfig, extractReleaserConfig(config.packages[path])); + if (releaseAs) { + repositoryConfig[path].releaseAs = releaseAs; + } } const configLabel = config['label']; const configReleaseLabel = config['release-label']; + const configSnapshotLabel = config['snapshot-label']; const manifestOptions = { bootstrapSha: config['bootstrap-sha'], lastReleaseSha: config['last-release-sha'], @@ -78449,6 +78533,7 @@ async function parseConfig(github, configFile, branch) { plugins: config['plugins'], labels: configLabel === undefined ? undefined : [configLabel], releaseLabels: configReleaseLabel === undefined ? undefined : [configReleaseLabel], + snapshotLabels: configSnapshotLabel === undefined ? undefined : [configSnapshotLabel], }; return { config: repositoryConfig, options: manifestOptions }; } @@ -78467,16 +78552,22 @@ async function parseReleasedVersions(github, manifestFile, branch) { } return releasedVersions; } +function isPublishedVersion(strategy, version) { + return strategy.isPublishedVersion + ? strategy.isPublishedVersion(version) + : true; +} /** * Find the most recent matching release tag on the branch we're * configured for. * - * @param {string} prefix - Limit the release to a specific component. - * @param {boolean} preRelease - Whether or not to return pre-release - * versions. Defaults to false. + * @param github GitHub client instance. + * @param {string} targetBranch Name of the scanned branch. + * @param releaseFilter Validator function for release version. Used to filter-out SNAPSHOT releases for Java strategy. + * @param {string} prefix Limit the release to a specific component. + * @param pullRequestTitlePattern Configured PR title pattern. */ -async function latestReleaseVersion(github, targetBranch, prefix, pullRequestTitlePattern) { - var _a; +async function latestReleaseVersion(github, targetBranch, releaseFilter, prefix, pullRequestTitlePattern) { const branchPrefix = prefix ? prefix.endsWith('-') ? prefix.replace(/-$/, '') @@ -78511,11 +78602,7 @@ async function latestReleaseVersion(github, targetBranch, prefix, pullRequestTit continue; } const version = pullRequestTitle.getVersion(); - if ((_a = version === null || version === void 0 ? void 0 : version.preRelease) === null || _a === void 0 ? void 0 : _a.includes('SNAPSHOT')) { - // FIXME, don't hardcode this - continue; - } - if (version) { + if (version && releaseFilter(version)) { logger_1.logger.debug(`Found latest release pull request: ${mergedPullRequest.number} version: ${version}`); candidateReleaseVersions.push(version); break; @@ -78565,7 +78652,7 @@ async function latestReleaseVersion(github, targetBranch, prefix, pullRequestTit return candidateTagVersion.sort((a, b) => b.compare(a))[0]; } function mergeReleaserConfig(defaultConfig, pathConfig) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t; return { releaseType: (_b = (_a = pathConfig.releaseType) !== null && _a !== void 0 ? _a : defaultConfig.releaseType) !== null && _b !== void 0 ? _b : 'node', bumpMinorPreMajor: (_c = pathConfig.bumpMinorPreMajor) !== null && _c !== void 0 ? _c : defaultConfig.bumpMinorPreMajor, @@ -78581,8 +78668,9 @@ function mergeReleaserConfig(defaultConfig, pathConfig) { versionFile: (_o = pathConfig.versionFile) !== null && _o !== void 0 ? _o : defaultConfig.versionFile, extraFiles: (_p = pathConfig.extraFiles) !== null && _p !== void 0 ? _p : defaultConfig.extraFiles, includeComponentInTag: (_q = pathConfig.includeComponentInTag) !== null && _q !== void 0 ? _q : defaultConfig.includeComponentInTag, - tagSeparator: (_r = pathConfig.tagSeparator) !== null && _r !== void 0 ? _r : defaultConfig.tagSeparator, - pullRequestTitlePattern: (_s = pathConfig.pullRequestTitlePattern) !== null && _s !== void 0 ? _s : defaultConfig.pullRequestTitlePattern, + includeVInTag: (_r = pathConfig.includeVInTag) !== null && _r !== void 0 ? _r : defaultConfig.includeVInTag, + tagSeparator: (_s = pathConfig.tagSeparator) !== null && _s !== void 0 ? _s : defaultConfig.tagSeparator, + pullRequestTitlePattern: (_t = pathConfig.pullRequestTitlePattern) !== null && _t !== void 0 ? _t : defaultConfig.pullRequestTitlePattern, }; } /** @@ -79747,6 +79835,7 @@ const composite_1 = __nccwpck_require__(40911); const generic_1 = __nccwpck_require__(96323); const generic_json_1 = __nccwpck_require__(15011); const generic_xml_1 = __nccwpck_require__(15591); +const pom_xml_1 = __nccwpck_require__(60255); const DEFAULT_CHANGELOG_PATH = 'CHANGELOG.md'; /** * A strategy is responsible for determining which files are @@ -79754,7 +79843,7 @@ const DEFAULT_CHANGELOG_PATH = 'CHANGELOG.md'; */ class BaseStrategy { constructor(options) { - var _a; + var _a, _b; this.path = options.path || manifest_1.ROOT_PROJECT_PATH; this.github = options.github; this.packageName = options.packageName; @@ -79772,6 +79861,7 @@ class BaseStrategy { this.changelogNotes = options.changelogNotes || new default_2.DefaultChangelogNotes(options); this.includeComponentInTag = (_a = options.includeComponentInTag) !== null && _a !== void 0 ? _a : true; + this.includeVInTag = (_b = options.includeVInTag) !== null && _b !== void 0 ? _b : true; this.pullRequestTitlePattern = options.pullRequestTitlePattern; this.extraFiles = options.extraFiles || []; } @@ -79811,7 +79901,7 @@ class BaseStrategy { async postProcessCommits(commits) { return commits; } - async buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease) { + async buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits) { var _a; return await this.changelogNotes.buildNotes(conventionalCommits, { owner: this.repository.owner, @@ -79821,6 +79911,7 @@ class BaseStrategy { currentTag: newVersionTag.toString(), targetBranch: this.targetBranch, changelogSections: this.changelogSections, + commits: commits, }); } async buildPullRequestBody(component, newVersion, releaseNotesBody, _conventionalCommits, _latestRelease) { @@ -79851,16 +79942,16 @@ class BaseStrategy { return undefined; } const newVersion = await this.buildNewVersion(conventionalCommits, latestRelease); - const versionsMap = await this.updateVersionsMap(await this.buildVersionsMap(conventionalCommits), conventionalCommits); + const versionsMap = await this.updateVersionsMap(await this.buildVersionsMap(conventionalCommits), conventionalCommits, newVersion); const component = await this.getComponent(); logger_1.logger.debug('component:', component); - const newVersionTag = new tag_name_1.TagName(newVersion, this.includeComponentInTag ? component : undefined, this.tagSeparator); + const newVersionTag = new tag_name_1.TagName(newVersion, this.includeComponentInTag ? component : undefined, this.tagSeparator, this.includeVInTag); logger_1.logger.debug('pull request title pattern:', this.pullRequestTitlePattern); const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion, this.pullRequestTitlePattern); const branchName = component ? branch_name_1.BranchName.ofComponentTargetBranch(component, this.targetBranch) : branch_name_1.BranchName.ofTargetBranch(this.targetBranch); - const releaseNotesBody = await this.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease); + const releaseNotesBody = await this.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits); if (this.changelogEmpty(releaseNotesBody)) { logger_1.logger.info(`No user facing commits found since ${latestRelease ? latestRelease.sha : 'beginning of time'} - skipping`); return undefined; @@ -79871,7 +79962,7 @@ class BaseStrategy { versionsMap, latestVersion: latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag.version, }); - const updatesWithExtras = composite_1.mergeUpdates(updates.concat(...this.extraFileUpdates(newVersion))); + const updatesWithExtras = composite_1.mergeUpdates(updates.concat(...this.extraFileUpdates(newVersion, versionsMap))); const pullRequestBody = await this.buildPullRequestBody(component, newVersion, releaseNotesBody, conventionalCommits, latestRelease); return { title: pullRequestTitle, @@ -79883,7 +79974,7 @@ class BaseStrategy { draft: draft !== null && draft !== void 0 ? draft : false, }; } - extraFileUpdates(version) { + extraFileUpdates(version, versionsMap) { return this.extraFiles.map(extraFile => { if (typeof extraFile === 'object') { switch (extraFile.type) { @@ -79899,6 +79990,12 @@ class BaseStrategy { createIfMissing: false, updater: new generic_xml_1.GenericXml(extraFile.xpath, version), }; + case 'pom': + return { + path: this.addPath(extraFile.path), + createIfMissing: false, + updater: new pom_xml_1.PomXml(version), + }; default: throw new Error(`unsupported extraFile type: ${extraFile.type}`); } @@ -79906,14 +80003,14 @@ class BaseStrategy { return { path: this.addPath(extraFile), createIfMissing: false, - updater: new generic_1.Generic({ version }), + updater: new generic_1.Generic({ version, versionsMap }), }; }); } changelogEmpty(changelogEntry) { return changelogEntry.split('\n').length <= 1; } - async updateVersionsMap(versionsMap, conventionalCommits) { + async updateVersionsMap(versionsMap, conventionalCommits, _newVersion) { for (const versionKey of versionsMap.keys()) { const version = versionsMap.get(versionKey); if (!version) { @@ -80006,7 +80103,7 @@ class BaseStrategy { logger_1.logger.error('Pull request should have included version'); return; } - const tag = new tag_name_1.TagName(version, this.includeComponentInTag ? component : undefined, this.tagSeparator); + const tag = new tag_name_1.TagName(version, this.includeComponentInTag ? component : undefined, this.tagSeparator, this.includeVInTag); const releaseName = component && this.includeComponentInTag ? `${component}: v${version.toString()}` : `v${version.toString()}`; @@ -80122,6 +80219,109 @@ exports.Dart = Dart; /***/ }), +/***/ 98175: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.DotnetYoshi = void 0; +const base_1 = __nccwpck_require__(95081); +const changelog_1 = __nccwpck_require__(3325); +const apis_1 = __nccwpck_require__(4856); +const logger_1 = __nccwpck_require__(68809); +const errors_1 = __nccwpck_require__(93637); +const CHANGELOG_SECTIONS = [ + { type: 'feat', section: 'New features' }, + { type: 'fix', section: 'Bug fixes' }, + { type: 'perf', section: 'Performance improvements' }, + { type: 'revert', section: 'Reverts' }, + { type: 'chore', section: 'Miscellaneous chores', hidden: true }, + { type: 'docs', section: 'Documentation improvements' }, + { type: 'style', section: 'Styles', hidden: true }, + { type: 'refactor', section: 'Code Refactoring', hidden: true }, + { type: 'test', section: 'Tests', hidden: true }, + { type: 'build', section: 'Build System', hidden: true }, + { type: 'ci', section: 'Continuous Integration', hidden: true }, +]; +const DEFAULT_CHANGELOG_PATH = 'docs/history.md'; +const DEFAULT_PULL_REQUEST_TITLE_PATTERN = 'Release${component} version ${version}'; +const RELEASE_NOTES_HEADER_PATTERN = /#{2,3} \[?(\d+\.\d+\.\d+-?[^\]]*)\]?.* \((\d{4}-\d{2}-\d{2})\)/; +class DotnetYoshi extends base_1.BaseStrategy { + constructor(options) { + var _a, _b, _c, _d; + options.changelogSections = (_a = options.changelogSections) !== null && _a !== void 0 ? _a : CHANGELOG_SECTIONS; + options.changelogPath = (_b = options.changelogPath) !== null && _b !== void 0 ? _b : DEFAULT_CHANGELOG_PATH; + options.pullRequestTitlePattern = (_c = options.pullRequestTitlePattern) !== null && _c !== void 0 ? _c : DEFAULT_PULL_REQUEST_TITLE_PATTERN; + options.includeVInTag = (_d = options.includeVInTag) !== null && _d !== void 0 ? _d : false; + super(options); + } + async buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease) { + const notes = await super.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease); + return notes.replace(RELEASE_NOTES_HEADER_PATTERN, '## Version $1, released $2'); + } + async getApi() { + try { + const contents = await this.github.getFileContentsOnBranch('apis/apis.json', this.targetBranch); + const apis = JSON.parse(contents.parsedContent); + const component = await this.getComponent(); + return apis.apis.find(api => api.id === component); + } + catch (e) { + if (e instanceof errors_1.FileNotFoundError) { + throw new errors_1.MissingRequiredFileError('apis/apis.json', DotnetYoshi.name, `${this.repository.owner}/${this.repository.repo}`); + } + throw e; + } + } + async buildUpdates(options) { + const updates = []; + const version = options.newVersion; + const component = await this.getComponent(); + const api = await this.getApi(); + if (api === null || api === void 0 ? void 0 : api.noVersionHistory) { + logger_1.logger.info(`Skipping changelog for ${component} via noVersionHistory configuration`); + } + else { + updates.push({ + path: this.addPath(this.changelogPath), + createIfMissing: true, + updater: new changelog_1.Changelog({ + version, + changelogEntry: options.changelogEntry, + }), + }); + } + if (!this.component) { + logger_1.logger.warn('Dotnet strategy expects to use components, could not update all files'); + return updates; + } + updates.push({ + path: 'apis/apis.json', + createIfMissing: false, + updater: new apis_1.Apis(this.component, version), + }); + return updates; + } +} +exports.DotnetYoshi = DotnetYoshi; +//# sourceMappingURL=dotnet-yoshi.js.map + +/***/ }), + /***/ 91731: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -80317,8 +80517,8 @@ class GoYoshi extends base_1.BaseStrategy { } // "closes" is a little presumptuous, let's just indicate that the // PR references these other commits: - async buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease) { - const releaseNotes = await super.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease); + async buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits) { + const releaseNotes = await super.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits); return releaseNotes.replace(/, closes /g, ', refs '); } initialReleaseVersion() { @@ -80468,92 +80668,12 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.JavaYoshi = void 0; const versions_manifest_1 = __nccwpck_require__(78345); const version_1 = __nccwpck_require__(17348); -const java_update_1 = __nccwpck_require__(90276); -const base_1 = __nccwpck_require__(95081); const changelog_1 = __nccwpck_require__(3325); -const java_snapshot_1 = __nccwpck_require__(66860); const errors_1 = __nccwpck_require__(93637); const logger_1 = __nccwpck_require__(68809); -const pull_request_title_1 = __nccwpck_require__(1158); -const branch_name_1 = __nccwpck_require__(16344); -const pull_request_body_1 = __nccwpck_require__(70774); -const default_1 = __nccwpck_require__(94073); -const java_add_snapshot_1 = __nccwpck_require__(87719); -const CHANGELOG_SECTIONS = [ - { type: 'feat', section: 'Features' }, - { type: 'fix', section: 'Bug Fixes' }, - { type: 'perf', section: 'Performance Improvements' }, - { type: 'deps', section: 'Dependencies' }, - { type: 'revert', section: 'Reverts' }, - { type: 'docs', section: 'Documentation' }, - { type: 'style', section: 'Styles', hidden: true }, - { type: 'chore', section: 'Miscellaneous Chores', hidden: true }, - { type: 'refactor', section: 'Code Refactoring', hidden: true }, - { type: 'test', section: 'Tests', hidden: true }, - { type: 'build', section: 'Build System', hidden: true }, - { type: 'ci', section: 'Continuous Integration', hidden: true }, -]; -class JavaYoshi extends base_1.BaseStrategy { - constructor(options) { - var _a; - options.changelogSections = (_a = options.changelogSections) !== null && _a !== void 0 ? _a : CHANGELOG_SECTIONS; - // wrap the configured versioning strategy with snapshotting - const parentVersioningStrategy = options.versioningStrategy || new default_1.DefaultVersioningStrategy(); - options.versioningStrategy = new java_snapshot_1.JavaSnapshot(parentVersioningStrategy); - super(options); - this.snapshotVersioning = new java_add_snapshot_1.JavaAddSnapshot(parentVersioningStrategy); - } - async buildReleasePullRequest(commits, latestRelease, draft, labels = []) { - if (await this.needsSnapshot()) { - logger_1.logger.info('Repository needs a snapshot bump.'); - return await this.buildSnapshotPullRequest(latestRelease); - } - logger_1.logger.info('No Java snapshot needed'); - return await super.buildReleasePullRequest(commits, latestRelease, draft, labels); - } - async buildSnapshotPullRequest(latestRelease) { - const component = await this.getComponent(); - const newVersion = latestRelease - ? await this.snapshotVersioning.bump(latestRelease.tag.version, []) - : this.initialReleaseVersion(); - const versionsMap = await this.buildVersionsMap(); - for (const versionKey of versionsMap.keys()) { - const version = versionsMap.get(versionKey); - if (!version) { - logger_1.logger.warn(`didn't find version for ${versionKey}`); - continue; - } - const newVersion = await this.snapshotVersioning.bump(version, []); - versionsMap.set(versionKey, newVersion); - } - const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion); - const branchName = component - ? branch_name_1.BranchName.ofComponentTargetBranch(component, this.targetBranch) - : branch_name_1.BranchName.ofTargetBranch(this.targetBranch); - const notes = '### Updating meta-information for bleeding-edge SNAPSHOT release.'; - const pullRequestBody = new pull_request_body_1.PullRequestBody([ - { - component, - version: newVersion, - notes, - }, - ]); - const updates = await this.buildUpdates({ - newVersion, - versionsMap, - changelogEntry: notes, - isSnapshot: true, - }); - return { - title: pullRequestTitle, - body: pullRequestBody, - updates, - labels: [], - headRefName: branchName.toString(), - version: newVersion, - draft: false, - }; - } +const java_1 = __nccwpck_require__(46892); +const java_update_1 = __nccwpck_require__(90276); +class JavaYoshi extends java_1.Java { /** * Override this method to post process commits * @param {ConventionalCommit[]} commits parsed commits @@ -80741,6 +80861,173 @@ function isPromotionNote(note) { /***/ }), +/***/ 46892: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.Java = void 0; +const base_1 = __nccwpck_require__(95081); +const changelog_1 = __nccwpck_require__(3325); +const java_snapshot_1 = __nccwpck_require__(66860); +const logger_1 = __nccwpck_require__(68809); +const pull_request_title_1 = __nccwpck_require__(1158); +const branch_name_1 = __nccwpck_require__(16344); +const pull_request_body_1 = __nccwpck_require__(70774); +const default_1 = __nccwpck_require__(94073); +const java_add_snapshot_1 = __nccwpck_require__(87719); +const manifest_1 = __nccwpck_require__(31999); +const java_released_1 = __nccwpck_require__(16255); +const composite_1 = __nccwpck_require__(40911); +const CHANGELOG_SECTIONS = [ + { type: 'feat', section: 'Features' }, + { type: 'fix', section: 'Bug Fixes' }, + { type: 'perf', section: 'Performance Improvements' }, + { type: 'deps', section: 'Dependencies' }, + { type: 'revert', section: 'Reverts' }, + { type: 'docs', section: 'Documentation' }, + { type: 'style', section: 'Styles', hidden: true }, + { type: 'chore', section: 'Miscellaneous Chores', hidden: true }, + { type: 'refactor', section: 'Code Refactoring', hidden: true }, + { type: 'test', section: 'Tests', hidden: true }, + { type: 'build', section: 'Build System', hidden: true }, + { type: 'ci', section: 'Continuous Integration', hidden: true }, +]; +/** + * A strategy that generates SNAPSHOT version after each release, which is standard especially in Maven projects. + * + * This is universal strategy that does not update any files on its own. Use maven strategy for Maven projects. + */ +class Java extends base_1.BaseStrategy { + constructor(options) { + var _a; + options.changelogSections = (_a = options.changelogSections) !== null && _a !== void 0 ? _a : CHANGELOG_SECTIONS; + // wrap the configured versioning strategy with snapshotting + const parentVersioningStrategy = options.versioningStrategy || new default_1.DefaultVersioningStrategy(); + options.versioningStrategy = new java_snapshot_1.JavaSnapshot(parentVersioningStrategy); + super(options); + this.snapshotVersioning = new java_add_snapshot_1.JavaAddSnapshot(parentVersioningStrategy); + this.snapshotLabels = options.snapshotLabels || manifest_1.DEFAULT_SNAPSHOT_LABELS; + } + async buildReleasePullRequest(commits, latestRelease, draft, labels = []) { + if (await this.needsSnapshot(commits, latestRelease)) { + logger_1.logger.info('Repository needs a snapshot bump.'); + return await this.buildSnapshotPullRequest(latestRelease, draft, this.snapshotLabels); + } + logger_1.logger.info('No Java snapshot needed'); + return await super.buildReleasePullRequest(commits, latestRelease, draft, labels); + } + async buildSnapshotPullRequest(latestRelease, draft, labels = []) { + const component = await this.getComponent(); + const newVersion = latestRelease + ? await this.snapshotVersioning.bump(latestRelease.tag.version, []) + : this.initialReleaseVersion(); + const versionsMap = await this.buildVersionsMap([]); + const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion); + const branchName = component + ? branch_name_1.BranchName.ofComponentTargetBranch(component, this.targetBranch) + : branch_name_1.BranchName.ofTargetBranch(this.targetBranch); + const notes = '### Updating meta-information for bleeding-edge SNAPSHOT release.'; + const pullRequestBody = new pull_request_body_1.PullRequestBody([ + { + component, + version: newVersion, + notes, + }, + ]); + const updates = await this.buildUpdates({ + newVersion, + versionsMap, + changelogEntry: notes, + isSnapshot: true, + }); + const updatesWithExtras = composite_1.mergeUpdates(updates.concat(...this.extraFileUpdates(newVersion, versionsMap))); + return { + title: pullRequestTitle, + body: pullRequestBody, + updates: updatesWithExtras, + labels: labels, + headRefName: branchName.toString(), + version: newVersion, + draft: draft !== null && draft !== void 0 ? draft : false, + }; + } + isPublishedVersion(version) { + return !version.preRelease || version.preRelease.indexOf('SNAPSHOT') < 0; + } + async needsSnapshot(commits, latestRelease) { + var _a; + const component = await this.getComponent(); + logger_1.logger.debug('component:', component); + const version = (_a = latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag) === null || _a === void 0 ? void 0 : _a.version; + if (!version) { + // Don't bump snapshots for the first release ever + return false; + } + // Found snapshot as a release, this is unexpected, but use it + if (!this.isPublishedVersion(version)) { + return false; + } + // Search commits for snapshot bump + const pullRequests = commits + .map(commit => { + var _a; + return pull_request_title_1.PullRequestTitle.parse(((_a = commit.pullRequest) === null || _a === void 0 ? void 0 : _a.title) || commit.message, this.pullRequestTitlePattern); + }) + .filter(pullRequest => pullRequest); + const snapshotCommits = pullRequests + .filter(pullRequest => ((pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.component) || '') === component) + .map(pullRequest => pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.getVersion()) + .filter(version => version && !this.isPublishedVersion(version)); + return snapshotCommits.length === 0; + } + async buildUpdates(options) { + const version = options.newVersion; + const versionsMap = options.versionsMap; + const updates = []; + if (!options.isSnapshot) { + // Append java-specific updater for extraFiles + this.extraFiles.forEach(extraFile => { + if (typeof extraFile === 'string') { + updates.push({ + path: this.addPath(extraFile), + createIfMissing: false, + updater: new java_released_1.JavaReleased({ version, versionsMap }), + }); + } + }); + // Update changelog + updates.push({ + path: this.addPath(this.changelogPath), + createIfMissing: true, + updater: new changelog_1.Changelog({ + version, + changelogEntry: options.changelogEntry, + }), + }); + } + return updates; + } +} +exports.Java = Java; +//# sourceMappingURL=java.js.map + +/***/ }), + /***/ 76397: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -80812,6 +81099,69 @@ exports.KRMBlueprint = KRMBlueprint; /***/ }), +/***/ 60899: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.Maven = void 0; +const java_1 = __nccwpck_require__(46892); +const java_released_1 = __nccwpck_require__(16255); +const generic_1 = __nccwpck_require__(96323); +const pom_xml_1 = __nccwpck_require__(60255); +/** + * Strategy for Maven projects. It generates SNAPSHOT version after each release, and updates all found + * pom.xml files automatically. + */ +class Maven extends java_1.Java { + async buildUpdates(options) { + const version = options.newVersion; + const versionsMap = options.versionsMap; + // Use generic Java updates + const updates = await super.buildUpdates(options); + // Update pom.xml files + const pomFiles = await this.github.findFilesByFilenameAndRef('pom.xml', this.targetBranch, this.path); + pomFiles.forEach(path => { + updates.push({ + path: this.addPath(path), + createIfMissing: false, + updater: new pom_xml_1.PomXml(version), + }); + if (!options.isSnapshot) { + updates.push({ + path: this.addPath(path), + createIfMissing: false, + updater: new java_released_1.JavaReleased({ version, versionsMap }), + }); + } + updates.push({ + path: this.addPath(path), + createIfMissing: false, + updater: new generic_1.Generic({ version, versionsMap }), + }); + }); + return updates; + } +} +exports.Maven = Maven; +//# sourceMappingURL=maven.js.map + +/***/ }), + /***/ 78957: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -81028,6 +81378,7 @@ const tag_name_1 = __nccwpck_require__(36503); const pull_request_title_1 = __nccwpck_require__(1158); const branch_name_1 = __nccwpck_require__(16344); const pull_request_body_1 = __nccwpck_require__(70774); +const errors_1 = __nccwpck_require__(93637); const CHANGELOG_SECTIONS = [ { type: 'feat', section: 'Features' }, { type: 'fix', section: 'Bug Fixes' }, @@ -81089,7 +81440,7 @@ class PHPYoshi extends base_1.BaseStrategy { releaseNotesBody = updatePHPChangelogEntry(`${composer.name} ${newVersion.toString()}`, releaseNotesBody, partialReleaseNotes); } catch (err) { - if (err.status === 404) { + if (err instanceof errors_1.FileNotFoundError) { // if the updated path has no VERSION, assume this isn't a // module that needs updating. continue; @@ -81482,9 +81833,6 @@ const version_rb_1 = __nccwpck_require__(46979); const base_1 = __nccwpck_require__(95081); const fs_1 = __nccwpck_require__(35747); const path_1 = __nccwpck_require__(85622); -const manifest_1 = __nccwpck_require__(31999); -const logger_1 = __nccwpck_require__(68809); -const pull_request_body_1 = __nccwpck_require__(70774); const CHANGELOG_SECTIONS = [ { type: 'feat', section: 'Features' }, { type: 'fix', section: 'Bug Fixes' }, @@ -81504,9 +81852,9 @@ class RubyYoshi extends base_1.BaseStrategy { super({ ...options, changelogSections: CHANGELOG_SECTIONS, - commitPartial: fs_1.readFileSync(__nccwpck_require__.ab + "commit.hbs", 'utf8'), - headerPartial: fs_1.readFileSync(__nccwpck_require__.ab + "header.hbs", 'utf8'), - mainTemplate: fs_1.readFileSync(__nccwpck_require__.ab + "template.hbs", 'utf8'), + commitPartial: fs_1.readFileSync(__nccwpck_require__.ab + "commit2.hbs", 'utf8'), + headerPartial: fs_1.readFileSync(__nccwpck_require__.ab + "header2.hbs", 'utf8'), + mainTemplate: fs_1.readFileSync(__nccwpck_require__.ab + "template2.hbs", 'utf8'), tagSeparator: '/', }); this.versionFile = (_a = options.versionFile) !== null && _a !== void 0 ? _a : ''; @@ -81540,49 +81888,17 @@ class RubyYoshi extends base_1.BaseStrategy { }); return commits; } - async buildPullRequestBody(component, newVersion, releaseNotesBody, conventionalCommits, latestRelease) { - if (!latestRelease) { - return await super.buildPullRequestBody(component, newVersion, releaseNotesBody, conventionalCommits, latestRelease); - } - // summarize the commits that landed: - let summary = '### Commits since last release:\n\n'; - const updatedFiles = {}; - const repoUrl = `${this.repository.owner}/${this.repository.repo}`; - for (const commit of conventionalCommits) { - if (!commit.sha) - continue; - const splitMessage = commit.message.split('\n'); - summary += `* [${splitMessage[0]}](https://github.com/${repoUrl}/commit/${commit.sha})\n`; - if (splitMessage.length > 2) { - summary = `${summary}
${splitMessage
-                    .slice(1)
-                    .join('\n')}
\n`; - } - if (commit.files === undefined) { - logger_1.logger.error('No files for commit - this is likely a bug.'); - continue; - } - commit.files.forEach(file => { - if (this.path === manifest_1.ROOT_PROJECT_PATH || file.startsWith(this.path)) { - updatedFiles[file] = true; - } - }); - } - // summarize the files that changed: - summary = `${summary}\n### Files edited since last release:\n\n
`;
-        Object.keys(updatedFiles).forEach(file => {
-            summary += `${file}\n`;
-        });
-        summary += `
\n[Compare Changes](https://github.com/${repoUrl}/compare/${latestRelease.sha}...HEAD)\n`; - return new pull_request_body_1.PullRequestBody([ - { - component, - version: newVersion, - notes: releaseNotesBody, - }, - ], { - extra: summary, - }); + async buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits) { + const releaseNotes = await super.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits); + return (releaseNotes + // Remove links in version title line and standardize on h3 + .replace(/^###? \[([\d.]+)\]\([^)]*\)/gm, '### $1') + // Remove PR and commit links from pull request title suffixes + .replace(/ \(\[#\d+\]\([^)]*\)\)( \(\[\w+\]\([^)]*\)\))?\s*$/gm, '') + // Standardize on h4 for change type subheaders + .replace(/^### (Features|Bug Fixes|Documentation)$/gm, '#### $1') + // Collapse 2 or more blank lines + .replace(/\n{3,}/g, '\n\n')); } } exports.RubyYoshi = RubyYoshi; @@ -81752,10 +82068,16 @@ class Rust extends base_1.BaseStrategy { }); } else { - const manifestPath = this.addPath('Cargo.toml'); - logger_1.logger.info(`single crate found, updating ${manifestPath}`); + logger_1.logger.info('single crate found, updating Cargo.toml'); + const packageName = await this.getDefaultPackageName(); + if (packageName) { + versionsMap.set(packageName, version); + } + else { + logger_1.logger.warn('No crate package name found'); + } updates.push({ - path: manifestPath, + path: this.addPath('Cargo.toml'), createIfMissing: false, updater: new cargo_toml_1.CargoToml({ version, @@ -81944,6 +82266,52 @@ exports.TerraformModule = TerraformModule; /***/ }), +/***/ 29481: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.BaseXml = void 0; +const dom = __nccwpck_require__(57286); +/** + * Base class for all updaters working with XML files. + */ +class BaseXml { + /** + * Given initial file contents, return updated contents. + * @param {string} content The initial content + * @returns {string} The updated content + */ + updateContent(content) { + const document = new dom.DOMParser().parseFromString(content); + const updated = this.updateDocument(document); + if (updated) { + return new dom.XMLSerializer().serializeToString(document); + } + else { + return content; + } + } +} +exports.BaseXml = BaseXml; +//# sourceMappingURL=base-xml.js.map + +/***/ }), + /***/ 3325: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -82161,6 +82529,58 @@ exports.DefaultUpdater = DefaultUpdater; /***/ }), +/***/ 4856: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.Apis = void 0; +const logger_1 = __nccwpck_require__(68809); +const json_stringify_1 = __nccwpck_require__(69227); +/** + * Updates the apis.json format. See + * https://github.com/googleapis/google-cloud-dotnet/blob/main/apis/README.md. + */ +class Apis { + constructor(component, version) { + this.component = component; + this.version = version; + } + /** + * Given initial file contents, return updated contents. + * @param {string} content The initial content + * @returns {string} The updated content + */ + updateContent(content) { + const data = JSON.parse(content); + const api = data.apis.find(api => api.id === this.component); + if (!api) { + logger_1.logger.warn(`Failed to find component: ${this.component} in apis.json`); + return content; + } + api.version = this.version.toString(); + return json_stringify_1.jsonStringify(data, content); + } +} +exports.Apis = Apis; +//# sourceMappingURL=apis.js.map + +/***/ }), + /***/ 31612: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -82275,33 +82695,24 @@ exports.GenericJson = GenericJson; // limitations under the License. Object.defineProperty(exports, "__esModule", ({ value: true })); exports.GenericXml = void 0; +const base_xml_1 = __nccwpck_require__(29481); const xpath = __nccwpck_require__(65319); -const dom = __nccwpck_require__(57286); -class GenericXml { +class GenericXml extends base_xml_1.BaseXml { constructor(xpath, version) { + super(); this.xpath = xpath; this.version = version; } - /** - * Given initial file contents, return updated contents. - * @param {string} content The initial content - * @returns {string} The updated content - */ - updateContent(content) { - const document = new dom.DOMParser().parseFromString(content); - const iterator = xpath.evaluate(this.xpath, document, null, 0, null); - let node; + updateDocument(document) { + const version = this.version.toString(); let updated = false; - while ((node = iterator.iterateNext())) { - node.textContent = this.version.toString(); - updated = true; - } - if (updated) { - return new dom.XMLSerializer().serializeToString(document); - } - else { - return content; + for (const node of xpath.select(this.xpath, document)) { + if (node.textContent !== version) { + node.textContent = version; + updated = true; + } } + return updated; } } exports.GenericXml = GenericXml; @@ -82344,13 +82755,13 @@ const BLOCK_END_REGEX = /x-release-please-end/; * then replace a semver-looking string on that line with the next * version * 2. `x-release-please-major` if this string is found on the line, - * then replace an integer looking value with the the next version's + * then replace an integer looking value with the next version's * major * 3. `x-release-please-minor` if this string is found on the line, - * then replace an integer looking value with the the next version's + * then replace an integer looking value with the next version's * minor * 4. `x-release-please-patch` if this string is found on the line, - * then replace an integer looking value with the the next version's + * then replace an integer looking value with the next version's * patch * * You can also use a block-based replacement. Content between the @@ -82360,6 +82771,13 @@ const BLOCK_END_REGEX = /x-release-please-end/; * numbers */ class Generic extends default_1.DefaultUpdater { + constructor(options) { + var _a, _b, _c; + super(options); + this.inlineUpdateRegex = (_a = options.inlineUpdateRegex) !== null && _a !== void 0 ? _a : INLINE_UPDATE_REGEX; + this.blockStartRegex = (_b = options.blockStartRegex) !== null && _b !== void 0 ? _b : BLOCK_START_REGEX; + this.blockEndRegex = (_c = options.blockEndRegex) !== null && _c !== void 0 ? _c : BLOCK_END_REGEX; + } /** * Given initial file contents, return updated contents. * @param {string} content The initial content @@ -82392,7 +82810,7 @@ class Generic extends default_1.DefaultUpdater { } content.split(/\r?\n/).forEach(line => { var _a, _b; - let match = line.match(INLINE_UPDATE_REGEX); + let match = line.match(this.inlineUpdateRegex); if (match) { // replace inline versions replaceVersion(line, (((_a = match.groups) === null || _a === void 0 ? void 0 : _a.scope) || 'version'), this.version); @@ -82400,13 +82818,13 @@ class Generic extends default_1.DefaultUpdater { else if (blockScope) { // in a block, so try to replace versions replaceVersion(line, blockScope, this.version); - if (line.match(BLOCK_END_REGEX)) { + if (line.match(this.blockEndRegex)) { blockScope = undefined; } } else { // look for block start line - match = line.match(BLOCK_START_REGEX); + match = line.match(this.blockStartRegex); if (match) { if ((_b = match.groups) === null || _b === void 0 ? void 0 : _b.scope) { blockScope = match.groups.scope; @@ -82505,6 +82923,72 @@ exports.ChartYaml = ChartYaml; /***/ }), +/***/ 16255: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.JavaReleased = void 0; +const generic_1 = __nccwpck_require__(96323); +const INLINE_UPDATE_REGEX = /x-release-please-released-(?major|minor|patch|version)/; +const BLOCK_START_REGEX = /x-release-please-released-start-(?major|minor|patch|version)/; +const BLOCK_END_REGEX = /x-release-please-released-end/; +const REGEX_OPTIONS = { + inlineUpdateRegex: INLINE_UPDATE_REGEX, + blockStartRegex: BLOCK_START_REGEX, + blockEndRegex: BLOCK_END_REGEX, +}; +/** + * The JavaReleased updater is used only when updating to stable (not SNAPSHOT) + * versions. It looks for well known patterns and replaces content. + * The well known patterns are: + * + * 1. `x-release-please-released-version` if this string is found on the line, + * then replace a semver-looking string on that line with the next + * version + * 2. `x-release-please-released-major` if this string is found on the line, + * then replace an integer looking value with the next version's + * major + * 3. `x-release-please-released-minor` if this string is found on the line, + * then replace an integer looking value with the next version's + * minor + * 4. `x-release-please-released-patch` if this string is found on the line, + * then replace an integer looking value with the next version's + * patch + * + * You can also use a block-based replacement. Content between the + * opening `x-release-please-released-start-version` and `x-release-please-released-end` will + * be considered for version replacement. You can also open these blocks + * with `x-release-please-released-start-` to replace single + * numbers + */ +class JavaReleased extends generic_1.Generic { + constructor(options) { + super({ + ...REGEX_OPTIONS, + ...options, + }); + } +} +exports.JavaReleased = JavaReleased; +//# sourceMappingURL=java-released.js.map + +/***/ }), + /***/ 90276: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -82592,6 +83076,65 @@ exports.JavaUpdate = JavaUpdate; /***/ }), +/***/ 60255: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.PomXml = void 0; +const base_xml_1 = __nccwpck_require__(29481); +const xpath = __nccwpck_require__(65319); +const XPATH_PROJECT_VERSION = '/*[local-name()="project"]/*[local-name()="version"]'; +const XPATH_PROJECT_PARENT_VERSION = '/*[local-name()="project"]/*[local-name()="parent"]/*[local-name()="version"]'; +/** + * Updates version pom.xml files. + * + * If present it updates project.version element. + * If project.version is not present, it updates project.parent.version. + */ +class PomXml extends base_xml_1.BaseXml { + constructor(version) { + super(); + this.version = version; + } + updateDocument(document) { + const version = this.version.toString(); + // NOTE this intentionally ignores namespaces - let the maven decide, what's valid and what's not + // Update project.version + const projectVersionNodes = xpath.select(XPATH_PROJECT_VERSION, document); + if (projectVersionNodes.length) { + // If found update, detect actual change + return PomXml.updateNodes(projectVersionNodes, version); + } + // Try updating project.parent.version + const parentVersionNodes = xpath.select(XPATH_PROJECT_PARENT_VERSION, document); + return PomXml.updateNodes(parentVersionNodes, version); + } + static updateNodes(nodes, value) { + const toUpdate = nodes.filter(node => node.textContent !== value); + toUpdate.forEach(node => (node.textContent = value)); + return toUpdate.length > 0; + } +} +exports.PomXml = PomXml; +//# sourceMappingURL=pom-xml.js.map + +/***/ }), + /***/ 78345: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -84726,26 +85269,27 @@ exports.signoffCommitMessage = signoffCommitMessage; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.TagName = void 0; const version_1 = __nccwpck_require__(17348); -const TAG_PATTERN = /^((?.*)(?[^a-zA-Z]))?v(?\d+\.\d+\.\d+.*)$/; +const TAG_PATTERN = /^((?.*)(?[^a-zA-Z]))?(?v)?(?\d+\.\d+\.\d+.*)$/; const DEFAULT_SEPARATOR = '-'; class TagName { - constructor(version, component, separator = DEFAULT_SEPARATOR) { + constructor(version, component, separator = DEFAULT_SEPARATOR, includeV = true) { this.version = version; this.component = component; this.separator = separator; + this.includeV = includeV; } static parse(tagName) { const match = tagName.match(TAG_PATTERN); if (match === null || match === void 0 ? void 0 : match.groups) { - return new TagName(version_1.Version.parse(match.groups.version), match.groups.component, match.groups.separator); + return new TagName(version_1.Version.parse(match.groups.version), match.groups.component, match.groups.separator, !!match.groups.v); } return; } toString() { if (this.component) { - return `${this.component}${this.separator}v${this.version.toString()}`; + return `${this.component}${this.separator}${this.includeV ? 'v' : ''}${this.version.toString()}`; } - return `v${this.version.toString()}`; + return `${this.includeV ? 'v' : ''}${this.version.toString()}`; } } exports.TagName = TagName; @@ -112270,7 +112814,7 @@ module.exports = {}; /***/ ((module) => { "use strict"; -module.exports = {"i8":"13.6.0"}; +module.exports = {"i8":"13.10.0"}; /***/ }), diff --git a/dist/template.hbs b/dist/template.hbs index 0e567ae..2c1349a 100644 --- a/dist/template.hbs +++ b/dist/template.hbs @@ -1,19 +1,11 @@ {{> header}} -{{#if noteGroups}} -{{#each noteGroups}} -#### ⚠ {{title}} - -{{#each notes}} -* {{#if commit.scope}}**{{commit.scope}}:** {{/if}}{{text}} -{{/each}} -{{/each}} -{{/if}} {{#each commitGroups}} - -{{#if title}} -#### {{title}} - -{{/if}} {{#each commits}} -{{> commit root=@root}}{{/each}}{{/each}} \ No newline at end of file +{{> commit root=@root}} +{{/each}} +{{/each}} + +{{> footer}} + + diff --git a/dist/template1.hbs b/dist/template1.hbs index 2c1349a..3b194f0 100644 --- a/dist/template1.hbs +++ b/dist/template1.hbs @@ -1,11 +1,23 @@ {{> header}} +{{#if noteGroups}} +{{#each noteGroups}} + +### ⚠ {{title}} + +{{#each notes}} +* {{#if commit.scope}}**{{commit.scope}}:** {{/if}}{{text}} +{{/each}} +{{/each}} +{{/if}} {{#each commitGroups}} + +{{#if title}} +### {{title}} + +{{/if}} {{#each commits}} {{> commit root=@root}} {{/each}} + {{/each}} - -{{> footer}} - - diff --git a/dist/template2.hbs b/dist/template2.hbs index 3b194f0..0e567ae 100644 --- a/dist/template2.hbs +++ b/dist/template2.hbs @@ -1,9 +1,8 @@ {{> header}} - {{#if noteGroups}} {{#each noteGroups}} -### ⚠ {{title}} +#### ⚠ {{title}} {{#each notes}} * {{#if commit.scope}}**{{commit.scope}}:** {{/if}}{{text}} @@ -13,11 +12,8 @@ {{#each commitGroups}} {{#if title}} -### {{title}} +#### {{title}} {{/if}} {{#each commits}} -{{> commit root=@root}} -{{/each}} - -{{/each}} +{{> commit root=@root}}{{/each}}{{/each}} \ No newline at end of file