gha-utils 4.4.5__py3-none-any.whl → 4.5.0__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 +1 -1
- gha_utils/changelog.py +4 -8
- gha_utils/cli.py +16 -25
- gha_utils/metadata.py +1 -1
- {gha_utils-4.4.5.dist-info → gha_utils-4.5.0.dist-info}/METADATA +8 -8
- gha_utils-4.5.0.dist-info/RECORD +12 -0
- {gha_utils-4.4.5.dist-info → gha_utils-4.5.0.dist-info}/WHEEL +1 -1
- gha_utils-4.4.5.dist-info/RECORD +0 -12
- {gha_utils-4.4.5.dist-info → gha_utils-4.5.0.dist-info}/entry_points.txt +0 -0
- {gha_utils-4.4.5.dist-info → gha_utils-4.5.0.dist-info}/top_level.txt +0 -0
gha_utils/__init__.py
CHANGED
gha_utils/changelog.py
CHANGED
|
@@ -112,15 +112,15 @@ class Changelog:
|
|
|
112
112
|
SECTION_START = "##"
|
|
113
113
|
sections = self.content.split(SECTION_START, 2)
|
|
114
114
|
changelog_header = sections[0] if len(sections) > 0 else "# Changelog\n\n"
|
|
115
|
-
|
|
116
|
-
past_entries = sections[2] if len(sections) > 2 else ""
|
|
115
|
+
current_entry = f"{SECTION_START}{sections[1]}" if len(sections) > 1 else ""
|
|
116
|
+
past_entries = f"{SECTION_START}{sections[2]}" if len(sections) > 2 else ""
|
|
117
117
|
|
|
118
118
|
# Derive the release template from the last entry.
|
|
119
119
|
DATE_REGEX = r"\d{4}\-\d{2}\-\d{2}"
|
|
120
120
|
VERSION_REGEX = r"\d+\.\d+\.\d+"
|
|
121
121
|
|
|
122
122
|
# Replace the release date with the unreleased tag.
|
|
123
|
-
new_entry = re.sub(DATE_REGEX, "unreleased",
|
|
123
|
+
new_entry = re.sub(DATE_REGEX, "unreleased", current_entry, count=1)
|
|
124
124
|
|
|
125
125
|
# Update GitHub's comparison URL to target the main branch.
|
|
126
126
|
new_entry = re.sub(
|
|
@@ -141,16 +141,12 @@ class Changelog:
|
|
|
141
141
|
new_entry,
|
|
142
142
|
flags=re.MULTILINE | re.DOTALL,
|
|
143
143
|
)
|
|
144
|
-
|
|
145
|
-
# Prefix entries with section marker.
|
|
146
144
|
new_entry = f"{SECTION_START}{new_entry}"
|
|
147
|
-
history = f"{SECTION_START}{recent_entry}{SECTION_START}{past_entries}"
|
|
148
|
-
|
|
149
145
|
logging.info("New generated section:\n" + indent(new_entry, " " * 2))
|
|
150
146
|
|
|
151
147
|
# No need to update.
|
|
148
|
+
history = f"{current_entry}{past_entries}"
|
|
152
149
|
if new_entry in history:
|
|
153
150
|
return None
|
|
154
|
-
|
|
155
151
|
# Recompose full changelog with new top entry.
|
|
156
152
|
return f"{changelog_header}{new_entry}{history}"
|
gha_utils/cli.py
CHANGED
|
@@ -19,7 +19,6 @@ from __future__ import annotations
|
|
|
19
19
|
import logging
|
|
20
20
|
import os
|
|
21
21
|
import sys
|
|
22
|
-
from contextlib import contextmanager
|
|
23
22
|
from datetime import datetime
|
|
24
23
|
from pathlib import Path
|
|
25
24
|
|
|
@@ -27,6 +26,7 @@ from click_extra import (
|
|
|
27
26
|
Choice,
|
|
28
27
|
Context,
|
|
29
28
|
argument,
|
|
29
|
+
echo,
|
|
30
30
|
extra_group,
|
|
31
31
|
file_path,
|
|
32
32
|
option,
|
|
@@ -40,20 +40,14 @@ from .mailmap import Mailmap
|
|
|
40
40
|
from .metadata import Dialects, Metadata
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
def is_stdout(filepath):
|
|
43
|
+
def is_stdout(filepath: Path) -> bool:
|
|
44
44
|
return str(filepath) == "-"
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
def file_writer(filepath):
|
|
49
|
-
"""A context-aware file writer which default to stdout if no path is
|
|
50
|
-
provided."""
|
|
47
|
+
def handle_stdout(filepath: Path) -> Path | None:
|
|
51
48
|
if is_stdout(filepath):
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
writer = filepath.open("w")
|
|
55
|
-
yield writer
|
|
56
|
-
writer.close()
|
|
49
|
+
return None
|
|
50
|
+
return filepath
|
|
57
51
|
|
|
58
52
|
|
|
59
53
|
def generate_header(ctx: Context) -> str:
|
|
@@ -78,10 +72,12 @@ def remove_header(content: str) -> str:
|
|
|
78
72
|
if still_in_header:
|
|
79
73
|
# We are still in the header as long as we have blank lines or we have
|
|
80
74
|
# comment lines matching the format produced by the method above.
|
|
81
|
-
if not line.strip() or line.startswith(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
if not line.strip() or line.startswith(
|
|
76
|
+
(
|
|
77
|
+
"# Generated by ",
|
|
78
|
+
"# Timestamp: ",
|
|
79
|
+
)
|
|
80
|
+
):
|
|
85
81
|
continue
|
|
86
82
|
else:
|
|
87
83
|
still_in_header = False
|
|
@@ -161,9 +157,7 @@ def metadata(ctx, format, overwrite, output_path):
|
|
|
161
157
|
|
|
162
158
|
dialect = Dialects(format)
|
|
163
159
|
content = metadata.dump(dialect=dialect)
|
|
164
|
-
|
|
165
|
-
with file_writer(output_path) as f:
|
|
166
|
-
f.write(content)
|
|
160
|
+
echo(content, file=handle_stdout(output_path))
|
|
167
161
|
|
|
168
162
|
|
|
169
163
|
@gha_utils.command(short_help="Maintain a Markdown-formatted changelog")
|
|
@@ -183,7 +177,7 @@ def changelog(ctx, source, changelog_path):
|
|
|
183
177
|
initial_content = None
|
|
184
178
|
if source:
|
|
185
179
|
logging.info(f"Read initial changelog from {source}")
|
|
186
|
-
initial_content = source.read_text(encoding="
|
|
180
|
+
initial_content = source.read_text(encoding="UTF-8")
|
|
187
181
|
|
|
188
182
|
changelog = Changelog(initial_content)
|
|
189
183
|
content = changelog.update()
|
|
@@ -195,9 +189,7 @@ def changelog(ctx, source, changelog_path):
|
|
|
195
189
|
logging.info(f"Print updated results to {sys.stdout.name}")
|
|
196
190
|
else:
|
|
197
191
|
logging.info(f"Save updated results to {changelog_path}")
|
|
198
|
-
|
|
199
|
-
with file_writer(changelog_path) as f:
|
|
200
|
-
f.write(content)
|
|
192
|
+
echo(content, file=handle_stdout(changelog_path))
|
|
201
193
|
|
|
202
194
|
|
|
203
195
|
@gha_utils.command(short_help="Update Git's .mailmap file with missing contributors")
|
|
@@ -245,7 +237,7 @@ def mailmap_sync(ctx, source, create_if_missing, destination_mailmap):
|
|
|
245
237
|
|
|
246
238
|
if source.exists():
|
|
247
239
|
logging.info(f"Read initial mapping from {source}")
|
|
248
|
-
content = remove_header(source.read_text(encoding="
|
|
240
|
+
content = remove_header(source.read_text(encoding="UTF-8"))
|
|
249
241
|
mailmap.parse(content)
|
|
250
242
|
else:
|
|
251
243
|
logging.debug(f"Mailmap source file {source} does not exists.")
|
|
@@ -271,5 +263,4 @@ def mailmap_sync(ctx, source, create_if_missing, destination_mailmap):
|
|
|
271
263
|
logging.warning("Nothing to update, stop the sync process.")
|
|
272
264
|
ctx.exit()
|
|
273
265
|
|
|
274
|
-
|
|
275
|
-
f.write(generate_header(ctx) + new_content)
|
|
266
|
+
echo(generate_header(ctx) + new_content, file=handle_stdout(destination_mailmap))
|
gha_utils/metadata.py
CHANGED
|
@@ -267,7 +267,7 @@ class Metadata:
|
|
|
267
267
|
env:
|
|
268
268
|
GITHUB_CONTEXT: ${{ toJSON(github) }}
|
|
269
269
|
run: |
|
|
270
|
-
|
|
270
|
+
gha-utils --verbosity DEBUG metadata --overwrite "$GITHUB_OUTPUT"
|
|
271
271
|
|
|
272
272
|
.. todo::
|
|
273
273
|
Try to remove reliance on GitHub context entirely so we can eliminate the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: gha-utils
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.5.0
|
|
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
|
|
@@ -90,11 +90,11 @@ Nothing is done behind your back. A PR is created everytime a change is proposed
|
|
|
90
90
|
|
|
91
91
|
Standalone executables of `gha-utils`'s latest version are available as direct downloads for several platforms and architectures:
|
|
92
92
|
|
|
93
|
-
| Platform
|
|
94
|
-
|
|
|
95
|
-
| **Linux**
|
|
96
|
-
| **macOS**
|
|
97
|
-
| **Windows**
|
|
93
|
+
| Platform | `x86_64` | `arm64` |
|
|
94
|
+
| ----------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
95
|
+
| **Linux** | [Download `gha-utils-linux-x64.bin`](https://github.com/kdeldycke/workflows/releases/latest/download/gha-utils-linux-x64.bin) | |
|
|
96
|
+
| **macOS** | [Download `gha-utils-macos-x64.bin`](https://github.com/kdeldycke/workflows/releases/latest/download/gha-utils-macos-x64.bin) | [Download `gha-utils-macos-arm64.bin`](https://github.com/kdeldycke/workflows/releases/latest/download/gha-utils-macos-arm64.bin) |
|
|
97
|
+
| **Windows** | [Download `gha-utils-windows-x64.exe`](https://github.com/kdeldycke/workflows/releases/latest/download/gha-utils-windows-x64.exe) | |
|
|
98
98
|
|
|
99
99
|
### Run dev version
|
|
100
100
|
|
|
@@ -216,7 +216,7 @@ You will always end up with this kind or errors:
|
|
|
216
216
|
error: failed to push some refs to 'https://github.com/kdeldycke/my-repo'
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
-
>
|
|
219
|
+
> [!NOTE]
|
|
220
220
|
> That's also why the Settings > Actions > General > Workflow permissions parameter on your repository has no effect on this issue, even with the `Read and write permissions` set:
|
|
221
221
|
> 
|
|
222
222
|
|
|
@@ -233,7 +233,7 @@ To create this custom `WORKFLOW_UPDATE_GITHUB_PAT`:
|
|
|
233
233
|
- `Metadata` (mandatory): `Access: **Read-only**`
|
|
234
234
|
- `Pull Requests`: `Access: **Read and Write**`
|
|
235
235
|
- `Workflows`: `Access: **Read and Write**`
|
|
236
|
-
>
|
|
236
|
+
> [!NOTE]
|
|
237
237
|
> This is the only place where I can have control over the `Workflows` permission, which is not supported by the `permissions:` parameter in YAML files.
|
|
238
238
|
- Now save these parameters and copy the `github_pat_XXXX` secret token
|
|
239
239
|
- Got to your repo > `Settings` > `Security` > `Secrets and variables` > `Actions` > `Secrets` > `Repository secrets` and click `New repository secrets`
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
gha_utils/__init__.py,sha256=2hpwFw1Fxf-LQg9Elgz4VZow1ivxy9LI5LEfSKa3mQY,865
|
|
2
|
+
gha_utils/__main__.py,sha256=Dck9BjpLXmIRS83k0mghAMcYVYiMiFLltQdfRuMSP_Q,1703
|
|
3
|
+
gha_utils/changelog.py,sha256=-Iek7GkoM2MhUVQ_CloQzSMMUvX0TfDLytbDuZmrPRs,5923
|
|
4
|
+
gha_utils/cli.py,sha256=WE8Pi4Ga3S_2cn2u2RT7XC6ngrXhrQE4UnFwNOPW6Ec,8976
|
|
5
|
+
gha_utils/mailmap.py,sha256=sum4XIme2Dis7XtHyO9U7ogWelZwqb-yvJ5I92PPnqg,6301
|
|
6
|
+
gha_utils/metadata.py,sha256=FLkNjjAlB3FieMgvbtBQwWnA7tE6APEGnGHgbe8gbZg,47203
|
|
7
|
+
gha_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
gha_utils-4.5.0.dist-info/METADATA,sha256=HfmzzdwWWdQ6kyXh0T_rsTJIZdK9KMZMemCaTg8CnHs,17976
|
|
9
|
+
gha_utils-4.5.0.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
|
|
10
|
+
gha_utils-4.5.0.dist-info/entry_points.txt,sha256=8bJOwQYf9ZqsLhBR6gUCzvwLNI9f8tiiBrJ3AR0EK4o,54
|
|
11
|
+
gha_utils-4.5.0.dist-info/top_level.txt,sha256=C94Blb61YkkyPBwCdM3J_JPDjWH0lnKa5nGZeZ5M6yE,10
|
|
12
|
+
gha_utils-4.5.0.dist-info/RECORD,,
|
gha_utils-4.4.5.dist-info/RECORD
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
gha_utils/__init__.py,sha256=QBMQJ3ouEfz5WZFuN6QGlA8qM7VUlElMMuR7YamFzWw,865
|
|
2
|
-
gha_utils/__main__.py,sha256=Dck9BjpLXmIRS83k0mghAMcYVYiMiFLltQdfRuMSP_Q,1703
|
|
3
|
-
gha_utils/changelog.py,sha256=KuM323SslStwh25fuEiom39t1kfcgwxHAwi6KNy0Lhk,5959
|
|
4
|
-
gha_utils/cli.py,sha256=4wUG29fB0-Z-n105UBgIg5NLuqtODtoMLwKJP7RQFXo,9150
|
|
5
|
-
gha_utils/mailmap.py,sha256=sum4XIme2Dis7XtHyO9U7ogWelZwqb-yvJ5I92PPnqg,6301
|
|
6
|
-
gha_utils/metadata.py,sha256=d7s3_wlWweIxvv5xvtnKg_ohqojRF8eVBR2U5PxHUlA,47224
|
|
7
|
-
gha_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
gha_utils-4.4.5.dist-info/METADATA,sha256=QKk6F3Y4yLI_W-UFodlLep6_FRjO3ASH_FjDPJSFfVQ,17996
|
|
9
|
-
gha_utils-4.4.5.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
|
|
10
|
-
gha_utils-4.4.5.dist-info/entry_points.txt,sha256=8bJOwQYf9ZqsLhBR6gUCzvwLNI9f8tiiBrJ3AR0EK4o,54
|
|
11
|
-
gha_utils-4.4.5.dist-info/top_level.txt,sha256=C94Blb61YkkyPBwCdM3J_JPDjWH0lnKa5nGZeZ5M6yE,10
|
|
12
|
-
gha_utils-4.4.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|