forked from microsoft/graphrag
-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (79 loc) · 2.76 KB
/
python-publish.yml
File metadata and controls
100 lines (79 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Python Publish (pypi)
on:
release:
types: [created]
push:
branches: [main]
env:
PYTHON_VERSION: "3.13"
jobs:
publish:
name: Upload release to PyPI
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
shell: bash
run: uv sync --all-packages
- name: Export Publication Version
run: echo "version=$(uv version --short)" >> $GITHUB_OUTPUT
- name: Build Distributable
shell: bash
run: uv run poe build
- name: Inspect all distribution members and metadata
shell: bash
run: |
python - <<'PY'
import glob, zipfile, tarfile, re
print("\n=== FILES IN dist/ ===")
for f in glob.glob("dist/*"):
print(" ", f)
print("\n=== WHEELS ===")
for whl in glob.glob("dist/*.whl"):
print("\n---", whl, "---")
with zipfile.ZipFile(whl) as z:
for name in z.namelist():
print(name)
metas = [n for n in z.namelist() if n.endswith(".dist-info/METADATA")]
for meta in metas:
print("\n[METADATA:", meta, "]")
text = z.read(meta).decode("utf-8", "replace")
name_m = re.search(r"^Name:\s*(.+)$", text, re.M)
ver_m = re.search(r"^Version:\s*(.+)$", text, re.M)
if name_m:
print("Project Name:", name_m.group(1))
if ver_m:
print("Version:", ver_m.group(1))
print("\n=== SDISTS ===")
for sdist in glob.glob("dist/*.tar.gz"):
print("\n---", sdist, "---")
with tarfile.open(sdist, "r:gz") as t:
for m in t.getmembers():
print(m.name)
metas = [m for m in t.getmembers() if m.name.endswith("PKG-INFO")]
for m in metas:
print("\n[PKG-INFO:", m.name, "]")
text = t.extractfile(m).read().decode("utf-8", "replace")
name_m = re.search(r"^Name:\s*(.+)$", text, re.M)
ver_m = re.search(r"^Version:\s*(.+)$", text, re.M)
if name_m:
print("Project Name:", name_m.group(1))
if ver_m:
print("Version:", ver_m.group(1))
PY
- name: Publish package distributions to PyPI
run: uv publish