Phasor 3.3.0
Stack VM based Programming Language
Loading...
Searching...
No Matches
attestation_json.py
Go to the documentation of this file.
1import json
2import glob
3import os
4import hashlib
5
6fileglobs = [
7 "install/**/bin/*",
8 "install/**/lib/*",
9 "install/**/lib/**/*",
10 "install/**/Library/**/*",
11]
12
13def sha256_file(path):
14 h = hashlib.sha256()
15 with open(path, "rb") as f:
16 for chunk in iter(lambda: f.read(8192), b""):
17 h.update(chunk)
18 return h.hexdigest()
19
20hashes = {}
21
22for pattern in fileglobs:
23 for path in glob.glob(pattern, recursive=True):
24 if os.path.isfile(path):
25 normalized = path.replace("\\", "/")
26 if normalized not in hashes:
27 hashes[normalized] = sha256_file(path)
28
29files = [
30 {"path": path, "sha256": digest}
31 for path, digest in sorted(hashes.items())
32]
33
34data = {
35 "os": "${{ matrix.os }}",
36 "cc": "${{ matrix.c_compiler }}",
37 "cxx": "${{ matrix.cpp_compiler }}",
38 "attestation_url": "${{ steps.attest.outputs.attestation-url }}",
39 "attestation_id": "${{ steps.attest.outputs.attestation-id }}",
40 "commit": "${{ github.sha }}",
41 "run_id": "${{ github.run_id }}",
42 "files": files,
43}
44
45os.makedirs("install", exist_ok=True)
46
47with open("install/attestations.json", "w") as f:
48 json.dump(data, f, indent=2)