Skip to content

Commit 14d5c39

Browse files
committed
convert
1 parent aa56125 commit 14d5c39

File tree

3 files changed

+36
-26
lines changed

3 files changed

+36
-26
lines changed

.github/workflows/convert_attestation.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/create-release.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,24 @@ jobs:
7777
predicate: "null"
7878
show-summary: "true"
7979

80-
- uses: actions/upload-artifact@v4
80+
- name: Upload sigstore JSONL attestations bundle
81+
uses: actions/upload-artifact@v4
8182
with:
8283
name: sigstore-bundle
8384
path: ${{ steps.attest.outputs.bundle-path }}
8485

85-
# - name: Generate PEP 740 attestations
86-
# run: |
87-
# python -m pypi_attestations sign dist/*
88-
#
89-
# - name: Inspect PEP 740 attestations
90-
# run: |
91-
# python -m pypi_attestations inspect dist/*.publish.attestation
92-
#
93-
# - name: Verify PEP 740 attestations
94-
# run: |
95-
# python -m pypi_attestations verify dist/*.whl --identity https://github.com/${{ github.repository }}/.github/workflows/create-release.yml@${{ github.ref }}
96-
# python -m pypi_attestations verify dist/*.tar.gz --identity https://github.com/${{ github.repository }}/.github/workflows/create-release.yml@${{ github.ref }}
86+
- name: Convert attestations to PEP 740
87+
run: python utils/convert_attestations.py "${{ steps.attest.outputs.bundle-path }}"
88+
89+
- name: Inspect PEP 740 attestations
90+
run: |
91+
python -m pypi_attestations inspect dist/*.publish.attestation
92+
93+
- name: Verify PEP 740 attestations
94+
# workflow_ref example: sphinx-doc/sphinx/.github/workflows/create-release.yml@refs/heads/master
95+
run: |
96+
python -m pypi_attestations verify dist/*.whl --identity https://github.com/${{ github.workflow_ref }}
97+
python -m pypi_attestations verify dist/*.tar.gz --identity https://github.com/${{ github.workflow_ref }}
9798
9899
# - name: Upload to PyPI
99100
# env:

utils/convert_attestations.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import base64
2+
import json
3+
import sys
4+
from pathlib import Path
5+
6+
from pypi_attestations import Attestation
7+
from sigstore.models import Bundle
8+
9+
DIST = Path('dist')
10+
11+
bundle_path = Path(sys.argv[1])
12+
for line in bundle_path.read_bytes().splitlines():
13+
dsse_envelope_payload = json.loads(line)['dsseEnvelope']['payload']
14+
subjects = json.loads(base64.b64decode(dsse_envelope_payload))['subject']
15+
for subject in subjects:
16+
filename = subject['name']
17+
sigstore_bundle = Bundle.from_json(line)
18+
attestation = Attestation.from_bundle(sigstore_bundle)
19+
print(attestation.model_dump_json())
20+
signature_path = DIST / f'{filename}.publish.attestation'
21+
signature_path.write_text(attestation.model_dump_json())
22+
print(f'Attestation for {filename} written to {signature_path}')

0 commit comments

Comments
 (0)