gha-utils 4.5.1__py3-none-any.whl → 4.5.3__py3-none-any.whl

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.

Potentially problematic release.


This version of gha-utils might be problematic. Click here for more details.

gha_utils/__init__.py CHANGED
@@ -17,4 +17,4 @@
17
17
 
18
18
  from __future__ import annotations
19
19
 
20
- __version__ = "4.5.1"
20
+ __version__ = "4.5.3"
gha_utils/changelog.py CHANGED
@@ -19,6 +19,7 @@ from __future__ import annotations
19
19
  import logging
20
20
  import re
21
21
  import sys
22
+ from functools import cached_property
22
23
  from pathlib import Path
23
24
  from textwrap import indent
24
25
 
@@ -38,10 +39,20 @@ class Changelog:
38
39
  self.content = initial_changelog
39
40
  logging.debug(f"Initial content set to:\n{self.content}")
40
41
 
41
- def update(self) -> str | None:
42
+ @cached_property
43
+ def current_version(self) -> str | None:
44
+ # Extract current version as defined by bump-my-version.
45
+ config_file = Path("./pyproject.toml").resolve()
46
+ logging.info(f"Open {config_file}")
47
+ config = tomllib.loads(config_file.read_text(encoding="UTF-8"))
48
+ current_version = config["tool"]["bumpversion"]["current_version"]
49
+ logging.info(f"Current version: {current_version}")
50
+ return current_version if current_version else None
51
+
52
+ def update(self) -> str:
42
53
  r"""Adds a new empty entry at the top of the changelog.
43
54
 
44
- Returns ``None`` if initial changelog content has already been updated.
55
+ Will return the same content as the current changelog if it has already been updated.
45
56
 
46
57
  This is designed to be used just after a new release has been tagged. And before a
47
58
  post-release version increment is applied with a call to:
@@ -98,16 +109,6 @@ class Changelog:
98
109
  Would not tag since we are not committing
99
110
  ```
100
111
  """
101
- # Extract current version as defined by bump-my-version.
102
- config_file = Path("./pyproject.toml").resolve()
103
- logging.info(f"Open {config_file}")
104
- config = tomllib.loads(config_file.read_text(encoding="UTF-8"))
105
- current_version = config["tool"]["bumpversion"]["current_version"]
106
- logging.info(f"Current version: {current_version}")
107
- assert current_version
108
-
109
- assert current_version in self.content
110
-
111
112
  # Extract parts of the changelog or set default values.
112
113
  SECTION_START = "##"
113
114
  sections = self.content.split(SECTION_START, 2)
@@ -125,7 +126,7 @@ class Changelog:
125
126
  # Update GitHub's comparison URL to target the main branch.
126
127
  new_entry = re.sub(
127
128
  rf"v{VERSION_REGEX}\.\.\.v{VERSION_REGEX}",
128
- f"v{current_version}...main",
129
+ f"v{self.current_version}...main",
129
130
  new_entry,
130
131
  count=1,
131
132
  )
@@ -141,12 +142,9 @@ class Changelog:
141
142
  new_entry,
142
143
  flags=re.MULTILINE | re.DOTALL,
143
144
  )
144
- new_entry = f"{SECTION_START}{new_entry}"
145
145
  logging.info("New generated section:\n" + indent(new_entry, " " * 2))
146
146
 
147
- # No need to update.
148
- history = f"{current_entry}{past_entries}"
149
- if new_entry in history:
150
- return None
151
- # Recompose full changelog with new top entry.
152
- return f"{changelog_header}{new_entry}{history}"
147
+ history = current_entry + past_entries
148
+ if new_entry not in history:
149
+ history = new_entry + history
150
+ return (changelog_header + history).rstrip()
gha_utils/cli.py CHANGED
@@ -187,7 +187,7 @@ def changelog(ctx, source, changelog_path):
187
187
 
188
188
  changelog = Changelog(initial_content)
189
189
  content = changelog.update()
190
- if not content:
190
+ if content == initial_content:
191
191
  logging.warning("Changelog already up to date. Do nothing.")
192
192
  ctx.exit()
193
193
 
gha_utils/metadata.py CHANGED
@@ -398,11 +398,13 @@ class Metadata:
398
398
  current_version = Metadata.get_current_version()
399
399
 
400
400
  sha_list.append(commit.hash)
401
- include_list.append({
402
- "commit": commit.hash,
403
- "short_sha": commit.hash[:SHORT_SHA_LENGTH],
404
- "current_version": current_version,
405
- })
401
+ include_list.append(
402
+ {
403
+ "commit": commit.hash,
404
+ "short_sha": commit.hash[:SHORT_SHA_LENGTH],
405
+ "current_version": current_version,
406
+ }
407
+ )
406
408
 
407
409
  # Restore the repository to its initial state.
408
410
  if past_commit_lookup:
@@ -412,10 +414,12 @@ class Metadata:
412
414
  logging.debug("Unstash local changes that were previously saved.")
413
415
  git.repo.git.stash("pop")
414
416
 
415
- return Matrix({
416
- "commit": sha_list,
417
- "include": include_list,
418
- })
417
+ return Matrix(
418
+ {
419
+ "commit": sha_list,
420
+ "include": include_list,
421
+ }
422
+ )
419
423
 
420
424
  @cached_property
421
425
  def event_type(self) -> WorkflowEvent | None: # type: ignore[valid-type]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gha-utils
3
- Version: 4.5.1
3
+ Version: 4.5.3
4
4
  Summary: ⚙️ CLI helpers for GitHub Actions + reuseable workflows
5
5
  Author-email: Kevin Deldycke <kevin@deldycke.com>
6
6
  Project-URL: Homepage, https://github.com/kdeldycke/workflows
@@ -54,6 +54,13 @@ Requires-Dist: pyproject-metadata ~=0.8.0
54
54
  Requires-Dist: wcmatch >=8.5
55
55
  Requires-Dist: backports.strenum ~=1.3.1 ; python_version < "3.11"
56
56
  Requires-Dist: tomli ~=2.0.1 ; python_version < "3.11"
57
+ Provides-Extra: test
58
+ Requires-Dist: coverage[toml] ~=7.6.0 ; extra == 'test'
59
+ Requires-Dist: pytest ~=8.3.1 ; extra == 'test'
60
+ Requires-Dist: pytest-cases ~=3.8.3 ; extra == 'test'
61
+ Requires-Dist: pytest-cov ~=5.0.0 ; extra == 'test'
62
+ Requires-Dist: pytest-github-actions-annotate-failures ~=0.2.0 ; extra == 'test'
63
+ Requires-Dist: pytest-randomly ~=3.15.0 ; extra == 'test'
57
64
 
58
65
  # `gha-utils` CLI + reusable workflows
59
66
 
@@ -61,6 +68,7 @@ Requires-Dist: tomli ~=2.0.1 ; python_version < "3.11"
61
68
  [![Python versions](https://img.shields.io/pypi/pyversions/gha-utils.svg)](https://pypi.python.org/pypi/gha-utils)
62
69
  [![Type checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
63
70
  [![Unittests status](https://github.com/kdeldycke/workflows/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/kdeldycke/workflows/actions/workflows/tests.yaml?query=branch%3Amain)
71
+ [![Coverage status](https://codecov.io/gh/kdeldycke/workflows/branch/main/graph/badge.svg)](https://app.codecov.io/gh/kdeldycke/workflows)
64
72
 
65
73
  Thanks to this project, I am able to **release Python packages multiple times a day with only 2-clicks**.
66
74
 
@@ -0,0 +1,12 @@
1
+ gha_utils/__init__.py,sha256=nwJF-TNbGW0vPLIN9UbZJNTT83fXwRXiy1v5k6dKAl4,865
2
+ gha_utils/__main__.py,sha256=Dck9BjpLXmIRS83k0mghAMcYVYiMiFLltQdfRuMSP_Q,1703
3
+ gha_utils/changelog.py,sha256=oahY88A9FRV14f1JSFKIiYrN_TS7Jo3QlljXqJbeuaE,5892
4
+ gha_utils/cli.py,sha256=f1NRPffvgl5waBau8-5twXO7n3By_797npWBR_22XoM,9217
5
+ gha_utils/mailmap.py,sha256=snSQBn1BDZ21783l4yCkQc3RLIxh5X6QCunFRkDj-24,6301
6
+ gha_utils/metadata.py,sha256=MhFzNlx5nE2Z9DI89yPsloik-JL40_yBzO-K1Ly5Vn8,47283
7
+ gha_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ gha_utils-4.5.3.dist-info/METADATA,sha256=CV0NUhzAl7k_A9a3IG-tmcyYT5MPajuMeTcBugOZIH4,18485
9
+ gha_utils-4.5.3.dist-info/WHEEL,sha256=uCRv0ZEik_232NlR4YDw4Pv3Ajt5bKvMH13NUU7hFuI,91
10
+ gha_utils-4.5.3.dist-info/entry_points.txt,sha256=8bJOwQYf9ZqsLhBR6gUCzvwLNI9f8tiiBrJ3AR0EK4o,54
11
+ gha_utils-4.5.3.dist-info/top_level.txt,sha256=C94Blb61YkkyPBwCdM3J_JPDjWH0lnKa5nGZeZ5M6yE,10
12
+ gha_utils-4.5.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (73.0.1)
2
+ Generator: setuptools (74.1.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,12 +0,0 @@
1
- gha_utils/__init__.py,sha256=Lkof_jh0QHaox_62wIshAQPe0bbkcFTLk6wFZyB7wFY,865
2
- gha_utils/__main__.py,sha256=Dck9BjpLXmIRS83k0mghAMcYVYiMiFLltQdfRuMSP_Q,1703
3
- gha_utils/changelog.py,sha256=mcIUIce7ATNZyBeZerTWjDKB_mrReFdDJZJyDPIhS3Y,5915
4
- gha_utils/cli.py,sha256=NlOktO7ddL8fhwkXEB3fVw3Qj-37maWnrYpyL_cKgHw,9202
5
- gha_utils/mailmap.py,sha256=snSQBn1BDZ21783l4yCkQc3RLIxh5X6QCunFRkDj-24,6301
6
- gha_utils/metadata.py,sha256=qdhAH-NHPusWIicoN9Js-7idvkcnJa9wzF4mVi7giPY,47203
7
- gha_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- gha_utils-4.5.1.dist-info/METADATA,sha256=n3ADFMOjC8B5IllUjVzg0eNKzW4lk38-e7gLPcb1JGE,17976
9
- gha_utils-4.5.1.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
10
- gha_utils-4.5.1.dist-info/entry_points.txt,sha256=8bJOwQYf9ZqsLhBR6gUCzvwLNI9f8tiiBrJ3AR0EK4o,54
11
- gha_utils-4.5.1.dist-info/top_level.txt,sha256=C94Blb61YkkyPBwCdM3J_JPDjWH0lnKa5nGZeZ5M6yE,10
12
- gha_utils-4.5.1.dist-info/RECORD,,