release-please 13.0.0-candidate.4 → 13.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/CHANGELOG.md +1559 -0
  2. package/README.md +33 -131
  3. package/build/src/bin/release-please.js +13 -1
  4. package/build/src/changelog-notes.d.ts +1 -0
  5. package/build/src/changelog-notes.js +24 -0
  6. package/build/src/commit.d.ts +1 -1
  7. package/build/src/commit.js +14 -1
  8. package/build/src/github.d.ts +41 -7
  9. package/build/src/github.js +58 -19
  10. package/build/src/index.d.ts +5 -0
  11. package/build/src/index.js +27 -0
  12. package/build/src/manifest.js +89 -21
  13. package/build/src/plugins/cargo-workspace.js +2 -2
  14. package/build/src/plugins/merge.js +4 -1
  15. package/build/src/plugins/node-workspace.js +2 -2
  16. package/build/src/pull-request.d.ts +8 -8
  17. package/build/src/release-pull-request.d.ts +6 -6
  18. package/build/src/release.d.ts +1 -0
  19. package/build/src/strategies/base.d.ts +108 -0
  20. package/build/src/strategies/base.js +257 -0
  21. package/build/src/strategies/dart.d.ts +2 -2
  22. package/build/src/strategies/dart.js +2 -2
  23. package/build/src/strategies/elixir.d.ts +2 -2
  24. package/build/src/strategies/elixir.js +2 -2
  25. package/build/src/strategies/go-yoshi.d.ts +3 -3
  26. package/build/src/strategies/go-yoshi.js +2 -2
  27. package/build/src/strategies/go.d.ts +2 -2
  28. package/build/src/strategies/go.js +2 -2
  29. package/build/src/strategies/helm.d.ts +2 -2
  30. package/build/src/strategies/helm.js +2 -2
  31. package/build/src/strategies/java-yoshi.d.ts +3 -3
  32. package/build/src/strategies/java-yoshi.js +2 -2
  33. package/build/src/strategies/krm-blueprint.d.ts +2 -2
  34. package/build/src/strategies/krm-blueprint.js +3 -3
  35. package/build/src/strategies/node.d.ts +2 -2
  36. package/build/src/strategies/node.js +2 -2
  37. package/build/src/strategies/ocaml.d.ts +2 -2
  38. package/build/src/strategies/ocaml.js +2 -2
  39. package/build/src/strategies/php-yoshi.d.ts +3 -3
  40. package/build/src/strategies/php-yoshi.js +2 -2
  41. package/build/src/strategies/php.d.ts +3 -3
  42. package/build/src/strategies/php.js +2 -2
  43. package/build/src/strategies/python.d.ts +2 -2
  44. package/build/src/strategies/python.js +2 -2
  45. package/build/src/strategies/ruby-yoshi.d.ts +3 -3
  46. package/build/src/strategies/ruby-yoshi.js +7 -2
  47. package/build/src/strategies/ruby.d.ts +3 -3
  48. package/build/src/strategies/ruby.js +2 -2
  49. package/build/src/strategies/rust.d.ts +2 -2
  50. package/build/src/strategies/rust.js +2 -2
  51. package/build/src/strategies/simple.d.ts +2 -2
  52. package/build/src/strategies/simple.js +2 -2
  53. package/build/src/strategies/terraform-module.d.ts +2 -2
  54. package/build/src/strategies/terraform-module.js +2 -2
  55. package/build/src/strategy.d.ts +8 -73
  56. package/build/src/strategy.js +0 -233
  57. package/build/src/updaters/rust/cargo-toml.js +5 -1
  58. package/build/src/util/commit-split.js +3 -0
  59. package/build/src/util/pull-request-title.js +1 -0
  60. package/build/src/version.d.ts +28 -5
  61. package/build/src/version.js +26 -0
  62. package/build/src/versioning-strategies/always-bump-patch.d.ts +4 -0
  63. package/build/src/versioning-strategies/always-bump-patch.js +4 -0
  64. package/build/src/versioning-strategies/default.d.ts +31 -0
  65. package/build/src/versioning-strategies/default.js +31 -0
  66. package/build/src/versioning-strategies/dependency-manifest.d.ts +8 -0
  67. package/build/src/versioning-strategies/dependency-manifest.js +8 -0
  68. package/build/src/versioning-strategies/java-add-snapshot.d.ts +4 -0
  69. package/build/src/versioning-strategies/java-add-snapshot.js +6 -5
  70. package/build/src/versioning-strategies/java-snapshot.d.ts +4 -0
  71. package/build/src/versioning-strategies/java-snapshot.js +4 -1
  72. package/build/src/versioning-strategies/service-pack.d.ts +5 -0
  73. package/build/src/versioning-strategies/service-pack.js +10 -3
  74. package/build/src/versioning-strategy.d.ts +67 -5
  75. package/build/src/versioning-strategy.js +37 -10
  76. package/package.json +3 -3
  77. package/build/src/bin/release-please.js.map +0 -1
  78. package/build/src/bootstrapper.js.map +0 -1
  79. package/build/src/changelog-notes/default.js.map +0 -1
  80. package/build/src/changelog-notes/github.js.map +0 -1
  81. package/build/src/changelog-notes.js.map +0 -1
  82. package/build/src/commit.js.map +0 -1
  83. package/build/src/errors/index.js.map +0 -1
  84. package/build/src/factory.js.map +0 -1
  85. package/build/src/github.js.map +0 -1
  86. package/build/src/manifest.js.map +0 -1
  87. package/build/src/plugin.js.map +0 -1
  88. package/build/src/plugins/cargo-workspace.js.map +0 -1
  89. package/build/src/plugins/merge.js.map +0 -1
  90. package/build/src/plugins/node-workspace.js.map +0 -1
  91. package/build/src/plugins/workspace.js.map +0 -1
  92. package/build/src/pull-request.js.map +0 -1
  93. package/build/src/release-notes.d.ts +0 -29
  94. package/build/src/release-notes.js +0 -71
  95. package/build/src/release-notes.js.map +0 -1
  96. package/build/src/release-pull-request.js.map +0 -1
  97. package/build/src/release.js.map +0 -1
  98. package/build/src/repository.js.map +0 -1
  99. package/build/src/strategies/dart.js.map +0 -1
  100. package/build/src/strategies/elixir.js.map +0 -1
  101. package/build/src/strategies/go-yoshi.js.map +0 -1
  102. package/build/src/strategies/go.js.map +0 -1
  103. package/build/src/strategies/helm.js.map +0 -1
  104. package/build/src/strategies/java-yoshi.js.map +0 -1
  105. package/build/src/strategies/krm-blueprint.js.map +0 -1
  106. package/build/src/strategies/node.js.map +0 -1
  107. package/build/src/strategies/ocaml.js.map +0 -1
  108. package/build/src/strategies/php-yoshi.js.map +0 -1
  109. package/build/src/strategies/php.js.map +0 -1
  110. package/build/src/strategies/python.js.map +0 -1
  111. package/build/src/strategies/ruby-yoshi.js.map +0 -1
  112. package/build/src/strategies/ruby.js.map +0 -1
  113. package/build/src/strategies/rust.js.map +0 -1
  114. package/build/src/strategies/simple.js.map +0 -1
  115. package/build/src/strategies/terraform-module.js.map +0 -1
  116. package/build/src/strategy.js.map +0 -1
  117. package/build/src/update.js.map +0 -1
  118. package/build/src/updaters/composite.js.map +0 -1
  119. package/build/src/updaters/dart/pubspec-yaml.js.map +0 -1
  120. package/build/src/updaters/default.js.map +0 -1
  121. package/build/src/updaters/dotnet/csproj.js.map +0 -1
  122. package/build/src/updaters/elixir/elixir-mix-exs.js.map +0 -1
  123. package/build/src/updaters/go/version-go.js.map +0 -1
  124. package/build/src/updaters/helm/chart-yaml.js.map +0 -1
  125. package/build/src/updaters/java/java-update.js.map +0 -1
  126. package/build/src/updaters/java/versions-manifest.js.map +0 -1
  127. package/build/src/updaters/krm/krm-blueprint-version.js.map +0 -1
  128. package/build/src/updaters/node/package-json.js.map +0 -1
  129. package/build/src/updaters/node/package-lock-json.js.map +0 -1
  130. package/build/src/updaters/node/samples-package-json.js.map +0 -1
  131. package/build/src/updaters/ocaml/dune-project.js.map +0 -1
  132. package/build/src/updaters/ocaml/esy-json.js.map +0 -1
  133. package/build/src/updaters/ocaml/opam.js.map +0 -1
  134. package/build/src/updaters/php/php-client-version.js.map +0 -1
  135. package/build/src/updaters/php/php-manifest.js.map +0 -1
  136. package/build/src/updaters/php/root-composer-update-packages.js.map +0 -1
  137. package/build/src/updaters/python/pyproject-toml.js.map +0 -1
  138. package/build/src/updaters/python/python-file-with-version.js.map +0 -1
  139. package/build/src/updaters/python/setup-cfg.js.map +0 -1
  140. package/build/src/updaters/python/setup-py.js.map +0 -1
  141. package/build/src/updaters/raw-content.js.map +0 -1
  142. package/build/src/updaters/release-please-config.js.map +0 -1
  143. package/build/src/updaters/release-please-manifest.js.map +0 -1
  144. package/build/src/updaters/ruby/version-rb.js.map +0 -1
  145. package/build/src/updaters/rust/cargo-lock.js.map +0 -1
  146. package/build/src/updaters/rust/cargo-toml.js.map +0 -1
  147. package/build/src/updaters/rust/common.js.map +0 -1
  148. package/build/src/updaters/terraform/module-version.js.map +0 -1
  149. package/build/src/util/branch-name.js.map +0 -1
  150. package/build/src/util/coerce-option.js.map +0 -1
  151. package/build/src/util/commit-split.js.map +0 -1
  152. package/build/src/util/indent-commit.js.map +0 -1
  153. package/build/src/util/json-stringify.js.map +0 -1
  154. package/build/src/util/logger.js.map +0 -1
  155. package/build/src/util/pull-request-body.js.map +0 -1
  156. package/build/src/util/pull-request-title.js.map +0 -1
  157. package/build/src/util/signoff-commit-message.js.map +0 -1
  158. package/build/src/util/tag-name.js.map +0 -1
  159. package/build/src/util/toml-edit.js.map +0 -1
  160. package/build/src/version.js.map +0 -1
  161. package/build/src/versioning-strategies/always-bump-patch.js.map +0 -1
  162. package/build/src/versioning-strategies/default.js.map +0 -1
  163. package/build/src/versioning-strategies/dependency-manifest.js.map +0 -1
  164. package/build/src/versioning-strategies/java-add-snapshot.js.map +0 -1
  165. package/build/src/versioning-strategies/java-snapshot.js.map +0 -1
  166. package/build/src/versioning-strategies/service-pack.js.map +0 -1
  167. package/build/src/versioning-strategy.js.map +0 -1
package/README.md CHANGED
@@ -75,6 +75,8 @@ The above commit message will contain:
75
75
  that it's a breaking change.
76
76
  3. an entry for the feature **"update encode to support unicode"**.
77
77
 
78
+ > :warning: **Important:** The additional messages must be added to the bottom of the commit.
79
+
78
80
  ## How do I change the version number?
79
81
 
80
82
  When a commit to the main branch has `Release-As: x.x.x`(case insensitive) in the **commit body**, Release Please will open a new pull request for the specified version.
@@ -89,31 +91,25 @@ chore: release 2.0.0
89
91
  Release-As: 2.0.0
90
92
  ```
91
93
 
92
- ## Release types supported
94
+ ## Strategy (Language) types supported
93
95
 
94
96
  Release Please automates releases for the following flavors of repositories:
95
97
 
96
98
  | release type | description
97
99
  |-------------------|---------------------------------------------------------|
98
- | node | [A Node.js repository, with a package.json and CHANGELOG.md](https://github.com/yargs/yargs) |
99
- | python | [A Python repository, with a setup.py, setup.cfg, CHANGELOG.md](https://github.com/googleapis/python-storage) and optionally a pyproject.toml and a <project>/\_\_init\_\_.py |
100
- | terraform-module | [A terraform module, with a version in the README.md, and a CHANGELOG.md](https://github.com/terraform-google-modules/terraform-google-project-factory) |
101
- | krm-blueprint | [A kpt package, with 1 or more KRM files and a CHANGELOG.md](https://github.com/GoogleCloudPlatform/blueprints/tree/main/catalog/project) |
102
- | rust | A Rust repository, with a Cargo.toml (either as a crate or workspace) and a CHANGELOG.md |
103
- | ocaml | [An OCaml repository, containing 1 or more opam or esy files and a CHANGELOG.md](https://github.com/grain-lang/binaryen.ml) |
104
- | simple | [A repository with a version.txt and a CHANGELOG.md](https://github.com/googleapis/gapic-generator) |
105
- | helm | A repository with a Chart.yaml and a CHANGELOG.md |
106
- | elixir | A repository with a mix.exs and a CHANGELOG.md |
107
- | dart | A repository with a pubspec.yaml and a CHANGELOG.md |
108
-
109
- ## Adding additional release types
110
-
111
- To add a new release type, simply use the existing [releasers](https://github.com/googleapis/release-please/tree/main/src/releasers) and [updaters](https://github.com/googleapis/release-please/tree/main/src/updaters)
112
- as a starting point.
113
-
114
- **releasers** describe the files that should be updated for a release.
115
-
116
- **updaters** describe how to update the version in these files.
100
+ | `dart` | A repository with a pubspec.yaml and a CHANGELOG.md |
101
+ | `elixir` | A repository with a mix.exs and a CHANGELOG.md |
102
+ | `go` | A repository with a CHANGELOG.md |
103
+ | `helm` | A repository with a Chart.yaml and a CHANGELOG.md |
104
+ | `krm-blueprint` | [A kpt package, with 1 or more KRM files and a CHANGELOG.md](https://github.com/GoogleCloudPlatform/blueprints/tree/main/catalog/project) |
105
+ | `node` | [A Node.js repository, with a package.json and CHANGELOG.md](https://github.com/yargs/yargs) |
106
+ | `ocaml` | [An OCaml repository, containing 1 or more opam or esy files and a CHANGELOG.md](https://github.com/grain-lang/binaryen.ml) |
107
+ | `php` | A repository with a composer.json and a CHANGELOG.md |
108
+ | `python` | [A Python repository, with a setup.py, setup.cfg, CHANGELOG.md](https://github.com/googleapis/python-storage) and optionally a pyproject.toml and a <project>/\_\_init\_\_.py |
109
+ | `ruby` | A repository with a version.rb and a CHANGELOG.md |
110
+ | `rust` | A Rust repository, with a Cargo.toml (either as a crate or workspace) and a CHANGELOG.md |
111
+ | `simple` | [A repository with a version.txt and a CHANGELOG.md](https://github.com/googleapis/gapic-generator) |
112
+ | `terraform-module` | [A terraform module, with a version in the README.md, and a CHANGELOG.md](https://github.com/terraform-google-modules/terraform-google-project-factory) |
117
113
 
118
114
  ## Setting up Release Please
119
115
 
@@ -121,128 +117,34 @@ There are a variety of ways you can deploy release-please:
121
117
 
122
118
  ### GitHub Action (recommended)
123
119
 
124
- The easiest way to run release please is as a GitHub action:
125
-
126
- 1. If you haven't already done so, create a `.github/workflows` folder in your
127
- repository (_this is where your actions will live_).
128
- 2. Now create a `.github/workflows/release-please.yml` file with these contents:
129
-
130
- ```yaml
131
- on:
132
- push:
133
- branches:
134
- - main
135
- name: release-please
136
- jobs:
137
- release-please:
138
- runs-on: ubuntu-latest
139
- steps:
140
- - uses: GoogleCloudPlatform/release-please-action@v2
141
- with:
142
- token: ${{ secrets.GITHUB_TOKEN }}
143
- release-type: node
144
- package-name: release-please-action
145
- ```
146
-
147
- 3. Merge the above action into your repository and make sure new commits follow
148
- the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
149
- convention, [release-please](https://github.com/googleapis/release-please)
150
- will start creating Release PRs for you.
151
-
152
- #### Automating publication to npm
153
-
154
- With a few additions, the Release Please action can be made to publish to
155
- npm when a Release PR is merged:
156
-
157
- ```yaml
158
- on:
159
- push:
160
- branches:
161
- - main
162
- name: release-please
163
- jobs:
164
- release-please:
165
- runs-on: ubuntu-latest
166
- steps:
167
- - uses: GoogleCloudPlatform/release-please-action@v2
168
- id: release
169
- with:
170
- token: ${{ secrets.GITHUB_TOKEN }}
171
- release-type: node
172
- package-name: test-release-please
173
- # The logic below handles the npm publication:
174
- - uses: actions/checkout@v2
175
- # these if statements ensure that a publication only occurs when
176
- # a new release is created:
177
- if: ${{ steps.release.outputs.release_created }}
178
- - uses: actions/setup-node@v1
179
- with:
180
- node-version: 12
181
- registry-url: 'https://registry.npmjs.org'
182
- if: ${{ steps.release.outputs.release_created }}
183
- # if you are using Yarn, substitute the command below with `yarn install --frozen-lockfile`
184
- - run: npm ci
185
- if: ${{ steps.release.outputs.release_created }}
186
- - run: npm publish
187
- env:
188
- NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
189
- if: ${{ steps.release.outputs.release_created }}
190
- ```
191
-
192
- > So that you can keep 2FA enabled for npm publications, we recommend setting
193
- `registry-url` to your own [Wombat Dressing Room](https://github.com/GoogleCloudPlatform/wombat-dressing-room) deployment.
120
+ The easiest way to run release please is as a GitHub action. Please see [google-github-actions/release-please-action](https://github.com/google-github-actions/release-please-action) for installation and configuration instructions.
194
121
 
195
122
  ### Running as CLI
196
123
 
197
- Install release-please globally:
124
+ Please see [Running release-please CLI](docs/cli.md) for all the configuration options.
198
125
 
199
- ```bash
200
- npm i release-please -g
201
- ```
126
+ ### Install the GitHub App
202
127
 
203
- ### Creating/updating release PRs
128
+ There is a probot application available, which allows you to deploy Release
129
+ Please as a GitHub App. Please see
130
+ [github.com/googleapis/repo-automation-bots](https://github.com/googleapis/repo-automation-bots/tree/main/packages/release-please)
131
+ for installation and configuration instructions.
204
132
 
205
- ```bash
206
- release-please release-pr --package-name=@google-cloud/firestore" \
207
- --repo-url=googleapis/nodejs-firestore \
208
- --token=$GITHUB_TOKEN
209
- ```
133
+ ## Bootstrapping your Repository
210
134
 
211
- | option | description |
212
- |-------------------|---------------------------------------------------------|
213
- | `--package-name` | is the name of the package to publish to publish to an upstream registry such as npm. |
214
- | `--repo-url` | is the URL of the repository on GitHub. |
215
- | `--token` | a token with write access to `--repo-url`. |
216
- | `--default-branch`| branch to open pull release PR against (detected by default). |
217
- | `--path` | create a release from a path other than the repository's root |
218
- | `--monorepo-tags` | add prefix to tags and branches, allowing multiple libraries to be released from the same repository. |
219
- | `--pull-request-title-pattern` | add title pattern to make release PR, defaults to using `chore${scope}: release${component} ${version}`. |
220
- | `--signoff` | Add [`Signed-off-by`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---signoff) line at the end of the commit log message using the user and email provided. (format "Name \<email@example.com\>") |
221
- | `--api-url` | URL to use when making API requests [default: "https://api.github.com"] |
222
- | `--graphql-url` | URL to use when making GraphQL requests [default: "https://api.github.com"] |
223
-
224
- ### Creating a release on GitHub
225
-
226
- ```bash
227
- release-please github-release --repo-url=googleapis/nodejs-firestore \
228
- --token=$GITHUB_TOKEN
229
- ```
135
+ Release Please looks at commits since your last release tag. It may or may not be able to find
136
+ your previous releases. The easiest way to on-board your repository is to
137
+ [bootstrap a manifest config](/docs/cli.md#bootstrapping).
230
138
 
231
- | option | description |
232
- |-------------------|---------------------------------------------------------|
233
- | `--package-name` | is the name of the package to publish to publish to an upstream registry such as npm. |
234
- | `--repo-url` | is the URL of the repository on GitHub. |
235
- | `--token` | a token with write access to `--repo-url`. |
236
- | `--path` | create a release from a path other than the repository's root |
237
- | `--api-url` | URL to use when making API requests [default: "https://api.github.com"] |
238
- | `--graphql-url` | URL to use when making GraphQL requests [default: "https://api.github.com"] |
139
+ ## Customizing Release Please
239
140
 
240
- ### Running as a GitHub App
141
+ Release Please provides several configuration options to allow customizing
142
+ your release process. Please see [customizing.md](docs/customizing.md) for more details.
241
143
 
242
- There is a probot application available, which allows you to deploy Release
243
- Please as a GitHub App:
144
+ ## Supporting Monorepos via Manifest Configuration
244
145
 
245
- * [github.com/googleapis/repo-automation-bots](https://github.com/googleapis/repo-automation-bots/tree/main/packages/release-please).
146
+ Release Please also supports releasing multiple artifacts from the same repository.
147
+ See more at [manifest-releaser.md](docs/manifest-releaser.md).
246
148
 
247
149
  ## Supported Node.js Versions
248
150
 
@@ -19,6 +19,7 @@ const coerce_option_1 = require("../util/coerce-option");
19
19
  const yargs = require("yargs");
20
20
  const github_1 = require("../github");
21
21
  const manifest_1 = require("../manifest");
22
+ const changelog_notes_1 = require("../changelog-notes");
22
23
  const logger_1 = require("../util/logger");
23
24
  const factory_1 = require("../factory");
24
25
  const bootstrapper_1 = require("../bootstrapper");
@@ -157,6 +158,16 @@ function pullRequestStrategyOptions(yargs) {
157
158
  .option('changelog-type', {
158
159
  describe: 'type of changelog to build',
159
160
  choices: factory_1.getChangelogTypes(),
161
+ })
162
+ .option('changelog-sections', {
163
+ describe: 'comma-separated list of scopes to include in the changelog',
164
+ type: 'string',
165
+ coerce: (arg) => {
166
+ if (arg) {
167
+ return changelog_notes_1.buildChangelogSections(arg.split(','));
168
+ }
169
+ return arg;
170
+ },
160
171
  })
161
172
  .option('last-package-version', {
162
173
  describe: 'last version # that package was released as',
@@ -251,6 +262,7 @@ const createReleasePullRequestCommand = {
251
262
  bumpPatchForMinorPreMajor: argv.bumpPatchForMinorPreMajor,
252
263
  changelogPath: argv.changelogPath,
253
264
  changelogType: argv.changelogType,
265
+ pullRequestTitlePattern: argv.pullRequestTitlePattern,
254
266
  changelogSections: argv.changelogSections,
255
267
  releaseAs: argv.releaseAs,
256
268
  versioning: argv.versioningStrategy,
@@ -388,7 +400,7 @@ const bootstrapCommand = {
388
400
  command: 'bootstrap',
389
401
  describe: 'configure release manifest',
390
402
  builder(yargs) {
391
- return manifestOptions(releaseOptions(pullRequestStrategyOptions(gitHubOptions(yargs))))
403
+ return manifestConfigOptions(manifestOptions(releaseOptions(pullRequestStrategyOptions(gitHubOptions(yargs)))))
392
404
  .option('initial-version', {
393
405
  description: 'current version',
394
406
  })
@@ -17,3 +17,4 @@ export interface ChangelogSection {
17
17
  section: string;
18
18
  hidden?: boolean;
19
19
  }
20
+ export declare function buildChangelogSections(scopes: string[]): ChangelogSection[];
@@ -13,4 +13,28 @@
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.buildChangelogSections = void 0;
17
+ const DEFAULT_HEADINGS = {
18
+ feat: 'Features',
19
+ fix: 'Bug Fixes',
20
+ perf: 'Performance Improvements',
21
+ deps: 'Dependencies',
22
+ revert: 'Reverts',
23
+ docs: 'Documentation',
24
+ style: 'Styles',
25
+ chore: 'Miscellaneous Chores',
26
+ refactor: 'Code Refactoring',
27
+ test: 'Tests',
28
+ build: 'Build System',
29
+ ci: 'Continuous Integration',
30
+ };
31
+ function buildChangelogSections(scopes) {
32
+ return scopes.map(scope => {
33
+ return {
34
+ type: scope,
35
+ section: DEFAULT_HEADINGS[scope] || scope,
36
+ };
37
+ });
38
+ }
39
+ exports.buildChangelogSections = buildChangelogSections;
16
40
  //# sourceMappingURL=changelog-notes.js.map
@@ -3,7 +3,7 @@ import * as parser from '@conventional-commits/parser';
3
3
  export interface Commit {
4
4
  sha: string;
5
5
  message: string;
6
- files: string[];
6
+ files?: string[];
7
7
  pullRequest?: PullRequest;
8
8
  }
9
9
  export interface ConventionalCommit extends Commit {
@@ -288,8 +288,9 @@ function parseCommits(message) {
288
288
  function parseConventionalCommits(commits) {
289
289
  const conventionalCommits = [];
290
290
  for (const commit of commits) {
291
+ const commitMessage = preprocessCommitMessage(commit);
291
292
  try {
292
- for (const parsedCommit of parseCommits(commit.message)) {
293
+ for (const parsedCommit of parseCommits(commitMessage)) {
293
294
  const breaking = parsedCommit.notes.filter(note => note.title === 'BREAKING CHANGE')
294
295
  .length > 0;
295
296
  conventionalCommits.push({
@@ -313,4 +314,16 @@ function parseConventionalCommits(commits) {
313
314
  return conventionalCommits;
314
315
  }
315
316
  exports.parseConventionalCommits = parseConventionalCommits;
317
+ function preprocessCommitMessage(commit) {
318
+ // look for 'BEGIN_COMMIT_OVERRIDE' section of pull request body
319
+ if (commit.pullRequest) {
320
+ const overrideMessage = (commit.pullRequest.body.split('BEGIN_COMMIT_OVERRIDE')[1] || '')
321
+ .split('END_COMMIT_OVERRIDE')[0]
322
+ .trim();
323
+ if (overrideMessage) {
324
+ return overrideMessage;
325
+ }
326
+ }
327
+ return commit.message;
328
+ }
316
329
  //# sourceMappingURL=commit.js.map
@@ -36,6 +36,16 @@ export interface GitHubFileContents {
36
36
  parsedContent: string;
37
37
  }
38
38
  declare type CommitFilter = (commit: Commit) => boolean;
39
+ interface CommitIteratorOptions {
40
+ maxResults?: number;
41
+ backfillFiles?: boolean;
42
+ }
43
+ interface ReleaseIteratorOptions {
44
+ maxResults?: number;
45
+ }
46
+ interface TagIteratorOptions {
47
+ maxResults?: number;
48
+ }
39
49
  export interface GitHubRelease {
40
50
  name?: string;
41
51
  tagName: string;
@@ -44,6 +54,10 @@ export interface GitHubRelease {
44
54
  url: string;
45
55
  draft?: boolean;
46
56
  }
57
+ export interface GitHubTag {
58
+ name: string;
59
+ sha: string;
60
+ }
47
61
  export declare class GitHub {
48
62
  readonly repository: Repository;
49
63
  private octokit;
@@ -81,22 +95,28 @@ export declare class GitHub {
81
95
  * @param {string} targetBranch Target branch of commit
82
96
  * @param {CommitFilter} filter Callback function that returns whether a
83
97
  * commit/pull request matches certain criteria
84
- * @param {number} maxResults Limit the number of results searched.
98
+ * @param {CommitIteratorOptions} options Query options
99
+ * @param {number} options.maxResults Limit the number of results searched.
85
100
  * Defaults to unlimited.
101
+ * @param {boolean} options.backfillFiles If set, use the REST API for
102
+ * fetching the list of touched files in this commit. Defaults to `false`.
86
103
  * @returns {Commit[]} List of commits to current branch
87
104
  * @throws {GitHubAPIError} on an API error
88
105
  */
89
- commitsSince(targetBranch: string, filter: CommitFilter, maxResults?: number): Promise<Commit[]>;
106
+ commitsSince(targetBranch: string, filter: CommitFilter, options?: CommitIteratorOptions): Promise<Commit[]>;
90
107
  /**
91
108
  * Iterate through commit history with a max number of results scanned.
92
109
  *
93
110
  * @param {string} targetBranch target branch of commit
94
- * @param {number} maxResults maxResults - Limit the number of results searched.
111
+ * @param {CommitIteratorOptions} options Query options
112
+ * @param {number} options.maxResults Limit the number of results searched.
95
113
  * Defaults to unlimited.
114
+ * @param {boolean} options.backfillFiles If set, use the REST API for
115
+ * fetching the list of touched files in this commit. Defaults to `false`.
96
116
  * @yields {Commit}
97
117
  * @throws {GitHubAPIError} on an API error
98
118
  */
99
- mergeCommitIterator(targetBranch: string, maxResults?: number): AsyncGenerator<Commit, void, unknown>;
119
+ mergeCommitIterator(targetBranch: string, options?: CommitIteratorOptions): AsyncGenerator<Commit, void, unknown>;
100
120
  private mergeCommitsGraphQL;
101
121
  /**
102
122
  * Get the list of file paths modified in a given commit.
@@ -129,15 +149,29 @@ export declare class GitHub {
129
149
  */
130
150
  private pullRequestsGraphQL;
131
151
  /**
132
- * Iterate through merged pull requests with a max number of results scanned.
152
+ * Iterate through releases with a max number of results scanned.
133
153
  *
134
- * @param {number} maxResults maxResults - Limit the number of results searched.
154
+ * @param {ReleaseIteratorOptions} options Query options
155
+ * @param {number} options.maxResults Limit the number of results searched.
135
156
  * Defaults to unlimited.
136
157
  * @yields {GitHubRelease}
137
158
  * @throws {GitHubAPIError} on an API error
138
159
  */
139
- releaseIterator(maxResults?: number): AsyncGenerator<GitHubRelease, void, unknown>;
160
+ releaseIterator(options?: ReleaseIteratorOptions): AsyncGenerator<GitHubRelease, void, unknown>;
140
161
  private releaseGraphQL;
162
+ /**
163
+ * Iterate through tags with a max number of results scanned.
164
+ *
165
+ * @param {TagIteratorOptions} options Query options
166
+ * @param {number} options.maxResults Limit the number of results searched.
167
+ * Defaults to unlimited.
168
+ * @yields {GitHubTag}
169
+ * @throws {GitHubAPIError} on an API error
170
+ */
171
+ tagIterator(options?: TagIteratorOptions): AsyncGenerator<{
172
+ name: string;
173
+ sha: string;
174
+ }, void, unknown>;
141
175
  /**
142
176
  * Fetch the contents of a file from the configured branch
143
177
  *
@@ -139,7 +139,7 @@ class GitHub {
139
139
  // match the filename
140
140
  path.endsWith(filename) &&
141
141
  // match the prefix if provided
142
- (!prefix || path.startsWith(prefix)));
142
+ (!prefix || path.startsWith(`${prefix}/`)));
143
143
  })
144
144
  .map(file => {
145
145
  let path = file.path;
@@ -277,7 +277,7 @@ class GitHub {
277
277
  // match the file extension
278
278
  path.endsWith(`.${extension}`) &&
279
279
  // match the prefix if provided
280
- (!prefix || path.startsWith(prefix)));
280
+ (!prefix || path.startsWith(`${prefix}/`)));
281
281
  })
282
282
  .map(file => {
283
283
  let path = file.path;
@@ -299,6 +299,7 @@ class GitHub {
299
299
  */
300
300
  this.createRelease = wrapAsync(async (release, options = {}) => {
301
301
  const resp = await this.octokit.repos.createRelease({
302
+ name: release.name,
302
303
  owner: this.repository.owner,
303
304
  repo: this.repository.repo,
304
305
  tag_name: release.tag.toString(),
@@ -454,14 +455,17 @@ class GitHub {
454
455
  * @param {string} targetBranch Target branch of commit
455
456
  * @param {CommitFilter} filter Callback function that returns whether a
456
457
  * commit/pull request matches certain criteria
457
- * @param {number} maxResults Limit the number of results searched.
458
+ * @param {CommitIteratorOptions} options Query options
459
+ * @param {number} options.maxResults Limit the number of results searched.
458
460
  * Defaults to unlimited.
461
+ * @param {boolean} options.backfillFiles If set, use the REST API for
462
+ * fetching the list of touched files in this commit. Defaults to `false`.
459
463
  * @returns {Commit[]} List of commits to current branch
460
464
  * @throws {GitHubAPIError} on an API error
461
465
  */
462
- async commitsSince(targetBranch, filter, maxResults = Number.MAX_SAFE_INTEGER) {
466
+ async commitsSince(targetBranch, filter, options = {}) {
463
467
  const commits = [];
464
- const generator = this.mergeCommitIterator(targetBranch, maxResults);
468
+ const generator = this.mergeCommitIterator(targetBranch, options);
465
469
  for await (const commit of generator) {
466
470
  if (filter(commit)) {
467
471
  break;
@@ -474,16 +478,21 @@ class GitHub {
474
478
  * Iterate through commit history with a max number of results scanned.
475
479
  *
476
480
  * @param {string} targetBranch target branch of commit
477
- * @param {number} maxResults maxResults - Limit the number of results searched.
481
+ * @param {CommitIteratorOptions} options Query options
482
+ * @param {number} options.maxResults Limit the number of results searched.
478
483
  * Defaults to unlimited.
484
+ * @param {boolean} options.backfillFiles If set, use the REST API for
485
+ * fetching the list of touched files in this commit. Defaults to `false`.
479
486
  * @yields {Commit}
480
487
  * @throws {GitHubAPIError} on an API error
481
488
  */
482
- async *mergeCommitIterator(targetBranch, maxResults = Number.MAX_SAFE_INTEGER) {
489
+ async *mergeCommitIterator(targetBranch, options = {}) {
490
+ var _a;
491
+ const maxResults = (_a = options.maxResults) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER;
483
492
  let cursor = undefined;
484
493
  let results = 0;
485
494
  while (results < maxResults) {
486
- const response = await this.mergeCommitsGraphQL(targetBranch, cursor);
495
+ const response = await this.mergeCommitsGraphQL(targetBranch, cursor, options);
487
496
  // no response usually means that the branch can't be found
488
497
  if (!response) {
489
498
  break;
@@ -498,7 +507,7 @@ class GitHub {
498
507
  cursor = response.pageInfo.endCursor;
499
508
  }
500
509
  }
501
- async mergeCommitsGraphQL(targetBranch, cursor) {
510
+ async mergeCommitsGraphQL(targetBranch, cursor, options = {}) {
502
511
  logger_1.logger.debug(`Fetching merge commits on branch ${targetBranch} with cursor: ${cursor}`);
503
512
  const response = await this.graphqlRequest({
504
513
  query: `query pullRequestsSince($owner: String!, $repo: String!, $num: Int!, $maxFilesChanged: Int, $targetBranch: String!, $cursor: String) {
@@ -566,7 +575,6 @@ class GitHub {
566
575
  const commit = {
567
576
  sha: graphCommit.sha,
568
577
  message: graphCommit.message,
569
- files: [],
570
578
  };
571
579
  const pullRequest = graphCommit.associatedPullRequests.nodes.find(pr => {
572
580
  return pr.mergeCommit && pr.mergeCommit.oid === graphCommit.sha;
@@ -587,7 +595,7 @@ class GitHub {
587
595
  // information for commits with associated pull requests
588
596
  commit.files = files;
589
597
  }
590
- else {
598
+ else if (options.backfillFiles) {
591
599
  // In this case, there is no squashed merge commit. This could be a simple
592
600
  // merge commit, a rebase merge commit, or a direct commit to the branch.
593
601
  // Fallback to fetching the list of commits from the REST API. In the future
@@ -708,23 +716,28 @@ class GitHub {
708
716
  };
709
717
  }
710
718
  /**
711
- * Iterate through merged pull requests with a max number of results scanned.
719
+ * Iterate through releases with a max number of results scanned.
712
720
  *
713
- * @param {number} maxResults maxResults - Limit the number of results searched.
721
+ * @param {ReleaseIteratorOptions} options Query options
722
+ * @param {number} options.maxResults Limit the number of results searched.
714
723
  * Defaults to unlimited.
715
724
  * @yields {GitHubRelease}
716
725
  * @throws {GitHubAPIError} on an API error
717
726
  */
718
- async *releaseIterator(maxResults = Number.MAX_SAFE_INTEGER) {
727
+ async *releaseIterator(options = {}) {
728
+ var _a;
729
+ const maxResults = (_a = options.maxResults) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER;
719
730
  let results = 0;
720
731
  let cursor = undefined;
721
- while (results < maxResults) {
732
+ while (true) {
722
733
  const response = await this.releaseGraphQL(cursor);
723
734
  if (!response) {
724
735
  break;
725
736
  }
726
737
  for (let i = 0; i < response.data.length; i++) {
727
- results += 1;
738
+ if ((results += 1) > maxResults) {
739
+ break;
740
+ }
728
741
  yield response.data[i];
729
742
  }
730
743
  if (!response.pageInfo.hasNextPage) {
@@ -763,12 +776,11 @@ class GitHub {
763
776
  repo: this.repository.repo,
764
777
  num: 25,
765
778
  });
766
- if (!response.repository.releases) {
779
+ if (!response.repository.releases.nodes.length) {
767
780
  logger_1.logger.warn('Could not find releases.');
768
781
  return null;
769
782
  }
770
- const releases = (response.repository.releases.nodes ||
771
- []);
783
+ const releases = response.repository.releases.nodes;
772
784
  return {
773
785
  pageInfo: response.repository.releases.pageInfo,
774
786
  data: releases
@@ -788,6 +800,33 @@ class GitHub {
788
800
  }),
789
801
  };
790
802
  }
803
+ /**
804
+ * Iterate through tags with a max number of results scanned.
805
+ *
806
+ * @param {TagIteratorOptions} options Query options
807
+ * @param {number} options.maxResults Limit the number of results searched.
808
+ * Defaults to unlimited.
809
+ * @yields {GitHubTag}
810
+ * @throws {GitHubAPIError} on an API error
811
+ */
812
+ async *tagIterator(options = {}) {
813
+ const maxResults = options.maxResults || Number.MAX_SAFE_INTEGER;
814
+ let results = 0;
815
+ for await (const response of this.octokit.paginate.iterator(this.octokit.rest.repos.listTags, {
816
+ owner: this.repository.owner,
817
+ repo: this.repository.repo,
818
+ })) {
819
+ for (const tag of response.data) {
820
+ if ((results += 1) > maxResults) {
821
+ break;
822
+ }
823
+ yield {
824
+ name: tag.name,
825
+ sha: tag.commit.sha,
826
+ };
827
+ }
828
+ }
829
+ }
791
830
  /**
792
831
  * Fetch the contents of a file from the configured branch
793
832
  *
@@ -0,0 +1,5 @@
1
+ export * as Errors from './errors';
2
+ export { Manifest, ReleaserConfig, ManifestOptions } from './manifest';
3
+ export { ReleaseType, getReleaserTypes, VersioningStrategyType, getVersioningStrategyTypes, ChangelogNotesType, getChangelogTypes, } from './factory';
4
+ export { Logger, setLogger } from './util/logger';
5
+ export { GitHub } from './github';
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ // Copyright 2021 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.Errors = require("./errors");
17
+ var manifest_1 = require("./manifest");
18
+ Object.defineProperty(exports, "Manifest", { enumerable: true, get: function () { return manifest_1.Manifest; } });
19
+ var factory_1 = require("./factory");
20
+ Object.defineProperty(exports, "getReleaserTypes", { enumerable: true, get: function () { return factory_1.getReleaserTypes; } });
21
+ Object.defineProperty(exports, "getVersioningStrategyTypes", { enumerable: true, get: function () { return factory_1.getVersioningStrategyTypes; } });
22
+ Object.defineProperty(exports, "getChangelogTypes", { enumerable: true, get: function () { return factory_1.getChangelogTypes; } });
23
+ var logger_1 = require("./util/logger");
24
+ Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return logger_1.setLogger; } });
25
+ var github_1 = require("./github");
26
+ Object.defineProperty(exports, "GitHub", { enumerable: true, get: function () { return github_1.GitHub; } });
27
+ //# sourceMappingURL=index.js.map