release-please 15.6.0 → 15.7.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/release-please?activeTab=versions
6
6
 
7
+ ## [15.7.0](https://github.com/googleapis/release-please/compare/v15.6.0...v15.7.0) (2023-02-07)
8
+
9
+
10
+ ### Features
11
+
12
+ * **changelog.json:** Implement changelog.json for python ([#1841](https://github.com/googleapis/release-please/issues/1841)) ([52594b1](https://github.com/googleapis/release-please/commit/52594b194fdd0ae516776128e6511d5e4cd21518))
13
+
7
14
  ## [15.6.0](https://github.com/googleapis/release-please/compare/v15.5.1...v15.6.0) (2023-02-01)
8
15
 
9
16
 
@@ -5,5 +5,7 @@ export declare class Python extends BaseStrategy {
5
5
  constructor(options: BaseStrategyOptions);
6
6
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
7
7
  private getPyProject;
8
+ protected getNameFromSetupPy(): Promise<string | null>;
9
+ protected getSetupPyContents(): Promise<string | null>;
8
10
  protected initialReleaseVersion(): Version;
9
11
  }
@@ -16,11 +16,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.Python = void 0;
17
17
  const base_1 = require("./base");
18
18
  const changelog_1 = require("../updaters/changelog");
19
+ const changelog_json_1 = require("../updaters/changelog-json");
19
20
  const version_1 = require("../version");
20
21
  const setup_cfg_1 = require("../updaters/python/setup-cfg");
21
22
  const setup_py_1 = require("../updaters/python/setup-py");
22
23
  const pyproject_toml_1 = require("../updaters/python/pyproject-toml");
23
24
  const python_file_with_version_1 = require("../updaters/python/python-file-with-version");
25
+ const errors_1 = require("../errors");
26
+ const filter_commits_1 = require("../util/filter-commits");
24
27
  const CHANGELOG_SECTIONS = [
25
28
  { type: 'feat', section: 'Features' },
26
29
  { type: 'fix', section: 'Bug Fixes' },
@@ -112,6 +115,21 @@ class Python extends base_1.BaseStrategy {
112
115
  }),
113
116
  });
114
117
  });
118
+ // If a machine readable changelog.json exists update it:
119
+ const artifactName = projectName !== null && projectName !== void 0 ? projectName : (await this.getNameFromSetupPy());
120
+ if (options.commits && artifactName) {
121
+ const commits = (0, filter_commits_1.filterCommits)(options.commits, this.changelogSections);
122
+ updates.push({
123
+ path: 'changelog.json',
124
+ createIfMissing: false,
125
+ updater: new changelog_json_1.ChangelogJson({
126
+ artifactName,
127
+ version,
128
+ commits,
129
+ language: 'PYTHON',
130
+ }),
131
+ });
132
+ }
115
133
  return updates;
116
134
  }
117
135
  async getPyProject(path) {
@@ -123,6 +141,31 @@ class Python extends base_1.BaseStrategy {
123
141
  return null;
124
142
  }
125
143
  }
144
+ async getNameFromSetupPy() {
145
+ var _a;
146
+ const ARTIFACT_NAME_REGEX = /name *= *['"](?<name>.*)['"](\r|\n|$)/;
147
+ const setupPyContents = await this.getSetupPyContents();
148
+ if (setupPyContents) {
149
+ const match = setupPyContents.match(ARTIFACT_NAME_REGEX);
150
+ if (match && ((_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.name)) {
151
+ return match.groups.name;
152
+ }
153
+ }
154
+ return null;
155
+ }
156
+ async getSetupPyContents() {
157
+ try {
158
+ return (await this.github.getFileContentsOnBranch(this.addPath('setup.py'), this.targetBranch)).parsedContent;
159
+ }
160
+ catch (e) {
161
+ if (e instanceof errors_1.FileNotFoundError) {
162
+ return null;
163
+ }
164
+ else {
165
+ throw e;
166
+ }
167
+ }
168
+ }
126
169
  initialReleaseVersion() {
127
170
  return version_1.Version.parse('0.1.0');
128
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "15.6.0",
3
+ "version": "15.7.0",
4
4
  "description": "generate release PRs based on the conventionalcommits.org spec",
5
5
  "main": "./build/src/index.js",
6
6
  "bin": "./build/src/bin/release-please.js",