tag-publish 1.3.0.dev23__tar.gz → 1.4.0.dev2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tag-publish
3
- Version: 1.3.0.dev23
3
+ Version: 1.4.0.dev2
4
4
  Summary: Tools used to publish Python packages, Docker images and Helm charts for GitHub tag and branch
5
5
  License: FreeBSD
6
6
  License-File: LICENSE
@@ -96,7 +96,7 @@ include = [
96
96
  ]
97
97
  requires-python = ">=3.11"
98
98
  dependencies = ["PyYAML<7,>=6", "security-md<2,>=1", "githubkit<1,>=0"]
99
- version = "1.3.0.dev23"
99
+ version = "1.4.0.dev2"
100
100
 
101
101
  [project.optional-dependencies]
102
102
  pypi = ["requests<3,>=2", "twine<7,>=6", "id<2,>=1"]
@@ -59,8 +59,11 @@ def get_dpkg_packages_versions(
59
59
  print(f"Found distribution '{distribution_final}', release '{release_final}'.")
60
60
 
61
61
  package_version: dict[str, Version] = {}
62
+ # `dpkg --status` without a package name is refused by the old dpkg of Ubuntu 18.04
63
+ # (`dpkg-query: error: --status needs at least one package name argument`), the status database
64
+ # is read directly, it is what `dpkg --status` prints.
62
65
  packages_status_process = subprocess.run(
63
- ["docker", "run", "--rm", "--entrypoint=", image, "dpkg", "--status"],
66
+ ["docker", "run", "--rm", "--entrypoint=", image, "cat", "/var/lib/dpkg/status"],
64
67
  stdout=subprocess.PIPE,
65
68
  check=True,
66
69
  )
@@ -25,11 +25,15 @@ def main() -> None:
25
25
  """Create a new version with its stabilization branch."""
26
26
  tag_publish.require_extra("new", "multi_repo_automation", "ruamel.yaml")
27
27
  # Imported here because they are optional dependencies provided by the `new` extra.
28
- import multi_repo_automation as mra # noqa: PLC0415
29
28
  import ruamel.yaml # noqa: PLC0415
30
29
  import ruamel.yaml.comments # noqa: PLC0415
31
30
  import ruamel.yaml.error # noqa: PLC0415
32
31
 
32
+ # The top level aliases (gh, gh_json, get_repo_config, EditRenovateConfig, ...) have been
33
+ # removed in multi-repo-automation 1.8, use the sub modules present since 1.7.0.
34
+ from multi_repo_automation import editor as mra_editor # noqa: PLC0415
35
+ from multi_repo_automation import tools as mra_tools # noqa: PLC0415
36
+
33
37
  args_parser = argparse.ArgumentParser(
34
38
  description="Create a new version with its stabilization branch",
35
39
  usage="""
@@ -85,7 +89,7 @@ regarding the SECURITY.md available on GitHub.
85
89
  # "dir": "/home/user/src/tag_publish",
86
90
  # }
87
91
  # can be override with a repo.yaml file
88
- repo = mra.get_repo_config()
92
+ repo = mra_tools.get_repo_config()
89
93
 
90
94
  # Stash all your changes
91
95
  subprocess.run(["git", "stash", "--all", "--message=Stashed by release creation"], check=True)
@@ -168,7 +172,7 @@ regarding the SECURITY.md available on GitHub.
168
172
 
169
173
  if Path("SECURITY.md").exists():
170
174
  modified_files.append("SECURITY.md")
171
- with mra.Edit("SECURITY.md") as security_md_file:
175
+ with mra_editor.Edit(Path("SECURITY.md")) as security_md_file:
172
176
  security_md_lines = security_md_file.data.split("\n")
173
177
  index = -1
174
178
  for i, line in enumerate(security_md_lines):
@@ -185,15 +189,15 @@ regarding the SECURITY.md available on GitHub.
185
189
 
186
190
  stabilization_branches_with_master = [*stabilization_branches, default_branch]
187
191
 
188
- for labels in mra.gh_json("label", ["name"], "list"):
192
+ for labels in mra_tools.gh_json("label", ["name"], "list"):
189
193
  if (
190
194
  labels["name"].startswith("backport ")
191
195
  and labels["name"].replace("backport ", "") not in stabilization_branches_with_master
192
196
  ):
193
- mra.gh("label", "delete", labels["name"], "--yes")
197
+ mra_tools.gh("label", "delete", labels["name"], "--yes")
194
198
 
195
199
  for branch in stabilization_branches_with_master:
196
- mra.gh(
200
+ mra_tools.gh(
197
201
  "label",
198
202
  "create",
199
203
  "--force",
@@ -204,9 +208,15 @@ regarding the SECURITY.md available on GitHub.
204
208
 
205
209
  if Path(".github/renovate.json5").exists():
206
210
  modified_files.append(".github/renovate.json5")
207
- with mra.EditRenovateConfig(".github/renovate.json5") as renovate_config:
211
+ with mra_editor.EditRenovateConfig(Path(".github/renovate.json5")) as renovate_config:
208
212
  if stabilization_branches:
209
- if "baseBranches: " in renovate_config.data:
213
+ if "baseBranchPatterns: " in renovate_config.data:
214
+ renovate_config.data = re.sub(
215
+ r"(.*baseBranchPatterns: )\[[^\]]*\](.*)",
216
+ rf"\1{json.dumps(stabilization_branches_with_master)}\2",
217
+ renovate_config.data,
218
+ )
219
+ elif "baseBranches: " in renovate_config.data:
210
220
  renovate_config.data = re.sub(
211
221
  r"(.*baseBranches: )\[[^\]]*\](.*)",
212
222
  rf"\1{json.dumps(stabilization_branches_with_master)}\2",
@@ -220,7 +230,7 @@ regarding the SECURITY.md available on GitHub.
220
230
 
221
231
  if stabilization_branches and Path(".github/workflows/audit.yaml").exists():
222
232
  modified_files.append(".github/workflows/audit.yaml")
223
- with mra.EditYAML(".github/workflows/audit.yaml") as yaml:
233
+ with mra_editor.EditYAML(Path(".github/workflows/audit.yaml")) as yaml:
224
234
  for job in yaml["jobs"].values():
225
235
  matrix = job.get("strategy", {}).get("matrix", {})
226
236
  if "include" in matrix and version:
@@ -261,7 +271,7 @@ regarding the SECURITY.md available on GitHub.
261
271
  )
262
272
 
263
273
  # Create a pull request
264
- url = mra.gh(
274
+ url = mra_tools.gh(
265
275
  "pr",
266
276
  "create",
267
277
  f"--title={message}",
@@ -275,9 +285,9 @@ regarding the SECURITY.md available on GitHub.
275
285
 
276
286
  if url:
277
287
  pr_number = url.rsplit("/", 1)[-1]
278
- mra.gh("browse", pr_number)
288
+ mra_tools.gh("browse", pr_number)
279
289
  else:
280
- mra.gh("browse")
290
+ mra_tools.gh("browse")
281
291
 
282
292
 
283
293
  if __name__ == "__main__":