release-please 13.0.0-candidate.5 → 13.0.0

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 (75) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +33 -131
  3. package/build/src/bin/release-please.js +12 -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 +51 -14
  10. package/build/src/manifest.js +76 -20
  11. package/build/src/plugins/cargo-workspace.js +2 -2
  12. package/build/src/plugins/merge.js +4 -1
  13. package/build/src/plugins/node-workspace.js +2 -2
  14. package/build/src/pull-request.d.ts +8 -8
  15. package/build/src/release-pull-request.d.ts +6 -6
  16. package/build/src/strategies/base.d.ts +108 -0
  17. package/build/src/strategies/base.js +253 -0
  18. package/build/src/strategies/dart.d.ts +2 -2
  19. package/build/src/strategies/dart.js +2 -2
  20. package/build/src/strategies/elixir.d.ts +2 -2
  21. package/build/src/strategies/elixir.js +2 -2
  22. package/build/src/strategies/go-yoshi.d.ts +3 -3
  23. package/build/src/strategies/go-yoshi.js +2 -2
  24. package/build/src/strategies/go.d.ts +2 -2
  25. package/build/src/strategies/go.js +2 -2
  26. package/build/src/strategies/helm.d.ts +2 -2
  27. package/build/src/strategies/helm.js +2 -2
  28. package/build/src/strategies/java-yoshi.d.ts +3 -3
  29. package/build/src/strategies/java-yoshi.js +2 -2
  30. package/build/src/strategies/krm-blueprint.d.ts +2 -2
  31. package/build/src/strategies/krm-blueprint.js +3 -3
  32. package/build/src/strategies/node.d.ts +2 -2
  33. package/build/src/strategies/node.js +2 -2
  34. package/build/src/strategies/ocaml.d.ts +2 -2
  35. package/build/src/strategies/ocaml.js +2 -2
  36. package/build/src/strategies/php-yoshi.d.ts +3 -3
  37. package/build/src/strategies/php-yoshi.js +2 -2
  38. package/build/src/strategies/php.d.ts +3 -3
  39. package/build/src/strategies/php.js +2 -2
  40. package/build/src/strategies/python.d.ts +2 -2
  41. package/build/src/strategies/python.js +2 -2
  42. package/build/src/strategies/ruby-yoshi.d.ts +3 -3
  43. package/build/src/strategies/ruby-yoshi.js +7 -2
  44. package/build/src/strategies/ruby.d.ts +3 -3
  45. package/build/src/strategies/ruby.js +2 -2
  46. package/build/src/strategies/rust.d.ts +2 -2
  47. package/build/src/strategies/rust.js +2 -2
  48. package/build/src/strategies/simple.d.ts +2 -2
  49. package/build/src/strategies/simple.js +2 -2
  50. package/build/src/strategies/terraform-module.d.ts +2 -2
  51. package/build/src/strategies/terraform-module.js +2 -2
  52. package/build/src/strategy.d.ts +8 -73
  53. package/build/src/strategy.js +0 -233
  54. package/build/src/updaters/rust/cargo-toml.js +5 -1
  55. package/build/src/util/commit-split.js +3 -0
  56. package/build/src/util/pull-request-title.js +1 -0
  57. package/build/src/version.d.ts +28 -5
  58. package/build/src/version.js +26 -0
  59. package/build/src/versioning-strategies/always-bump-patch.d.ts +4 -0
  60. package/build/src/versioning-strategies/always-bump-patch.js +4 -0
  61. package/build/src/versioning-strategies/default.d.ts +31 -0
  62. package/build/src/versioning-strategies/default.js +31 -0
  63. package/build/src/versioning-strategies/dependency-manifest.d.ts +8 -0
  64. package/build/src/versioning-strategies/dependency-manifest.js +8 -0
  65. package/build/src/versioning-strategies/java-add-snapshot.d.ts +4 -0
  66. package/build/src/versioning-strategies/java-add-snapshot.js +6 -5
  67. package/build/src/versioning-strategies/java-snapshot.d.ts +4 -0
  68. package/build/src/versioning-strategies/java-snapshot.js +4 -1
  69. package/build/src/versioning-strategies/service-pack.d.ts +5 -0
  70. package/build/src/versioning-strategies/service-pack.js +10 -3
  71. package/build/src/versioning-strategy.d.ts +67 -5
  72. package/build/src/versioning-strategy.js +37 -10
  73. package/package.json +3 -3
  74. package/build/src/release-notes.d.ts +0 -29
  75. package/build/src/release-notes.js +0 -71
package/CHANGELOG.md CHANGED
@@ -4,6 +4,58 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/release-please?activeTab=versions
6
6
 
7
+ ## [13.0.0](https://www.github.com/googleapis/release-please/compare/v12.6.0...v13.0.0) (2021-12-22)
8
+
9
+
10
+ ### ⚠ BREAKING CHANGES
11
+
12
+ * releasers are now "strategies", more logic moved into base classes
13
+ * Node 12 is now required
14
+ * manifest is now main entrypoint for release please, and logic is shared between mono-repo/split-repo flow
15
+ * versioning straregy now handled by VersionStrategies rather than regexes
16
+ * merge Manifest and standard PR paths (#1104)
17
+
18
+ ### Features
19
+
20
+ * add `includeComponentInTag` option for strategies and hook up to `--monorepo-tags` ([#1119](https://www.github.com/googleapis/release-please/issues/1119)) ([bf9aacd](https://www.github.com/googleapis/release-please/commit/bf9aacdde3a97c453f6e3280035607c97c7dffcd))
21
+ * add ability to override merged commit message ([#1161](https://www.github.com/googleapis/release-please/issues/1161)) ([c568b57](https://www.github.com/googleapis/release-please/commit/c568b57280f2048f6dabbb716cdb4174c3386b91)), closes [#967](https://www.github.com/googleapis/release-please/issues/967)
22
+ * add GitHub changelog notes generator ([#1120](https://www.github.com/googleapis/release-please/issues/1120)) ([1470661](https://www.github.com/googleapis/release-please/commit/1470661bd76a1e731585ed3fbf7363224c7a7a3e))
23
+ * enable specifying changelog section headings in the CLI ([#1162](https://www.github.com/googleapis/release-please/issues/1162)) ([aaa8342](https://www.github.com/googleapis/release-please/commit/aaa8342cd48062c56fe87b3296904274b7fb9dbe)), closes [#511](https://www.github.com/googleapis/release-please/issues/511)
24
+ * **go:** add support for bumping a Go version file ([#1112](https://www.github.com/googleapis/release-please/issues/1112)) ([8f6e52b](https://www.github.com/googleapis/release-please/commit/8f6e52b27811e6838800c7152be74e13201eb9e1))
25
+ * reimplement custom pull request title ([#1122](https://www.github.com/googleapis/release-please/issues/1122)) ([2f3e84c](https://www.github.com/googleapis/release-please/commit/2f3e84c8c51f367cad8baae44c8d9f0727aa02a5))
26
+ * reimplement Java 1.0.0 special version bumping ([#1126](https://www.github.com/googleapis/release-please/issues/1126)) ([28bc76b](https://www.github.com/googleapis/release-please/commit/28bc76b35d9e1eff218a5be1b9b8cebb4b1e6f9d))
27
+ * return path along with created release ([#1114](https://www.github.com/googleapis/release-please/issues/1114)) ([81fc0f4](https://www.github.com/googleapis/release-please/commit/81fc0f49d75ec66ef1915be26330734abddd11d7))
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * add back version/major/minor/patch ([#1118](https://www.github.com/googleapis/release-please/issues/1118)) ([4b6ae50](https://www.github.com/googleapis/release-please/commit/4b6ae5049e39e6f5bca10b514256090ea76ef5bd))
33
+ * allow setting release-type at root of manifest config ([#1159](https://www.github.com/googleapis/release-please/issues/1159)) ([fc73b6d](https://www.github.com/googleapis/release-please/commit/fc73b6dd3f5f7ed449b9d304e53bada911e3190f))
34
+ * backfill commit files ([#1110](https://www.github.com/googleapis/release-please/issues/1110)) ([173ce70](https://www.github.com/googleapis/release-please/commit/173ce704c9413d7f0da820fdd2961166a5ff0b73))
35
+ * backfill latest release with version found in manifest ([#1131](https://www.github.com/googleapis/release-please/issues/1131)) ([94859a0](https://www.github.com/googleapis/release-please/commit/94859a0cfbc58724016daaefaca03f34a43e0473))
36
+ * **cli:** pass pull-request-title-pattern ([#1128](https://www.github.com/googleapis/release-please/issues/1128)) ([28d7727](https://www.github.com/googleapis/release-please/commit/28d7727bc827612b02a8fde58d13cd87f962a399))
37
+ * combined manifest PR should include labels ([#1137](https://www.github.com/googleapis/release-please/issues/1137)) ([d8bb7ca](https://www.github.com/googleapis/release-please/commit/d8bb7caddfa14aabd3bfa19008c10ed911638a66))
38
+ * fallback to look at releases when looking for latest release ([#1146](https://www.github.com/googleapis/release-please/issues/1146)) ([76ed1a7](https://www.github.com/googleapis/release-please/commit/76ed1a77e64f28b0af7d8125dce457b885f80e52))
39
+ * fallback to look at tags when looking for latest release ([#1160](https://www.github.com/googleapis/release-please/issues/1160)) ([e06c6ba](https://www.github.com/googleapis/release-please/commit/e06c6ba5c3ce29689275e495934d4a6785962d5b))
40
+ * GitHub#findFilesByExtension should treat prefix as a directory ([#1165](https://www.github.com/googleapis/release-please/issues/1165)) ([b48ec5b](https://www.github.com/googleapis/release-please/commit/b48ec5bc285233436d7cb1b367326a3c6dd555a9))
41
+ * **github:** correctly return maxResults releases ([#1134](https://www.github.com/googleapis/release-please/issues/1134)) ([25f6811](https://www.github.com/googleapis/release-please/commit/25f68113d0e0bfa5a181d616c11bfd5e573cfaf5))
42
+ * make PullRequest, ReleasePullRequest, Version fields readonly ([#1150](https://www.github.com/googleapis/release-please/issues/1150)) ([9659c1c](https://www.github.com/googleapis/release-please/commit/9659c1c868395394a40ff8f6caf9aaa7998fb8b8))
43
+ * Manifest.fromConfig can find latest release version without component ([#1123](https://www.github.com/googleapis/release-please/issues/1123)) ([0aeb67b](https://www.github.com/googleapis/release-please/commit/0aeb67b4c4a497b5570bdec10f5ab15e620b235d))
44
+ * merge manifest release PRs unless separatePullRequests is configured ([#1129](https://www.github.com/googleapis/release-please/issues/1129)) ([328009d](https://www.github.com/googleapis/release-please/commit/328009d10b4609441a6f8432fa0d2aa9df1f5ff0))
45
+ * only backfill files if requested ([#1151](https://www.github.com/googleapis/release-please/issues/1151)) ([ae007fe](https://www.github.com/googleapis/release-please/commit/ae007feb430e97f2995d6fd431f2825512651e3a))
46
+ * reimplement draft releases ([#1111](https://www.github.com/googleapis/release-please/issues/1111)) ([6f38b4a](https://www.github.com/googleapis/release-please/commit/6f38b4aa5a206b358468e623a020ef715257ddfe))
47
+ * **rust:** Don't update dev-dependencies lacking a version key ([#1095](https://www.github.com/googleapis/release-please/issues/1095)) ([#1152](https://www.github.com/googleapis/release-please/issues/1152)) ([56f37d9](https://www.github.com/googleapis/release-please/commit/56f37d997c75ec5bcc330b08b0e9e25c68329b7a)), closes [#1094](https://www.github.com/googleapis/release-please/issues/1094)
48
+ * switch branch delimiter to `--` ([#1127](https://www.github.com/googleapis/release-please/issues/1127)) ([26442f1](https://www.github.com/googleapis/release-please/commit/26442f14356c387c9117f5d660b532185c8084c4))
49
+
50
+
51
+ ### Code Refactoring
52
+
53
+ * manifest is now main entrypoint for release please, and logic is shared between mono-repo/split-repo flow ([fd8f9fc](https://www.github.com/googleapis/release-please/commit/fd8f9fc82838f3a3a05470dfe4dab4d3b47c6fa1))
54
+ * merge Manifest and standard PR paths ([#1104](https://www.github.com/googleapis/release-please/issues/1104)) ([fd8f9fc](https://www.github.com/googleapis/release-please/commit/fd8f9fc82838f3a3a05470dfe4dab4d3b47c6fa1))
55
+ * Node 12 is now required ([fd8f9fc](https://www.github.com/googleapis/release-please/commit/fd8f9fc82838f3a3a05470dfe4dab4d3b47c6fa1))
56
+ * releasers are now "strategies", more logic moved into base classes ([fd8f9fc](https://www.github.com/googleapis/release-please/commit/fd8f9fc82838f3a3a05470dfe4dab4d3b47c6fa1))
57
+ * versioning straregy now handled by VersionStrategies rather than regexes ([fd8f9fc](https://www.github.com/googleapis/release-please/commit/fd8f9fc82838f3a3a05470dfe4dab4d3b47c6fa1))
58
+
7
59
  ## [12.6.0](https://www.github.com/googleapis/release-please/compare/v12.5.0...v12.6.0) (2021-10-11)
8
60
 
9
61
 
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',
@@ -389,7 +400,7 @@ const bootstrapCommand = {
389
400
  command: 'bootstrap',
390
401
  describe: 'configure release manifest',
391
402
  builder(yargs) {
392
- return manifestOptions(releaseOptions(pullRequestStrategyOptions(gitHubOptions(yargs))))
403
+ return manifestConfigOptions(manifestOptions(releaseOptions(pullRequestStrategyOptions(gitHubOptions(yargs)))))
393
404
  .option('initial-version', {
394
405
  description: 'current version',
395
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;
@@ -454,14 +454,17 @@ class GitHub {
454
454
  * @param {string} targetBranch Target branch of commit
455
455
  * @param {CommitFilter} filter Callback function that returns whether a
456
456
  * commit/pull request matches certain criteria
457
- * @param {number} maxResults Limit the number of results searched.
457
+ * @param {CommitIteratorOptions} options Query options
458
+ * @param {number} options.maxResults Limit the number of results searched.
458
459
  * Defaults to unlimited.
460
+ * @param {boolean} options.backfillFiles If set, use the REST API for
461
+ * fetching the list of touched files in this commit. Defaults to `false`.
459
462
  * @returns {Commit[]} List of commits to current branch
460
463
  * @throws {GitHubAPIError} on an API error
461
464
  */
462
- async commitsSince(targetBranch, filter, maxResults = Number.MAX_SAFE_INTEGER) {
465
+ async commitsSince(targetBranch, filter, options = {}) {
463
466
  const commits = [];
464
- const generator = this.mergeCommitIterator(targetBranch, maxResults);
467
+ const generator = this.mergeCommitIterator(targetBranch, options);
465
468
  for await (const commit of generator) {
466
469
  if (filter(commit)) {
467
470
  break;
@@ -474,16 +477,21 @@ class GitHub {
474
477
  * Iterate through commit history with a max number of results scanned.
475
478
  *
476
479
  * @param {string} targetBranch target branch of commit
477
- * @param {number} maxResults maxResults - Limit the number of results searched.
480
+ * @param {CommitIteratorOptions} options Query options
481
+ * @param {number} options.maxResults Limit the number of results searched.
478
482
  * Defaults to unlimited.
483
+ * @param {boolean} options.backfillFiles If set, use the REST API for
484
+ * fetching the list of touched files in this commit. Defaults to `false`.
479
485
  * @yields {Commit}
480
486
  * @throws {GitHubAPIError} on an API error
481
487
  */
482
- async *mergeCommitIterator(targetBranch, maxResults = Number.MAX_SAFE_INTEGER) {
488
+ async *mergeCommitIterator(targetBranch, options = {}) {
489
+ var _a;
490
+ const maxResults = (_a = options.maxResults) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER;
483
491
  let cursor = undefined;
484
492
  let results = 0;
485
493
  while (results < maxResults) {
486
- const response = await this.mergeCommitsGraphQL(targetBranch, cursor);
494
+ const response = await this.mergeCommitsGraphQL(targetBranch, cursor, options);
487
495
  // no response usually means that the branch can't be found
488
496
  if (!response) {
489
497
  break;
@@ -498,7 +506,7 @@ class GitHub {
498
506
  cursor = response.pageInfo.endCursor;
499
507
  }
500
508
  }
501
- async mergeCommitsGraphQL(targetBranch, cursor) {
509
+ async mergeCommitsGraphQL(targetBranch, cursor, options = {}) {
502
510
  logger_1.logger.debug(`Fetching merge commits on branch ${targetBranch} with cursor: ${cursor}`);
503
511
  const response = await this.graphqlRequest({
504
512
  query: `query pullRequestsSince($owner: String!, $repo: String!, $num: Int!, $maxFilesChanged: Int, $targetBranch: String!, $cursor: String) {
@@ -566,7 +574,6 @@ class GitHub {
566
574
  const commit = {
567
575
  sha: graphCommit.sha,
568
576
  message: graphCommit.message,
569
- files: [],
570
577
  };
571
578
  const pullRequest = graphCommit.associatedPullRequests.nodes.find(pr => {
572
579
  return pr.mergeCommit && pr.mergeCommit.oid === graphCommit.sha;
@@ -587,7 +594,7 @@ class GitHub {
587
594
  // information for commits with associated pull requests
588
595
  commit.files = files;
589
596
  }
590
- else {
597
+ else if (options.backfillFiles) {
591
598
  // In this case, there is no squashed merge commit. This could be a simple
592
599
  // merge commit, a rebase merge commit, or a direct commit to the branch.
593
600
  // Fallback to fetching the list of commits from the REST API. In the future
@@ -708,14 +715,17 @@ class GitHub {
708
715
  };
709
716
  }
710
717
  /**
711
- * Iterate through merged pull requests with a max number of results scanned.
718
+ * Iterate through releases with a max number of results scanned.
712
719
  *
713
- * @param {number} maxResults maxResults - Limit the number of results searched.
720
+ * @param {ReleaseIteratorOptions} options Query options
721
+ * @param {number} options.maxResults Limit the number of results searched.
714
722
  * Defaults to unlimited.
715
723
  * @yields {GitHubRelease}
716
724
  * @throws {GitHubAPIError} on an API error
717
725
  */
718
- async *releaseIterator(maxResults = Number.MAX_SAFE_INTEGER) {
726
+ async *releaseIterator(options = {}) {
727
+ var _a;
728
+ const maxResults = (_a = options.maxResults) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER;
719
729
  let results = 0;
720
730
  let cursor = undefined;
721
731
  while (true) {
@@ -789,6 +799,33 @@ class GitHub {
789
799
  }),
790
800
  };
791
801
  }
802
+ /**
803
+ * Iterate through tags with a max number of results scanned.
804
+ *
805
+ * @param {TagIteratorOptions} options Query options
806
+ * @param {number} options.maxResults Limit the number of results searched.
807
+ * Defaults to unlimited.
808
+ * @yields {GitHubTag}
809
+ * @throws {GitHubAPIError} on an API error
810
+ */
811
+ async *tagIterator(options = {}) {
812
+ const maxResults = options.maxResults || Number.MAX_SAFE_INTEGER;
813
+ let results = 0;
814
+ for await (const response of this.octokit.paginate.iterator(this.octokit.rest.repos.listTags, {
815
+ owner: this.repository.owner,
816
+ repo: this.repository.repo,
817
+ })) {
818
+ for (const tag of response.data) {
819
+ if ((results += 1) > maxResults) {
820
+ break;
821
+ }
822
+ yield {
823
+ name: tag.name,
824
+ sha: tag.commit.sha,
825
+ };
826
+ }
827
+ }
828
+ }
792
829
  /**
793
830
  * Fetch the contents of a file from the configured branch
794
831
  *