tag-publish 1.4.0.dev5__tar.gz → 1.5.0.dev0__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.
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/PKG-INFO +35 -10
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/README.md +31 -8
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/pyproject.toml +10 -6
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/tag_publish/__init__.py +20 -8
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/tag_publish/configuration.py +16 -2
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/tag_publish/publish.py +106 -7
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/tag_publish/schema.json +8 -2
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/tag_publish/versions.yaml +1 -0
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/LICENSE +0 -0
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/tag_publish/cli.py +0 -0
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/tag_publish/lib/__init__.py +0 -0
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/tag_publish/lib/docker.py +0 -0
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/tag_publish/lib/oidc.py +0 -0
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/tag_publish/new.py +0 -0
- {tag_publish-1.4.0.dev5 → tag_publish-1.5.0.dev0}/tag_publish/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tag-publish
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0.dev0
|
|
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
|
|
@@ -25,9 +25,11 @@ Provides-Extra: new
|
|
|
25
25
|
Provides-Extra: pypi
|
|
26
26
|
Provides-Extra: validation
|
|
27
27
|
Requires-Dist: PyYAML (>=6,<7)
|
|
28
|
+
Requires-Dist: applications-download (>=1,<2) ; extra == "docker"
|
|
28
29
|
Requires-Dist: applications-download (>=1,<2) ; extra == "helm"
|
|
29
30
|
Requires-Dist: debian-inspector (>=31,<32) ; extra == "docker"
|
|
30
|
-
Requires-Dist: githubkit (>=0,<1)
|
|
31
|
+
Requires-Dist: githubkit (>=0.17.1,<1)
|
|
32
|
+
Requires-Dist: githubkit-schemas (>=26,<27)
|
|
31
33
|
Requires-Dist: id (>=1,<2) ; extra == "pypi"
|
|
32
34
|
Requires-Dist: jsonschema-validator-new (>=0,<1) ; extra == "validation"
|
|
33
35
|
Requires-Dist: multi-repo-automation (>=1,<2) ; extra == "new"
|
|
@@ -89,13 +91,13 @@ per kind of publishing. Only install the extras you actually use: a plain
|
|
|
89
91
|
`githubkit`) and will fail with an explicit message if you try a publishing whose
|
|
90
92
|
extra is missing.
|
|
91
93
|
|
|
92
|
-
| Extra | Kind of publishing | Dependencies
|
|
93
|
-
| ------------ | --------------------------------- |
|
|
94
|
-
| `pypi` | Python packages to PyPI | `requests`, `twine`, `id` (OIDC trusted publishing)
|
|
95
|
-
| `docker` | Docker images (dpkg audit)
|
|
96
|
-
| `helm` | Helm charts (GitHub/OCI) | `applications-download` (chart-releaser, cosign)
|
|
97
|
-
| `new` | `tag-publish-new` command | `multi-repo-automation`, `ruamel-yaml`
|
|
98
|
-
| `validation` | `.github/publish.yaml` validation | `jsonschema-validator-new`
|
|
94
|
+
| Extra | Kind of publishing | Dependencies |
|
|
95
|
+
| ------------ | --------------------------------- | ---------------------------------------------------------- |
|
|
96
|
+
| `pypi` | Python packages to PyPI | `requests`, `twine`, `id` (OIDC trusted publishing) |
|
|
97
|
+
| `docker` | Docker images (dpkg audit, SBOM) | `debian-inspector`, `applications-download` (syft, cosign) |
|
|
98
|
+
| `helm` | Helm charts (GitHub/OCI) | `applications-download` (chart-releaser, cosign) |
|
|
99
|
+
| `new` | `tag-publish-new` command | `multi-repo-automation`, `ruamel-yaml` |
|
|
100
|
+
| `validation` | `.github/publish.yaml` validation | `jsonschema-validator-new` |
|
|
99
101
|
|
|
100
102
|
Notes:
|
|
101
103
|
|
|
@@ -293,11 +295,29 @@ docker:
|
|
|
293
295
|
# If your images are published by different jobs you can separate them in different groups
|
|
294
296
|
# and publish them with `tag-publish --group=<group>`
|
|
295
297
|
group:
|
|
298
|
+
# Publish the SBOM of the image, `True` by default
|
|
299
|
+
sbom:
|
|
296
300
|
```
|
|
297
301
|
|
|
298
302
|
By default, the last line of the `SECURITY.md` file will be published (`docker`) with the tag
|
|
299
303
|
`latest`. Set `latest` to `False` to disable it.
|
|
300
304
|
|
|
305
|
+
#### SBOM attestation
|
|
306
|
+
|
|
307
|
+
By default (`sbom: True`), once the image is pushed, tag-publish generates a CycloneDX SBOM with
|
|
308
|
+
[syft](https://github.com/anchore/syft) and attaches it to every published tag as a keyless
|
|
309
|
+
[cosign](https://github.com/sigstore/cosign) attestation (`cosign attest-blob`) on the registry.
|
|
310
|
+
|
|
311
|
+
The publishing job requires the `packages: write` permission (to push the image and the
|
|
312
|
+
attestation) and the `id-token: write` permission (for the keyless signature), and `applications-download`
|
|
313
|
+
is required, so the `docker` extra must be installed: `pip install 'tag-publish[docker]'`.
|
|
314
|
+
|
|
315
|
+
The SBOM can be verified and retrieved with:
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
cosign verify-attestation --type cyclonedx ghcr.io/<owner>/<image>:<version>
|
|
319
|
+
```
|
|
320
|
+
|
|
301
321
|
#### Use Renovate to trigger a new build instead of the legacy rebuild
|
|
302
322
|
|
|
303
323
|
If the `ci/dpkg-versions.yaml` or `.github/dpkg-versions.yaml` file is present, the package list will be updated on publishing.
|
|
@@ -368,10 +388,15 @@ rejected once the release is immutable.
|
|
|
368
388
|
|
|
369
389
|
By default, the Helm chart is also published to an OCI registry (`ghcr.io/<owner>/<repo>`) and signed with [cosign](https://github.com/sigstore/cosign) using keyless signing.
|
|
370
390
|
|
|
371
|
-
The chart is pushed to `ghcr.io/<owner>/<repo>:<version
|
|
391
|
+
The chart is pushed to `ghcr.io/<owner>/<repo>/<chart-name>:<version>`, e.g.
|
|
392
|
+
`ghcr.io/camptocamp/tag-publish/tag-publish:1.2.2`.
|
|
372
393
|
|
|
373
394
|
The required permissions are `packages: write` (for pushing to ghcr.io) and `id-token: write` (for cosign keyless signing).
|
|
374
395
|
|
|
396
|
+
If the first push fails with `403: denied: installation not allowed to Create organization package`,
|
|
397
|
+
the `packages: write` permission is missing in the workflow, and the package must be created by a first
|
|
398
|
+
push or manually before the `GITHUB_TOKEN` is allowed to write on it.
|
|
399
|
+
|
|
375
400
|
To customize the OCI publishing:
|
|
376
401
|
|
|
377
402
|
```yaml
|
|
@@ -48,13 +48,13 @@ per kind of publishing. Only install the extras you actually use: a plain
|
|
|
48
48
|
`githubkit`) and will fail with an explicit message if you try a publishing whose
|
|
49
49
|
extra is missing.
|
|
50
50
|
|
|
51
|
-
| Extra | Kind of publishing | Dependencies
|
|
52
|
-
| ------------ | --------------------------------- |
|
|
53
|
-
| `pypi` | Python packages to PyPI | `requests`, `twine`, `id` (OIDC trusted publishing)
|
|
54
|
-
| `docker` | Docker images (dpkg audit)
|
|
55
|
-
| `helm` | Helm charts (GitHub/OCI) | `applications-download` (chart-releaser, cosign)
|
|
56
|
-
| `new` | `tag-publish-new` command | `multi-repo-automation`, `ruamel-yaml`
|
|
57
|
-
| `validation` | `.github/publish.yaml` validation | `jsonschema-validator-new`
|
|
51
|
+
| Extra | Kind of publishing | Dependencies |
|
|
52
|
+
| ------------ | --------------------------------- | ---------------------------------------------------------- |
|
|
53
|
+
| `pypi` | Python packages to PyPI | `requests`, `twine`, `id` (OIDC trusted publishing) |
|
|
54
|
+
| `docker` | Docker images (dpkg audit, SBOM) | `debian-inspector`, `applications-download` (syft, cosign) |
|
|
55
|
+
| `helm` | Helm charts (GitHub/OCI) | `applications-download` (chart-releaser, cosign) |
|
|
56
|
+
| `new` | `tag-publish-new` command | `multi-repo-automation`, `ruamel-yaml` |
|
|
57
|
+
| `validation` | `.github/publish.yaml` validation | `jsonschema-validator-new` |
|
|
58
58
|
|
|
59
59
|
Notes:
|
|
60
60
|
|
|
@@ -252,11 +252,29 @@ docker:
|
|
|
252
252
|
# If your images are published by different jobs you can separate them in different groups
|
|
253
253
|
# and publish them with `tag-publish --group=<group>`
|
|
254
254
|
group:
|
|
255
|
+
# Publish the SBOM of the image, `True` by default
|
|
256
|
+
sbom:
|
|
255
257
|
```
|
|
256
258
|
|
|
257
259
|
By default, the last line of the `SECURITY.md` file will be published (`docker`) with the tag
|
|
258
260
|
`latest`. Set `latest` to `False` to disable it.
|
|
259
261
|
|
|
262
|
+
#### SBOM attestation
|
|
263
|
+
|
|
264
|
+
By default (`sbom: True`), once the image is pushed, tag-publish generates a CycloneDX SBOM with
|
|
265
|
+
[syft](https://github.com/anchore/syft) and attaches it to every published tag as a keyless
|
|
266
|
+
[cosign](https://github.com/sigstore/cosign) attestation (`cosign attest-blob`) on the registry.
|
|
267
|
+
|
|
268
|
+
The publishing job requires the `packages: write` permission (to push the image and the
|
|
269
|
+
attestation) and the `id-token: write` permission (for the keyless signature), and `applications-download`
|
|
270
|
+
is required, so the `docker` extra must be installed: `pip install 'tag-publish[docker]'`.
|
|
271
|
+
|
|
272
|
+
The SBOM can be verified and retrieved with:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
cosign verify-attestation --type cyclonedx ghcr.io/<owner>/<image>:<version>
|
|
276
|
+
```
|
|
277
|
+
|
|
260
278
|
#### Use Renovate to trigger a new build instead of the legacy rebuild
|
|
261
279
|
|
|
262
280
|
If the `ci/dpkg-versions.yaml` or `.github/dpkg-versions.yaml` file is present, the package list will be updated on publishing.
|
|
@@ -327,10 +345,15 @@ rejected once the release is immutable.
|
|
|
327
345
|
|
|
328
346
|
By default, the Helm chart is also published to an OCI registry (`ghcr.io/<owner>/<repo>`) and signed with [cosign](https://github.com/sigstore/cosign) using keyless signing.
|
|
329
347
|
|
|
330
|
-
The chart is pushed to `ghcr.io/<owner>/<repo>:<version
|
|
348
|
+
The chart is pushed to `ghcr.io/<owner>/<repo>/<chart-name>:<version>`, e.g.
|
|
349
|
+
`ghcr.io/camptocamp/tag-publish/tag-publish:1.2.2`.
|
|
331
350
|
|
|
332
351
|
The required permissions are `packages: write` (for pushing to ghcr.io) and `id-token: write` (for cosign keyless signing).
|
|
333
352
|
|
|
353
|
+
If the first push fails with `403: denied: installation not allowed to Create organization package`,
|
|
354
|
+
the `packages: write` permission is missing in the workflow, and the package must be created by a first
|
|
355
|
+
push or manually before the `GITHUB_TOKEN` is allowed to write on it.
|
|
356
|
+
|
|
334
357
|
To customize the OCI publishing:
|
|
335
358
|
|
|
336
359
|
```yaml
|
|
@@ -22,8 +22,9 @@ exclude = ["tag_publish/node_modules/**/test"]
|
|
|
22
22
|
[tool.poetry.dependencies]
|
|
23
23
|
python = ">=3.11,<4.0"
|
|
24
24
|
PyYAML = "6.0.3"
|
|
25
|
-
security-md = "1.
|
|
26
|
-
githubkit = "0.
|
|
25
|
+
security-md = "1.1.0"
|
|
26
|
+
githubkit = "0.17.1"
|
|
27
|
+
githubkit-schemas = "26.11.5"
|
|
27
28
|
requests = { version = "2.33.0", optional = true }
|
|
28
29
|
twine = { version = "6.2.0", optional = true }
|
|
29
30
|
id = { version = "1.5.0", optional = true }
|
|
@@ -35,7 +36,7 @@ ruamel-yaml = { version = "0.19.1", optional = true }
|
|
|
35
36
|
|
|
36
37
|
[tool.poetry.extras]
|
|
37
38
|
pypi = ["requests", "twine", "id"]
|
|
38
|
-
docker = ["debian-inspector"]
|
|
39
|
+
docker = ["debian-inspector", "applications-download"]
|
|
39
40
|
helm = ["applications-download"]
|
|
40
41
|
new = ["multi-repo-automation", "ruamel-yaml"]
|
|
41
42
|
validation = ["jsonschema-validator-new"]
|
|
@@ -46,6 +47,7 @@ prospector-profile-duplicated = "1.12.0"
|
|
|
46
47
|
prospector-profile-utils = "1.27.0"
|
|
47
48
|
types-requests = "2.33.0.20260712"
|
|
48
49
|
types-pyyaml = "6.0.12.20260724"
|
|
50
|
+
pytest = "9.1.1"
|
|
49
51
|
ruff = "0.15.21"
|
|
50
52
|
pylint = "4.0.9"
|
|
51
53
|
|
|
@@ -67,6 +69,8 @@ format-jinja = """
|
|
|
67
69
|
|
|
68
70
|
[tool.poetry-plugin-tweak-dependencies-version]
|
|
69
71
|
default = "major"
|
|
72
|
+
# githubkit 0.17.0 is broken with hishel 2.0.0 (RuntimeError: GitHubKit requires httpx2...), fixed in 0.17.1
|
|
73
|
+
githubkit = ">=0.17.1,<1"
|
|
70
74
|
|
|
71
75
|
[project]
|
|
72
76
|
classifiers = [
|
|
@@ -95,12 +99,12 @@ include = [
|
|
|
95
99
|
"tag_publish/*.json",
|
|
96
100
|
]
|
|
97
101
|
requires-python = ">=3.11"
|
|
98
|
-
dependencies = ["PyYAML<7,>=6", "security-md<2,>=1", "githubkit<1,>=0"]
|
|
99
|
-
version = "1.
|
|
102
|
+
dependencies = ["PyYAML<7,>=6", "security-md<2,>=1", "githubkit<1,>=0.17.1", "githubkit-schemas<27,>=26"]
|
|
103
|
+
version = "1.5.0.dev0"
|
|
100
104
|
|
|
101
105
|
[project.optional-dependencies]
|
|
102
106
|
pypi = ["requests<3,>=2", "twine<7,>=6", "id<2,>=1"]
|
|
103
|
-
docker = ["debian-inspector<32,>=31"]
|
|
107
|
+
docker = ["debian-inspector<32,>=31", "applications-download<2,>=1"]
|
|
104
108
|
helm = ["applications-download<2,>=1"]
|
|
105
109
|
new = ["multi-repo-automation<2,>=1", "ruamel-yaml<1,>=0"]
|
|
106
110
|
validation = ["jsonschema-validator-new<1,>=0"]
|
|
@@ -13,7 +13,7 @@ from re import Match, Pattern
|
|
|
13
13
|
from typing import Any, TypedDict, cast, overload
|
|
14
14
|
|
|
15
15
|
import githubkit
|
|
16
|
-
import
|
|
16
|
+
import githubkit_schemas.latest.models
|
|
17
17
|
import security_md
|
|
18
18
|
import yaml
|
|
19
19
|
|
|
@@ -124,7 +124,7 @@ def get_security_md(gh: GH, local: bool) -> security_md.Security:
|
|
|
124
124
|
path="SECURITY.md",
|
|
125
125
|
).parsed_data
|
|
126
126
|
print("Using SECURITY.md file from the default branch")
|
|
127
|
-
assert isinstance(security_file,
|
|
127
|
+
assert isinstance(security_file, githubkit_schemas.latest.models.ContentFile)
|
|
128
128
|
# Decode content from base64
|
|
129
129
|
content = base64.b64decode(security_file.content).decode("utf-8") if security_file.content else ""
|
|
130
130
|
return security_md.Security(content)
|
|
@@ -233,20 +233,32 @@ def match(
|
|
|
233
233
|
|
|
234
234
|
|
|
235
235
|
@overload
|
|
236
|
-
def download_application(application_name: str, binary_filename: Path) -> Path: ...
|
|
236
|
+
def download_application(application_name: str, binary_filename: Path, *, extra: str = ...) -> Path: ...
|
|
237
237
|
|
|
238
238
|
|
|
239
239
|
@overload
|
|
240
|
-
def download_application(application_name: str) -> None: ...
|
|
240
|
+
def download_application(application_name: str, *, extra: str = ...) -> None: ...
|
|
241
241
|
|
|
242
242
|
|
|
243
|
-
def download_application(
|
|
244
|
-
|
|
243
|
+
def download_application(
|
|
244
|
+
application_name: str, binary_filename: Path | None = None, *, extra: str = "helm"
|
|
245
|
+
) -> Path | None:
|
|
246
|
+
"""
|
|
247
|
+
Download the application if necessary, with the included version.
|
|
248
|
+
|
|
249
|
+
Arguments:
|
|
250
|
+
application_name: The GitHub `owner/name` of the application to download
|
|
251
|
+
binary_filename: The name of the binary in ~/.local/bin, only used to check if the
|
|
252
|
+
application is already installed
|
|
253
|
+
extra: The name of the extra providing the `applications-download` dependency
|
|
254
|
+
|
|
255
|
+
"""
|
|
245
256
|
binary_full_filename = Path.home() / ".local" / "bin" / binary_filename if binary_filename else None
|
|
246
257
|
|
|
247
258
|
if not binary_full_filename.exists() if binary_full_filename else True:
|
|
248
|
-
require_extra(
|
|
249
|
-
# Imported here because it is an optional dependency provided by the `helm`
|
|
259
|
+
require_extra(extra, "applications_download")
|
|
260
|
+
# Imported here because it is an optional dependency provided by the `helm` and
|
|
261
|
+
# `docker` extras.
|
|
250
262
|
import applications_download # noqa: PLC0415
|
|
251
263
|
|
|
252
264
|
applications = applications_download.Applications()
|
|
@@ -92,6 +92,11 @@ r""" Default value of the field path 'Docker image group' """
|
|
|
92
92
|
|
|
93
93
|
|
|
94
94
|
|
|
95
|
+
DOCKER_IMAGE_SBOM_DEFAULT = True
|
|
96
|
+
r""" Default value of the field path 'Docker image sbom' """
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
95
100
|
DOCKER_IMAGE_TAGS_DEFAULT = ['{version}']
|
|
96
101
|
r""" Default value of the field path 'Docker image tags' """
|
|
97
102
|
|
|
@@ -213,6 +218,15 @@ class DockerImage(TypedDict, total=False):
|
|
|
213
218
|
- '{version}'
|
|
214
219
|
"""
|
|
215
220
|
|
|
221
|
+
sbom: bool
|
|
222
|
+
r"""
|
|
223
|
+
Docker image SBOM.
|
|
224
|
+
|
|
225
|
+
Publish the CycloneDX SBOM of the image as a keyless cosign attestation on the registry, requires the id-token: write permission on the publishing job
|
|
226
|
+
|
|
227
|
+
default: True
|
|
228
|
+
"""
|
|
229
|
+
|
|
216
230
|
|
|
217
231
|
|
|
218
232
|
class DockerRepository(TypedDict, total=False):
|
|
@@ -324,7 +338,7 @@ class HelmOci(TypedDict, total=False):
|
|
|
324
338
|
r"""
|
|
325
339
|
helm OCI enabled.
|
|
326
340
|
|
|
327
|
-
Enable publishing to an OCI registry
|
|
341
|
+
Enable publishing to an OCI registry, requires the workflow permission `packages: write`
|
|
328
342
|
|
|
329
343
|
default: True
|
|
330
344
|
"""
|
|
@@ -342,7 +356,7 @@ class HelmOci(TypedDict, total=False):
|
|
|
342
356
|
r"""
|
|
343
357
|
helm OCI sign.
|
|
344
358
|
|
|
345
|
-
Enable keyless signing of the chart using cosign
|
|
359
|
+
Enable keyless signing of the chart using cosign, requires the workflow permission `id-token: write`
|
|
346
360
|
|
|
347
361
|
default: True
|
|
348
362
|
"""
|
|
@@ -6,6 +6,7 @@ import os
|
|
|
6
6
|
import re
|
|
7
7
|
import subprocess # nosec
|
|
8
8
|
import sys
|
|
9
|
+
import tempfile
|
|
9
10
|
import tomllib
|
|
10
11
|
from collections.abc import Sequence
|
|
11
12
|
from pathlib import Path
|
|
@@ -16,6 +17,58 @@ import tag_publish
|
|
|
16
17
|
import tag_publish.configuration
|
|
17
18
|
|
|
18
19
|
|
|
20
|
+
def uses_poetry_build(build_requires: Sequence[str]) -> bool:
|
|
21
|
+
"""
|
|
22
|
+
Check if the package must be built with the Poetry CLI.
|
|
23
|
+
|
|
24
|
+
The `poetry-dynamic-versioning` plugin is only loaded by the Poetry CLI, not by the
|
|
25
|
+
poetry-core PEP 517 build backend used by `pip wheel`. If we build with `pip wheel`
|
|
26
|
+
a package using this plugin, the version silently falls back to `0.0.0`.
|
|
27
|
+
|
|
28
|
+
Arguments:
|
|
29
|
+
build_requires: The `build-system.requires` from the pyproject.toml file
|
|
30
|
+
|
|
31
|
+
"""
|
|
32
|
+
re_splitter = re.compile(r"[<>=]+")
|
|
33
|
+
for requirement in build_requires:
|
|
34
|
+
name = re_splitter.split(requirement)[0].split("[", 1)[0]
|
|
35
|
+
if name in ("poetry", "poetry-core", "poetry-dynamic-versioning"):
|
|
36
|
+
return True
|
|
37
|
+
return False
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def dist_versions(cwd: Path) -> list[str]:
|
|
41
|
+
"""
|
|
42
|
+
Get the versions of the built distributions.
|
|
43
|
+
|
|
44
|
+
Arguments:
|
|
45
|
+
cwd: The folder containing the `dist` folder
|
|
46
|
+
|
|
47
|
+
"""
|
|
48
|
+
versions = []
|
|
49
|
+
for wheel in cwd.glob("dist/*.whl"):
|
|
50
|
+
parts = wheel.name[: -len(".whl")].split("-")
|
|
51
|
+
if len(parts) >= 2:
|
|
52
|
+
versions.append(parts[1])
|
|
53
|
+
for archive in cwd.glob("dist/*.tar.gz"):
|
|
54
|
+
name_version = archive.name[: -len(".tar.gz")]
|
|
55
|
+
if "-" in name_version:
|
|
56
|
+
versions.append(name_version.rsplit("-", 1)[1])
|
|
57
|
+
return versions
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def check_tag_version(built_versions: Sequence[str], version: str) -> bool:
|
|
61
|
+
"""
|
|
62
|
+
Check that all the built distributions have the version of the tag.
|
|
63
|
+
|
|
64
|
+
Arguments:
|
|
65
|
+
built_versions: The versions of the built distributions
|
|
66
|
+
version: The version of the tag
|
|
67
|
+
|
|
68
|
+
"""
|
|
69
|
+
return bool(built_versions) and all(built_version == version for built_version in built_versions)
|
|
70
|
+
|
|
71
|
+
|
|
19
72
|
def pip(
|
|
20
73
|
package: tag_publish.configuration.PypiPackage,
|
|
21
74
|
version: str,
|
|
@@ -65,14 +118,10 @@ def pip(
|
|
|
65
118
|
if "build_command" not in package:
|
|
66
119
|
with (cwd / "pyproject.toml").open("rb") as project_file:
|
|
67
120
|
pyproject = tomllib.load(project_file)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
requirement_split = re_splitter.split(requirement)
|
|
71
|
-
if requirement_split[0] in ("poetry", "poetry-core"):
|
|
72
|
-
use_poetry = True
|
|
73
|
-
break
|
|
121
|
+
build_requires: list[str] = pyproject.get("build-system", {}).get("requires", [])
|
|
122
|
+
use_poetry = uses_poetry_build(build_requires)
|
|
74
123
|
subprocess.run(
|
|
75
|
-
["pip", "install", *
|
|
124
|
+
["pip", "install", *build_requires],
|
|
76
125
|
check=True,
|
|
77
126
|
)
|
|
78
127
|
if use_poetry:
|
|
@@ -85,6 +134,18 @@ def pip(
|
|
|
85
134
|
if cmd:
|
|
86
135
|
cmd = package.get("build_command", cmd)
|
|
87
136
|
subprocess.check_call(cmd, cwd=cwd, env=env)
|
|
137
|
+
if version_type == "tag":
|
|
138
|
+
built_versions = dist_versions(cwd)
|
|
139
|
+
if not check_tag_version(built_versions, version):
|
|
140
|
+
print(
|
|
141
|
+
f"Error: the versions of the built distributions "
|
|
142
|
+
f"({', '.join(built_versions) if built_versions else 'none'}) "
|
|
143
|
+
f"do not match the version of the tag ({version}), "
|
|
144
|
+
f"the version detection of the build is probably broken",
|
|
145
|
+
)
|
|
146
|
+
print("::endgroup::")
|
|
147
|
+
print("::error::The version of the built package does not match the version of the tag")
|
|
148
|
+
return False
|
|
88
149
|
cmd = [
|
|
89
150
|
"twine",
|
|
90
151
|
*(["upload", "--verbose", "--disable-progress-bar"] if publish else ["check"]),
|
|
@@ -262,6 +323,9 @@ def docker(
|
|
|
262
323
|
subprocess.run(["docker", "push", image], check=True)
|
|
263
324
|
images_full += new_images_full
|
|
264
325
|
|
|
326
|
+
if image_config.get("sbom", tag_publish.configuration.DOCKER_IMAGE_SBOM_DEFAULT):
|
|
327
|
+
_publish_sbom(new_images_full)
|
|
328
|
+
|
|
265
329
|
print("::endgroup::")
|
|
266
330
|
except subprocess.CalledProcessError as exception:
|
|
267
331
|
print(f"Error: {exception}")
|
|
@@ -271,6 +335,41 @@ def docker(
|
|
|
271
335
|
return True
|
|
272
336
|
|
|
273
337
|
|
|
338
|
+
def _publish_sbom(images: list[str]) -> None:
|
|
339
|
+
"""
|
|
340
|
+
Publish the SBOM of the pushed images as a keyless cosign attestation.
|
|
341
|
+
|
|
342
|
+
The CycloneDX SBOM is generated with syft on the first image reference, all the
|
|
343
|
+
references point to the same image, and it is then attached to every published
|
|
344
|
+
tag with `cosign attest-blob`.
|
|
345
|
+
|
|
346
|
+
Arguments:
|
|
347
|
+
images: The published image references, host/name:tag
|
|
348
|
+
|
|
349
|
+
"""
|
|
350
|
+
tag_publish.download_application("anchore/syft", extra="docker")
|
|
351
|
+
tag_publish.download_application("sigstore/cosign", extra="docker")
|
|
352
|
+
|
|
353
|
+
with tempfile.TemporaryDirectory() as folder:
|
|
354
|
+
sbom_filename = Path(folder) / "sbom.cdx.json"
|
|
355
|
+
subprocess.run(
|
|
356
|
+
["syft", images[0], f"--output=cyclonedx-json={sbom_filename}"],
|
|
357
|
+
check=True,
|
|
358
|
+
)
|
|
359
|
+
for image in images:
|
|
360
|
+
subprocess.run(
|
|
361
|
+
[
|
|
362
|
+
"cosign",
|
|
363
|
+
"attest-blob",
|
|
364
|
+
str(sbom_filename),
|
|
365
|
+
"--type=application/vnd.cyclonedx+json",
|
|
366
|
+
f"--subject={image}",
|
|
367
|
+
"--yes",
|
|
368
|
+
],
|
|
369
|
+
check=True,
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
|
|
274
373
|
def helm(
|
|
275
374
|
folder: str,
|
|
276
375
|
version: str,
|
|
@@ -44,6 +44,12 @@
|
|
|
44
44
|
"items": {
|
|
45
45
|
"type": "string"
|
|
46
46
|
}
|
|
47
|
+
},
|
|
48
|
+
"sbom": {
|
|
49
|
+
"description": "Publish the CycloneDX SBOM of the image as a keyless cosign attestation on the registry, requires the id-token: write permission on the publishing job",
|
|
50
|
+
"title": "Docker image SBOM",
|
|
51
|
+
"default": true,
|
|
52
|
+
"type": "boolean"
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
55
|
}
|
|
@@ -269,7 +275,7 @@
|
|
|
269
275
|
"additionalProperties": false,
|
|
270
276
|
"properties": {
|
|
271
277
|
"enabled": {
|
|
272
|
-
"description": "Enable publishing to an OCI registry",
|
|
278
|
+
"description": "Enable publishing to an OCI registry, requires the workflow permission `packages: write`",
|
|
273
279
|
"title": "helm OCI enabled",
|
|
274
280
|
"default": true,
|
|
275
281
|
"type": "boolean"
|
|
@@ -281,7 +287,7 @@
|
|
|
281
287
|
"type": "string"
|
|
282
288
|
},
|
|
283
289
|
"sign": {
|
|
284
|
-
"description": "Enable keyless signing of the chart using cosign",
|
|
290
|
+
"description": "Enable keyless signing of the chart using cosign, requires the workflow permission `id-token: write`",
|
|
285
291
|
"title": "helm OCI sign",
|
|
286
292
|
"default": true,
|
|
287
293
|
"type": "boolean"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|