11name : Python Publish (pypi)
2+
23on :
34 release :
45 types : [created]
@@ -13,11 +14,13 @@ jobs:
1314 name : Upload release to PyPI
1415 if : github.ref == 'refs/heads/main'
1516 runs-on : ubuntu-latest
17+
1618 environment :
1719 name : pypi
1820 url : https://pypi.org/p/graphrag
21+
1922 permissions :
20- id-token : write # IMPORTANT: this permission is mandatory for trusted publishing
23+ id-token : write
2124
2225 steps :
2326 - uses : actions/checkout@v4
4447 shell : bash
4548 run : uv build
4649
50+ - name : Inspect all distribution members and metadata
51+ shell : bash
52+ run : |
53+ python - <<'PY'
54+ import glob, zipfile, tarfile, re
55+
56+ print("\n=== FILES IN dist/ ===")
57+ for f in glob.glob("dist/*"):
58+ print(" ", f)
59+
60+ print("\n=== WHEELS ===")
61+ for whl in glob.glob("dist/*.whl"):
62+ print("\n---", whl, "---")
63+ with zipfile.ZipFile(whl) as z:
64+ for name in z.namelist():
65+ print(name)
66+
67+ metas = [n for n in z.namelist() if n.endswith(".dist-info/METADATA")]
68+ for meta in metas:
69+ print("\n[METADATA:", meta, "]")
70+ text = z.read(meta).decode("utf-8", "replace")
71+
72+ name_m = re.search(r"^Name:\s*(.+)$", text, re.M)
73+ ver_m = re.search(r"^Version:\s*(.+)$", text, re.M)
74+
75+ if name_m:
76+ print("Project Name:", name_m.group(1))
77+ if ver_m:
78+ print("Version:", ver_m.group(1))
79+
80+ print("\n=== SDISTS ===")
81+ for sdist in glob.glob("dist/*.tar.gz"):
82+ print("\n---", sdist, "---")
83+ with tarfile.open(sdist, "r:gz") as t:
84+ for m in t.getmembers():
85+ print(m.name)
86+
87+ metas = [m for m in t.getmembers() if m.name.endswith("PKG-INFO")]
88+ for m in metas:
89+ print("\n[PKG-INFO:", m.name, "]")
90+ text = t.extractfile(m).read().decode("utf-8", "replace")
91+
92+ name_m = re.search(r"^Name:\s*(.+)$", text, re.M)
93+ ver_m = re.search(r"^Version:\s*(.+)$", text, re.M)
94+
95+ if name_m:
96+ print("Project Name:", name_m.group(1))
97+ if ver_m:
98+ print("Version:", ver_m.group(1))
99+ PY
100+
47101 - name : Publish package distributions to PyPI
48102 uses : pypa/gh-action-pypi-publish@release/v1
49103 with :
0 commit comments