gha-utils 4.0.1__py3-none-any.whl → 4.1.1__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.

@@ -0,0 +1,285 @@
1
+ Metadata-Version: 2.1
2
+ Name: gha-utils
3
+ Version: 4.1.1
4
+ Summary: ⚙️ CLI helpers for GitHub Actions + reuseable workflows
5
+ Author-email: Kevin Deldycke <kevin@deldycke.com>
6
+ Project-URL: Homepage, https://github.com/kdeldycke/workflows
7
+ Project-URL: Repository, https://github.com/kdeldycke/workflows
8
+ Project-URL: Funding, https://github.com/sponsors/kdeldycke
9
+ Project-URL: Issues, https://github.com/kdeldycke/workflows/issues
10
+ Project-URL: Changelog, https://github.com/kdeldycke/workflows/blob/main/changelog.md
11
+ Keywords: build-automation,changelog-formatter,ci-cd,cli,formatting,github-actions,labels,linting,markdown,mypy,nuitka,packaging,pypi,python,release-automation,sphinx,sponsorship,terminal,typo,workflow-reusable,yaml
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Environment :: Console
14
+ Classifier: Framework :: Sphinx
15
+ Classifier: Framework :: Pelican
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
18
+ Classifier: Operating System :: MacOS :: MacOS X
19
+ Classifier: Operating System :: Microsoft :: Windows
20
+ Classifier: Operating System :: POSIX :: Linux
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.8
23
+ Classifier: Programming Language :: Python :: 3.9
24
+ Classifier: Programming Language :: Python :: 3.10
25
+ Classifier: Programming Language :: Python :: 3.11
26
+ Classifier: Programming Language :: Python :: 3.12
27
+ Classifier: Programming Language :: Python :: Implementation :: CPython
28
+ Classifier: Programming Language :: Unix Shell
29
+ Classifier: Topic :: Documentation :: Sphinx
30
+ Classifier: Topic :: File Formats :: JSON
31
+ Classifier: Topic :: Security
32
+ Classifier: Topic :: Software Development :: Build Tools
33
+ Classifier: Topic :: Software Development :: Compilers
34
+ Classifier: Topic :: Software Development :: Documentation
35
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
36
+ Classifier: Topic :: Software Development :: Quality Assurance
37
+ Classifier: Topic :: Software Development :: Version Control :: Git
38
+ Classifier: Topic :: System :: Archiving :: Packaging
39
+ Classifier: Topic :: System :: Installation/Setup
40
+ Classifier: Topic :: System :: Shells
41
+ Classifier: Topic :: System :: Software Distribution
42
+ Classifier: Topic :: Terminals
43
+ Classifier: Topic :: Text Processing :: Markup :: HTML
44
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
45
+ Classifier: Topic :: Utilities
46
+ Classifier: Typing :: Typed
47
+ Requires-Python: >=3.8.6
48
+ Description-Content-Type: text/markdown
49
+ Requires-Dist: bump-my-version ~=0.24.0
50
+ Requires-Dist: click-extra ~=4.8.3
51
+ Requires-Dist: packaging ~=24.1
52
+ Requires-Dist: PyDriller ~=2.6
53
+ Requires-Dist: pyproject-metadata ~=0.8.0
54
+ Requires-Dist: wcmatch ~=8.5.2
55
+ Requires-Dist: backports.strenum ~=1.3.1 ; python_version < "3.11"
56
+ Requires-Dist: tomli ~=2.0.1 ; python_version < "3.11"
57
+
58
+ # `gha-utils` CLI + reusable workflows
59
+
60
+ [![Last release](https://img.shields.io/pypi/v/gha-utils.svg)](https://pypi.python.org/pypi/gha-utils)
61
+ [![Python versions](https://img.shields.io/pypi/pyversions/gha-utils.svg)](https://pypi.python.org/pypi/gha-utils)
62
+ [![Type checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
63
+ [![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)
64
+
65
+ `gha-utils` stands for **G**it**H**ub **A**ction workflows **Util**itie**s**.
66
+
67
+ Maintaining project takes time. This repository contains the code of the `gha-utils` CLI and a collection of reusable workflows to:
68
+
69
+ - maintain a Python project, its CLI, doc, QA, etc.
70
+ - maintain an Awesome List project.
71
+
72
+ ## `gha-utils` CLI
73
+
74
+ ### Executables
75
+
76
+ Standalone executables of `gha-utils`'s latest version are available as direct downloads for several platforms and architectures:
77
+
78
+ | Platform | `x86_64` | `arm64` |
79
+ | ----------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
80
+ | **Linux** | [Download `gha-utils-linux-x64.bin`](https://github.com/kdeldycke/workflows/releases/latest/download/gha-utils-linux-x64.bin) | |
81
+ | **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) |
82
+ | **Windows** | [Download `gha-utils-windows-x64.exe`](https://github.com/kdeldycke/workflows/releases/latest/download/gha-utils-windows-x64.exe) | |
83
+
84
+ ### Run dev version
85
+
86
+ ```shell-session
87
+ $ git clone https://github.com/kdeldycke/workflows
88
+ $ cd workflows
89
+ $ python -m pip install uv
90
+ $ uv venv
91
+ $ source .venv/bin/activate
92
+ $ uv pip install .
93
+ $ uv run gha-utils
94
+ ```
95
+
96
+ ## Reusable workflows collection
97
+
98
+ This repository contains workflows to automate most of the boring tasks.
99
+
100
+ These workflows are mostly used for Python projects and their documentation, but not only. They're all [reusable GitHub actions workflows](https://docs.github.com/en/actions/learn-github-actions/reusing-workflows).
101
+
102
+ Reasons for a centralized workflow repository:
103
+
104
+ - reusability of course: no need to update dozens of repository where 95% of workflows are the same
105
+ - centralize all dependencies pertaining to automation: think of the point-release of an action that triggers dependabot upgrade to all your repositories depending on it
106
+
107
+ ### Guidelines
108
+
109
+ I don't want to copy-n-past, keep in sync and maintain another `N`th CI/CD file at the root of my repositories.
110
+
111
+ So my policy is: move every repository-specific config in a `pyproject.toml` file, or hide the gory details in a reused workflow.
112
+
113
+ ### `.github/workflows/docs.yaml` jobs
114
+
115
+ - Autofix typos
116
+
117
+ - Optimize images
118
+
119
+ - Keep `.mailmap` up to date
120
+
121
+ - Update dependency graph of Python projects
122
+
123
+ - **Requires**:
124
+ - Python package with a `pyproject.toml` file
125
+
126
+ - Build Sphinx-based documentation and publish it to GitHub Pages
127
+
128
+ - **Requires**:
129
+ - Python package with a `pyproject.toml` file
130
+ - All Sphinx dependencies in a `docs` [extra dependency group](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#dependencies-and-requirements):
131
+ ```toml
132
+ [project.optional-dependencies]
133
+ docs = [
134
+ "furo == 2024.1.29",
135
+ "myst-parser ~= 3.0.0",
136
+ "sphinx >= 6",
137
+ ...
138
+ ]
139
+ ```
140
+ - Sphinx configuration file at `docs/conf.py`
141
+
142
+ - Sync awesome projects from `awesome-template` repository
143
+
144
+ ### Why all these `requirements/*.txt` files?
145
+
146
+ Let's look for example at the `lint-yaml` job from [`.github/workflows/lint.yaml`](https://github.com/kdeldycke/workflows/blob/main/.github/workflows/lint.yaml#L126). Here we only need the `yamllint` CLI. This CLI is [distributed on PyPi](https://pypi.org/project/yamllint/). So before executing it, we could have simply run the following step:
147
+
148
+ ```yaml
149
+ - name: Install yamllint
150
+ run: |
151
+ pip install yamllint
152
+ ```
153
+
154
+ Instead, we install it via the [`requirements/yamllint.txt` file](https://github.com/kdeldycke/workflows/blob/main/requirements/yamllint.txt).
155
+
156
+ Why? Because I want the version of `yamllint` to be pinned. By pinning it, I make the workflow stable, predictable and reproducible.
157
+
158
+ So why use a dedicated requirements file? Why don't we simply add the version? Like this:
159
+
160
+ ```yaml
161
+ - name: Install yamllint
162
+ run: |
163
+ pip install yamllint==1.35.1
164
+ ```
165
+
166
+ That would indeed pin the version. But it requires the maintainer (me) to keep track of new release and update manually the version string. That's a lot of work. And I'm lazy. So this should be automated.
167
+
168
+ To automate that, the only practical way I found was to rely on dependabot. But dependabot cannot update arbitrary versions in `run:` YAML blocks. It [only supports `requirements.txt` and `pyproject.toml`](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#pip-and-pip-compile) files for Python projects.
169
+
170
+ So to keep track of new versions of dependencies while keeping them stable, we've hard-coded all Python libraries and CLIs in the `requirements/*.txt` files. All with pinned versions.
171
+
172
+ And for the case we need to install all dependencies in one go, we have a [`requirements.txt` file at the root](https://github.com/kdeldycke/workflows/blob/main/requirements.txt) that is referencing all files from the `requirements/` subfolder.
173
+
174
+ ### Permissions and token
175
+
176
+ This repository updates itself via GitHub actions. It particularly updates its own YAML files in `.github/workflows`. That's forbidden by default. So we need extra permissions.
177
+
178
+ Usually, to grant special permissions to some jobs, you use the [`permissions` parameter in workflow](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions) files. It looks like this:
179
+
180
+ ```yaml
181
+ on: (...)
182
+
183
+ jobs:
184
+
185
+ my-job:
186
+ runs-on: ubuntu-latest
187
+ permissions:
188
+ contents: write
189
+ pull-requests: write
190
+
191
+ steps: (...)
192
+ ```
193
+
194
+ But the `contents: write` permission doesn't allow write access to the workflow files in the `.github` subfolder. There is `actions: write`, but it only covers workflow runs, not their YAML source file. Even a `permissions: write-all` doesn't work. So you cannot use the `permissions` parameter to allow a repository's workflow update its own workflow files.
195
+
196
+ You will always end up with this kind or errors:
197
+
198
+ ```text
199
+ ! [remote rejected] branch_xxx -> branch_xxx (refusing to allow a GitHub App to create or update workflow `.github/workflows/my_workflow.yaml` without `workflows` permission)
200
+
201
+ error: failed to push some refs to 'https://github.com/kdeldycke/my-repo'
202
+ ```
203
+
204
+ > \[!NOTE\]
205
+ > 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:
206
+ > ![](docs/assets/repo-workflow-permissions.png)
207
+
208
+ To bypass the limitation, we rely on a custom access token. By convention, we call it `WORKFLOW_UPDATE_GITHUB_PAT`. It will be used, [in place of the default `secrets.GITHUB_TOKEN`](https://github.com/search?q=repo%3Akdeldycke%2Fworkflows%20WORKFLOW_UPDATE_GITHUB_PAT&type=code), in steps in which we need to change the workflow YAML files.
209
+
210
+ To create this custom `WORKFLOW_UPDATE_GITHUB_PAT`:
211
+
212
+ - From your GitHub user, go to `Settings` > `Developer Settings` > `Personal Access Tokens` > `Fine-grained tokens`
213
+ - Click on the `Generate new token` button
214
+ - Choose a good token name like `workflow-self-update` to make your intention clear
215
+ - Choose `Only select repositories` and the list the repositories in needs of updating their workflow YAML files
216
+ - In the `Repository permissions` drop-down, sets:
217
+ - `Contents`: `Access: **Read and Write**`
218
+ - `Metadata` (mandatory): `Access: **Read-only**`
219
+ - `Pull Requests`: `Access: **Read and Write**`
220
+ - `Workflows`: `Access: **Read and Write**`
221
+ > \[!NOTE\]
222
+ > 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.
223
+ - Now save these parameters and copy the `github_pat_XXXX` secret token
224
+ - Got to your repo > `Settings` > `Security` > `Secrets and variables` > `Actions` > `Secrets` > `Repository secrets` and click `New repository secrets`
225
+ - Name your secret `WORKFLOW_UPDATE_GITHUB_PAT` and copy the `github_pat_XXXX` token in the `Secret` field
226
+
227
+ Now re-run your actions and they should be able to update the workflow files in `.github` folder without the `refusing to allow a GitHub App to create or update workflow` error.
228
+
229
+ ### Release management
230
+
231
+ It turns out [Release Engineering is a full-time job, and full of edge-cases](https://blog.axo.dev/2023/02/cargo-dist).
232
+
233
+ Rust has [`cargo-dist`](https://github.com/axodotdev/cargo-dist). Go has... ? But there is no equivalent for Python.
234
+
235
+ So I made up a [`release.yaml` workflow](https://github.com/kdeldycke/workflows/blob/main/.github/workflows/release.yaml), which:
236
+
237
+ 1. Extracts project metadata from `pyproject.toml`
238
+ 1. Generates a build matrix of all commits / os / arch / CLI entry points
239
+ 1. Build Python wheel with Twine
240
+ 1. Compile binaries of all CLI with Nuitka
241
+ 1. Tag the release commit in Git
242
+ 1. Publish new version to PyPi
243
+ 1. Publish a GitHub release
244
+ 1. Attach and rename build artifacts to it
245
+
246
+ ## Changelog
247
+
248
+ A [detailed changelog](changelog.md) is available.
249
+
250
+ ## Used in
251
+
252
+ Check these projects to get real-life examples of usage and inspiration:
253
+
254
+ - ![GitHub stars](https://img.shields.io/github/stars/kdeldycke/awesome-falsehood?label=%E2%AD%90&style=flat-square) [Awesome Falsehood](https://github.com/kdeldycke/awesome-falsehood#readme) - Falsehoods Programmers Believe in.
255
+ - ![GitHub stars](https://img.shields.io/github/stars/kdeldycke/awesome-engineering-team-management?label=%E2%AD%90&style=flat-square) [Awesome Engineering Team Management](https://github.com/kdeldycke/awesome-engineering-team-management#readme) - How to transition from software development to engineering management.
256
+ - ![GitHub stars](https://img.shields.io/github/stars/kdeldycke/awesome-iam?label=%E2%AD%90&style=flat-square) [Awesome IAM](https://github.com/kdeldycke/awesome-iam#readme) - Identity and Access Management knowledge for cloud platforms.
257
+ - ![GitHub stars](https://img.shields.io/github/stars/kdeldycke/awesome-billing?label=%E2%AD%90&style=flat-square) [Awesome Billing](https://github.com/kdeldycke/awesome-billing#readme) - Billing & Payments knowledge for cloud platforms.
258
+ - ![GitHub stars](https://img.shields.io/github/stars/kdeldycke/meta-package-manager?label=%E2%AD%90&style=flat-square) [Meta Package Manager](https://github.com/kdeldycke/meta-package-manager#readme) - A unifying CLI for multiple package managers.
259
+ - ![GitHub stars](https://img.shields.io/github/stars/kdeldycke/mail-deduplicate?label=%E2%AD%90&style=flat-square) [Mail Deduplicate](https://github.com/kdeldycke/mail-deduplicate#readme) - A CLI to deduplicate similar emails.
260
+ - ![GitHub stars](https://img.shields.io/github/stars/kdeldycke/dotfiles?label=%E2%AD%90&style=flat-square) [dotfiles](https://github.com/kdeldycke/dotfiles#readme) - macOS dotfiles for Python developers.
261
+ - ![GitHub stars](https://img.shields.io/github/stars/kdeldycke/click-extra?label=%E2%AD%90&style=flat-square) [Click Extra](https://github.com/kdeldycke/click-extra#readme) - Extra colorization and configuration loading for Click.
262
+ - ![GitHub stars](https://img.shields.io/github/stars/themagicalmammal/wikibot?label=%E2%AD%90&style=flat-square) [Wiki bot](https://github.com/themagicalmammal/wikibot#readme) - A bot which provides features from Wikipedia like summary, title searches, location API etc.
263
+ - ![GitHub stars](https://img.shields.io/github/stars/kdeldycke/workflows?label=%E2%AD%90&style=flat-square) [workflows](https://github.com/kdeldycke/workflows#readme) - Itself. Eat your own dog-food.
264
+ - ![GitHub stars](https://img.shields.io/github/stars/themagicalmammal/stock-analyser?label=%E2%AD%90&style=flat-square) [Stock Analysis](https://github.com/themagicalmammal/stock-analyser#readme) - Simple to use interfaces for basic technical analysis of stocks.
265
+ - ![GitHub stars](https://img.shields.io/github/stars/themagicalmammal/genetictabler?label=%E2%AD%90&style=flat-square) [GeneticTabler](https://github.com/themagicalmammal/genetictabler#readme) - Time Table Scheduler using Genetic Algorithms.
266
+ - ![GitHub stars](https://img.shields.io/github/stars/themagicalmammal/excel-write?label=%E2%AD%90&style=flat-square) [Excel Write](https://github.com/themagicalmammal/excel-write#readme) - Optimised way to write in excel files.
267
+
268
+ Feel free to send a PR to add your project in this list if you are relying on these scripts.
269
+
270
+ ## Release process
271
+
272
+ All steps of the release process and version management are automated in the
273
+ [`changelog.yaml`](https://github.com/kdeldycke/workflows/blob/main/.github/workflows/changelog.yaml)
274
+ and
275
+ [`release.yaml`](https://github.com/kdeldycke/workflows/blob/main/.github/workflows/release.yaml)
276
+ workflows.
277
+
278
+ All there's left to do is to:
279
+
280
+ - [check the open draft `prepare-release` PR](https://github.com/kdeldycke/workflows/pulls?q=is%3Apr+is%3Aopen+head%3Aprepare-release)
281
+ and its changes,
282
+ - click the `Ready for review` button,
283
+ - click the `Rebase and merge` button,
284
+ - let the workflows tag the release and set back the `main` branch into a
285
+ development state.
@@ -0,0 +1,12 @@
1
+ gha_utils/__init__.py,sha256=dnH1Sku0aFVGnpkcImGQfGV4Arm-81fr31vQMpLF-20,865
2
+ gha_utils/__main__.py,sha256=Dck9BjpLXmIRS83k0mghAMcYVYiMiFLltQdfRuMSP_Q,1703
3
+ gha_utils/changelog.py,sha256=Ny9lCe8w_6uyh8x5P_EuzgQX88j2FJYemVoi9pw_8DI,5765
4
+ gha_utils/cli.py,sha256=PSQFbBF21qFDg-wdwHNAto0xouo6Ou7vQf1WHbD-96E,6784
5
+ gha_utils/mailmap.py,sha256=7pkkE0G2Mg6nDQ5wAaujvE0tTBRBVVCqj1vkEps12bk,3725
6
+ gha_utils/metadata.py,sha256=LDuUNk9RzVvr2BsgtB2Eh4wk_w9HnPiYM3OyxOQ9cXM,47115
7
+ gha_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ gha_utils-4.1.1.dist-info/METADATA,sha256=4axsdRT1qYeWJyTLIDFR4FWIqsPsTQ2-DPOBSkMV6pk,17188
9
+ gha_utils-4.1.1.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
10
+ gha_utils-4.1.1.dist-info/entry_points.txt,sha256=8bJOwQYf9ZqsLhBR6gUCzvwLNI9f8tiiBrJ3AR0EK4o,54
11
+ gha_utils-4.1.1.dist-info/top_level.txt,sha256=C94Blb61YkkyPBwCdM3J_JPDjWH0lnKa5nGZeZ5M6yE,10
12
+ gha_utils-4.1.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.1.1)
2
+ Generator: setuptools (70.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5