Add Python publish workflow for automated package release to PyPI

This commit is contained in:
akadeepesh
2026-05-15 14:43:29 +05:30
parent bc2543a9f4
commit a77eb85caf
@@ -27,10 +27,10 @@ jobs:
echo "Package version : $PKG_VERSION"
echo "Release tag : $TAG_VERSION"
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
echo "❌ Version mismatch — update __init__.py and pyproject.toml before releasing"
echo "Version mismatch — update __init__.py and pyproject.toml before releasing"
exit 1
fi
echo "✅ Versions match"
echo "Versions match"
# ── Job 2: Build the distributions ────────────────────────────────────────
build:
@@ -55,12 +55,12 @@ jobs:
import zipfile, sys, os
wheels = [f for f in os.listdir("dist") if f.endswith(".whl")]
if not wheels:
print("❌ No wheel found in dist/"); sys.exit(1)
print("No wheel found in dist/"); sys.exit(1)
with zipfile.ZipFile(f"dist/{wheels[0]}") as z:
names = z.namelist()
if not any("entry_points.txt" in n for n in names):
print("❌ entry_points.txt missing from wheel"); sys.exit(1)
print(f"✅ Wheel OK: {wheels[0]}")
print("entry_points.txt missing from wheel"); sys.exit(1)
print(f"Wheel OK: {wheels[0]}")
ep = [n for n in names if "entry_points" in n][0]
print(z.read(ep).decode())
EOF
@@ -76,7 +76,7 @@ jobs:
runs-on: ubuntu-latest
needs: build
permissions:
id-token: write # required for trusted publishing
id-token: write # required for trusted publishing
environment:
name: pypi
url: https://pypi.org/project/contextzip/${{ github.event.release.tag_name }}