Skip to content

Commit

Permalink
Merge branch 'main' into go-version2
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Nov 29, 2021
2 parents a8e3074 + 26442f1 commit 88586f7
Show file tree
Hide file tree
Showing 15 changed files with 723 additions and 198 deletions.
70 changes: 41 additions & 29 deletions __snapshots__/cli.js
Expand Up @@ -4,42 +4,54 @@ release-please github-release
create a GitHub release from a release PR
Options:
--help Show help [boolean]
--version Show version number [boolean]
--debug print verbose errors (use only for local debugging).
[boolean] [default: false]
--trace print extra verbose errors (use only for local debugging).
[boolean] [default: false]
--token GitHub token with repo write permissions
--api-url URL to use when making API requests
--help Show help [boolean]
--version Show version number [boolean]
--debug print verbose errors (use only for local
debugging). [boolean] [default: false]
--trace print extra verbose errors (use only for local
debugging). [boolean] [default: false]
--token GitHub token with repo write permissions
--api-url URL to use when making API requests
[string] [default: "https://api.github.com"]
--graphql-url URL to use when making GraphQL requests
--graphql-url URL to use when making GraphQL requests
[string] [default: "https://api.github.com"]
--default-branch The branch to open release PRs against and tag releases on
--default-branch The branch to open release PRs against and tag
releases on
[deprecated: use --target-branch instead] [string]
--target-branch The branch to open release PRs against and tag releases on
--target-branch The branch to open release PRs against and tag
releases on [string]
--repo-url GitHub URL to generate release for [required]
--dry-run Prepare but do not take action
[boolean] [default: false]
--monorepo-tags include library name in tags and release
branches [boolean] [default: false]
--pull-request-title-pattern Title pattern to make release PR [string]
--path release from path other than root directory
[string]
--repo-url GitHub URL to generate release for [required]
--dry-run Prepare but do not take action [boolean] [default: false]
--path release from path other than root directory [string]
--component name of component release is being minted for [string]
--package-name name of package release is being minted for [string]
--release-type what type of repo is a release being created for?
--component name of component release is being minted for
[string]
--package-name name of package release is being minted for
[string]
--release-type what type of repo is a release being created
for?
[choices: "dart", "elixir", "go", "go-yoshi", "helm", "java-backport",
"java-bom", "java-lts", "java-yoshi", "krm-blueprint", "node", "ocaml", "php",
"php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "simple",
"terraform-module"]
--config-file where can the config file be found in the project?
[default: "release-please-config.json"]
--manifest-file where can the manifest file be found in the project?
--config-file where can the config file be found in the
project? [default: "release-please-config.json"]
--manifest-file where can the manifest file be found in the
project?
[default: ".release-please-manifest.json"]
--draft mark release as a draft. no tag is created but tag_name and
target_commitish are associated with the release for future
tag creation upon "un-drafting" the release.
--draft mark release as a draft. no tag is created but
tag_name and target_commitish are associated
with the release for future tag creation upon
"un-drafting" the release.
[boolean] [default: false]
--label comma-separated list of labels to remove to from release PR
[default: "autorelease: pending"]
--release-label set a pull request label other than "autorelease: tagged"
--label comma-separated list of labels to remove to from
release PR [default: "autorelease: pending"]
--release-label set a pull request label other than
"autorelease: tagged"
[string] [default: "autorelease: tagged"]
`

Expand Down Expand Up @@ -151,8 +163,6 @@ Options:
the minor for non-breaking changes prior to
the first major release
[boolean] [default: false]
--monorepo-tags include library name in tags and release
branches [boolean] [default: false]
--extra-files extra files for the strategy to consider
[string]
--version-file path to version file to update, e.g.,
Expand All @@ -161,7 +171,6 @@ Options:
generated? [boolean] [default: false]
--versioning-strategy strategy used for bumping versions
[choices: "default", "always-bump-patch", "service-pack"] [default: "default"]
--pull-request-title-pattern Title pattern to make release PR [string]
--changelog-path where can the CHANGELOG be found in the
project? [string] [default: "CHANGELOG.md"]
--last-package-version last version # that package was released as
Expand All @@ -182,6 +191,9 @@ Options:
commit log message using the user and email
provided. (format "Name
<email@example.com>"). [string]
--monorepo-tags include library name in tags and release
branches [boolean] [default: false]
--pull-request-title-pattern Title pattern to make release PR [string]
--path release from path other than root directory
[string]
--component name of component release is being minted
Expand Down
@@ -1,4 +1,4 @@
exports['ReleaseNotes buildNotes should build default release notes 1'] = `
exports['DefaultChangelogNotes buildNotes should build default release notes 1'] = `
### [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
Expand All @@ -16,7 +16,7 @@ exports['ReleaseNotes buildNotes should build default release notes 1'] = `
* some bugfix ([sha2](https://github.com/googleapis/java-asset/commit/sha2))
`

exports['ReleaseNotes buildNotes should build with custom changelog sections 1'] = `
exports['DefaultChangelogNotes buildNotes should build with custom changelog sections 1'] = `
### [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
Expand All @@ -39,7 +39,7 @@ exports['ReleaseNotes buildNotes should build with custom changelog sections 1']
* some documentation ([sha3](https://github.com/googleapis/java-asset/commit/sha3))
`

exports['ReleaseNotes buildNotes should handle BREAKING CHANGE notes 1'] = `
exports['DefaultChangelogNotes buildNotes should handle BREAKING CHANGE notes 1'] = `
### [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
Expand All @@ -52,7 +52,7 @@ exports['ReleaseNotes buildNotes should handle BREAKING CHANGE notes 1'] = `
* some bugfix ([sha2](https://github.com/googleapis/java-asset/commit/sha2))
`

exports['ReleaseNotes buildNotes should ignore RELEASE AS notes 1'] = `
exports['DefaultChangelogNotes buildNotes should ignore RELEASE AS notes 1'] = `
### [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
Expand All @@ -65,7 +65,7 @@ exports['ReleaseNotes buildNotes should ignore RELEASE AS notes 1'] = `
* some bugfix ([sha2](https://github.com/googleapis/java-asset/commit/sha2))
`

exports['ReleaseNotes buildNotes with commit parsing handles Release-As footers 1'] = `
exports['DefaultChangelogNotes buildNotes with commit parsing handles Release-As footers 1'] = `
### [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
Expand All @@ -78,7 +78,7 @@ exports['ReleaseNotes buildNotes with commit parsing handles Release-As footers
* correct release ([1f64add](https://github.com/googleapis/java-asset/commit/1f64add37f426e87ce1b777616a137ec))
`

exports['ReleaseNotes buildNotes with commit parsing should handle BREAKING CHANGE body 1'] = `
exports['DefaultChangelogNotes buildNotes with commit parsing should handle BREAKING CHANGE body 1'] = `
### [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
Expand All @@ -91,7 +91,7 @@ exports['ReleaseNotes buildNotes with commit parsing should handle BREAKING CHAN
* some feature ([78abf20](https://github.com/googleapis/java-asset/commit/78abf20625d3ff86d627b5c6e0cacd06))
`

exports['ReleaseNotes buildNotes with commit parsing should handle a breaking change 1'] = `
exports['DefaultChangelogNotes buildNotes with commit parsing should handle a breaking change 1'] = `
### [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
Expand All @@ -104,7 +104,7 @@ exports['ReleaseNotes buildNotes with commit parsing should handle a breaking ch
* some bugfix ([05670cf](https://github.com/googleapis/java-asset/commit/05670cf2e850beffe53bb2691f8701c7))
`

exports['ReleaseNotes buildNotes with commit parsing should handle bug links 1'] = `
exports['DefaultChangelogNotes buildNotes with commit parsing should handle bug links 1'] = `
### [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
Expand All @@ -113,7 +113,7 @@ exports['ReleaseNotes buildNotes with commit parsing should handle bug links 1']
* some fix ([71489e6](https://github.com/googleapis/java-asset/commit/71489e63ad212c54598f5bdcbedec5f6)), closes [#123](https://github.com/googleapis/java-asset/issues/123)
`

exports['ReleaseNotes buildNotes with commit parsing should handle git trailers 1'] = `
exports['DefaultChangelogNotes buildNotes with commit parsing should handle git trailers 1'] = `
### [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
Expand All @@ -126,7 +126,7 @@ exports['ReleaseNotes buildNotes with commit parsing should handle git trailers
* some fix ([c538c97](https://github.com/googleapis/java-asset/commit/c538c973dc84b83ee6b699cf6433f0b3))
`

exports['ReleaseNotes buildNotes with commit parsing should handle meta commits 1'] = `
exports['DefaultChangelogNotes buildNotes with commit parsing should handle meta commits 1'] = `
### [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
Expand All @@ -145,7 +145,7 @@ exports['ReleaseNotes buildNotes with commit parsing should handle meta commits
* **securitycenter:** fixes security center. ([3cf10aa](https://github.com/googleapis/java-asset/commit/3cf10aa5f94cd40a1d0d08e573eb737f))
`

exports['ReleaseNotes buildNotes with commit parsing should handle multi-line breaking change, if prefixed with list 1'] = `
exports['DefaultChangelogNotes buildNotes with commit parsing should handle multi-line breaking change, if prefixed with list 1'] = `
### [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
Expand All @@ -160,7 +160,7 @@ exports['ReleaseNotes buildNotes with commit parsing should handle multi-line br
* upgrade to Node 7 ([a931c2d](https://github.com/googleapis/java-asset/commit/a931c2d29e9849c6989dfd4712226699))
`

exports['ReleaseNotes buildNotes with commit parsing should handle multi-line breaking changes 1'] = `
exports['DefaultChangelogNotes buildNotes with commit parsing should handle multi-line breaking changes 1'] = `
### [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
Expand All @@ -173,7 +173,7 @@ exports['ReleaseNotes buildNotes with commit parsing should handle multi-line br
* upgrade to Node 7 ([8916be7](https://github.com/googleapis/java-asset/commit/8916be74596394c27516696b957fd0d7))
`

exports['ReleaseNotes buildNotes with commit parsing should not include content two newlines after BREAKING CHANGE 1'] = `
exports['DefaultChangelogNotes buildNotes with commit parsing should not include content two newlines after BREAKING CHANGE 1'] = `
### [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
Expand All @@ -186,7 +186,7 @@ exports['ReleaseNotes buildNotes with commit parsing should not include content
* upgrade to Node 7 ([66925b0](https://github.com/googleapis/java-asset/commit/66925b06f59fc4fdd3031c498e1b0098))
`

exports['ReleaseNotes buildNotes with commit parsing should parse multiple commit messages from a single commit 1'] = `
exports['DefaultChangelogNotes buildNotes with commit parsing should parse multiple commit messages from a single commit 1'] = `
### [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
Expand Down
47 changes: 31 additions & 16 deletions src/bin/release-please.ts
Expand Up @@ -18,7 +18,7 @@ import {coerceOption} from '../util/coerce-option';
import * as yargs from 'yargs';
import {GitHub, GH_API_URL, GH_GRAPHQL_URL} from '../github';
import {Manifest, ManifestOptions, ROOT_PROJECT_PATH} from '../manifest';
import {ChangelogSection} from '../release-notes';
import {ChangelogSection} from '../changelog-notes';
import {logger, setLogger, CheckpointLogger} from '../util/logger';
import {
getReleaserTypes,
Expand Down Expand Up @@ -91,30 +91,35 @@ interface PullRequestArgs {

interface PullRequestStrategyArgs {
snapshot?: boolean;
monorepoTags?: boolean;
changelogSections?: ChangelogSection[];
changelogPath?: string;
versioningStrategy?: VersioningStrategyType;

// for Ruby: TODO refactor to find version.rb like Python finds version.py
// and then remove this property
versionFile?: string;
pullRequestTitlePattern?: string;
extraFiles?: string[];
}

interface TaggingArgs {
monorepoTags?: boolean;
pullRequestTitlePattern?: string;
}

interface CreatePullRequestArgs
extends GitHubArgs,
ManifestArgs,
ManifestConfigArgs,
VersioningArgs,
PullRequestArgs,
PullRequestStrategyArgs {}
PullRequestStrategyArgs,
TaggingArgs {}
interface CreateReleaseArgs
extends GitHubArgs,
ManifestArgs,
ManifestConfigArgs,
ReleaseArgs {}
ReleaseArgs,
TaggingArgs {}
interface CreateManifestPullRequestArgs
extends GitHubArgs,
ManifestArgs,
Expand Down Expand Up @@ -239,11 +244,6 @@ function pullRequestStrategyOptions(yargs: yargs.Argv): yargs.Argv {
default: false,
type: 'boolean',
})
.option('monorepo-tags', {
describe: 'include library name in tags and release branches',
type: 'boolean',
default: false,
})
.option('extra-files', {
describe: 'extra files for the strategy to consider',
type: 'string',
Expand All @@ -268,10 +268,6 @@ function pullRequestStrategyOptions(yargs: yargs.Argv): yargs.Argv {
choices: getVersioningStrategyTypes(),
default: 'default',
})
.option('pull-request-title-pattern', {
describe: 'Title pattern to make release PR',
type: 'string',
})
.option('changelog-path', {
default: 'CHANGELOG.md',
describe: 'where can the CHANGELOG be found in the project?',
Expand Down Expand Up @@ -350,6 +346,19 @@ function manifestOptions(yargs: yargs.Argv): yargs.Argv {
});
}
function taggingOptions(yargs: yargs.Argv): yargs.Argv {
return yargs
.option('monorepo-tags', {
describe: 'include library name in tags and release branches',
type: 'boolean',
default: false,
})
.option('pull-request-title-pattern', {
describe: 'Title pattern to make release PR',
type: 'string',
});
}
const createReleasePullRequestCommand: yargs.CommandModule<
{},
CreatePullRequestArgs
Expand All @@ -359,7 +368,9 @@ const createReleasePullRequestCommand: yargs.CommandModule<
builder(yargs) {
return manifestOptions(
manifestConfigOptions(
pullRequestOptions(pullRequestStrategyOptions(gitHubOptions(yargs)))
taggingOptions(
pullRequestOptions(pullRequestStrategyOptions(gitHubOptions(yargs)))
)
)
);
},
Expand All @@ -384,6 +395,7 @@ const createReleasePullRequestCommand: yargs.CommandModule<
versioning: argv.versioningStrategy,
extraFiles: argv.extraFiles,
versionFile: argv.versionFile,
includeComponentInTag: argv.monorepoTags,
},
extractManifestOptions(argv),
argv.path
Expand Down Expand Up @@ -429,7 +441,9 @@ const createReleaseCommand: yargs.CommandModule<{}, CreateReleaseArgs> = {
describe: 'create a GitHub release from a release PR',
builder(yargs) {
return releaseOptions(
manifestOptions(manifestConfigOptions(gitHubOptions(yargs)))
manifestOptions(
manifestConfigOptions(taggingOptions(gitHubOptions(yargs)))
)
);
},
async handler(argv) {
Expand All @@ -448,6 +462,7 @@ const createReleaseCommand: yargs.CommandModule<{}, CreateReleaseArgs> = {
component: argv.component,
packageName: argv.packageName,
draft: argv.draft,
includeComponentInTag: argv.monorepoTags,
},
extractManifestOptions(argv),
argv.path
Expand Down
37 changes: 37 additions & 0 deletions src/changelog-notes.ts
@@ -0,0 +1,37 @@
// Copyright 2021 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.

import {ConventionalCommit} from './commit';

export interface BuildNotesOptions {
host?: string;
owner: string;
repository: string;
version: string;
previousTag?: string;
currentTag: string;
}

export interface ChangelogNotes {
buildNotes(
commits: ConventionalCommit[],
options: BuildNotesOptions
): Promise<string>;
}

export interface ChangelogSection {
type: string;
section: string;
hidden?: boolean;
}

0 comments on commit 88586f7

Please sign in to comment.