gha-utils 4.4.5__tar.gz → 4.5.0__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.

Potentially problematic release.


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

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gha-utils
3
- Version: 4.4.5
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 | `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) | |
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
- > \[!NOTE\]
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
  > ![](docs/assets/repo-workflow-permissions.png)
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
- > \[!NOTE\]
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`
@@ -17,4 +17,4 @@
17
17
 
18
18
  from __future__ import annotations
19
19
 
20
- __version__ = "4.4.5"
20
+ __version__ = "4.5.0"
@@ -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
- recent_entry = sections[1] if len(sections) > 1 else ""
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", recent_entry, count=1)
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}"
@@ -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
- @contextmanager
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
- yield sys.stdout
53
- else:
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
- "# Generated by ",
83
- "# Timestamp: ",
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="utf-8")
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="utf-8"))
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
- with file_writer(destination_mailmap) as f:
275
- f.write(generate_header(ctx) + new_content)
266
+ echo(generate_header(ctx) + new_content, file=handle_stdout(destination_mailmap))
@@ -267,7 +267,7 @@ class Metadata:
267
267
  env:
268
268
  GITHUB_CONTEXT: ${{ toJSON(github) }}
269
269
  run: |
270
- uv --no-progress run gha-utils --verbosity DEBUG metadata --overwrite "$GITHUB_OUTPUT"
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.4.5
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 | `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) | |
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
- > \[!NOTE\]
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
  > ![](docs/assets/repo-workflow-permissions.png)
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
- > \[!NOTE\]
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`
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  # Docs: https://packaging.python.org/en/latest/guides/writing-pyproject-toml/
3
3
  name = "gha-utils"
4
- version = "4.4.5"
4
+ version = "4.5.0"
5
5
  # Python versions and their status: https://devguide.python.org/versions/
6
6
  requires-python = ">= 3.9"
7
7
  description = "⚙️ CLI helpers for GitHub Actions + reuseable workflows"
@@ -106,7 +106,7 @@ warn_unreachable = true
106
106
  pretty = true
107
107
 
108
108
  [tool.bumpversion]
109
- current_version = "4.4.5"
109
+ current_version = "4.5.0"
110
110
  allow_dirty = true
111
111
  ignore_missing_files = true
112
112
 
@@ -33,11 +33,11 @@ Nothing is done behind your back. A PR is created everytime a change is proposed
33
33
 
34
34
  Standalone executables of `gha-utils`'s latest version are available as direct downloads for several platforms and architectures:
35
35
 
36
- | Platform | `x86_64` | `arm64` |
37
- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
38
- | **Linux** | [Download `gha-utils-linux-x64.bin`](https://github.com/kdeldycke/workflows/releases/latest/download/gha-utils-linux-x64.bin) | |
39
- | **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) |
40
- | **Windows** | [Download `gha-utils-windows-x64.exe`](https://github.com/kdeldycke/workflows/releases/latest/download/gha-utils-windows-x64.exe) | |
36
+ | Platform | `x86_64` | `arm64` |
37
+ | ----------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
38
+ | **Linux** | [Download `gha-utils-linux-x64.bin`](https://github.com/kdeldycke/workflows/releases/latest/download/gha-utils-linux-x64.bin) | |
39
+ | **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) |
40
+ | **Windows** | [Download `gha-utils-windows-x64.exe`](https://github.com/kdeldycke/workflows/releases/latest/download/gha-utils-windows-x64.exe) | |
41
41
 
42
42
  ### Run dev version
43
43
 
@@ -159,7 +159,7 @@ You will always end up with this kind or errors:
159
159
  error: failed to push some refs to 'https://github.com/kdeldycke/my-repo'
160
160
  ```
161
161
 
162
- > \[!NOTE\]
162
+ > [!NOTE]
163
163
  > 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:
164
164
  > ![](docs/assets/repo-workflow-permissions.png)
165
165
 
@@ -176,7 +176,7 @@ To create this custom `WORKFLOW_UPDATE_GITHUB_PAT`:
176
176
  - `Metadata` (mandatory): `Access: **Read-only**`
177
177
  - `Pull Requests`: `Access: **Read and Write**`
178
178
  - `Workflows`: `Access: **Read and Write**`
179
- > \[!NOTE\]
179
+ > [!NOTE]
180
180
  > 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.
181
181
  - Now save these parameters and copy the `github_pat_XXXX` secret token
182
182
  - Got to your repo > `Settings` > `Security` > `Secrets and variables` > `Actions` > `Secrets` > `Repository secrets` and click `New repository secrets`
File without changes
File without changes