Skip to content
Open
145 changes: 145 additions & 0 deletions .github/workflows/list-packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: List package versions (PyPI / Test PyPI)

on:
workflow_dispatch:
schedule:
# Run every Monday at 9:00 AM UTC
- cron: '0 9 * * 1'
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maciejmajek, let me know whether this is necessary. I don't mind taking this out.


jobs:
list-packages:
name: List local and PyPI versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install packaging

- name: Discover local packages and check PyPI versions
run: |
python scripts/discover_packages.py --output-format json > packages.json

python -c '
import json
import subprocess
import sys

# Load local packages
with open("packages.json") as f:
local_packages = json.load(f)

print("## Package Version Status")
print("")
print("| Package | Local Version | PyPI Latest | Test PyPI Latest | Status |")
print("|---------|---------------|-------------|------------------|--------|")

for pkg_name in sorted(local_packages.keys()):
pkg_info = local_packages[pkg_name]
local_version = pkg_info["version"]

# Get Test PyPI versions
try:
result = subprocess.run(["python", "scripts/pypi_query.py", "--test-pypi", "list", pkg_name, "--json"],
capture_output=True, text=True, timeout=10)
testpypi_versions = json.loads(result.stdout) if result.returncode == 0 and result.stdout.strip() else []
except (json.JSONDecodeError, subprocess.TimeoutExpired):
testpypi_versions = []

# Get PyPI versions
try:
result = subprocess.run(["python", "scripts/pypi_query.py", "list", pkg_name, "--json"],
capture_output=True, text=True, timeout=10)
pypi_versions = json.loads(result.stdout) if result.returncode == 0 and result.stdout.strip() else []
except (json.JSONDecodeError, subprocess.TimeoutExpired):
pypi_versions = []

# Get latest versions (first in sorted list, which is newest)
pypi_latest = pypi_versions[0] if pypi_versions else "-"
testpypi_latest = testpypi_versions[0] if testpypi_versions else "-"

# Display local version (no annotations)
local_display = f"**{local_version}**"

# Generate recommendation
recommendation = ""
if pypi_latest and pypi_latest != "-":
# Compare versions - if PyPI is older, recommend publishing
from packaging import version as pkg_version
try:
if pkg_version.parse(local_version) > pkg_version.parse(pypi_latest):
recommendation = "📦 Awaiting release"
elif local_version == pypi_latest:
recommendation = "✅ Up to date"
else:
recommendation = "Local < PyPI"
except:
recommendation = "-"
elif testpypi_latest and testpypi_latest != "-":
recommendation = "📦 Awaiting release"
else:
recommendation = "📦 Awaiting release"

print(f"| {pkg_name} | {local_display} | {pypi_latest} | {testpypi_latest} | {recommendation} |")

print("")
print("Legend:")
print("- **bold** = current local version")
' >> $GITHUB_STEP_SUMMARY

# Also print to console
python -c '
import json
import subprocess

with open("packages.json") as f:
local_packages = json.load(f)

print("\\nPackage Version Status:\\n")

for pkg_name in sorted(local_packages.keys()):
pkg_info = local_packages[pkg_name]
local_version = pkg_info["version"]

# Get Test PyPI versions
try:
result = subprocess.run(["python", "scripts/pypi_query.py", "--test-pypi", "list", pkg_name, "--json"],
capture_output=True, text=True, timeout=10)
testpypi_versions = json.loads(result.stdout) if result.returncode == 0 and result.stdout.strip() else []
except (json.JSONDecodeError, subprocess.TimeoutExpired):
testpypi_versions = []

# Get PyPI versions
try:
result = subprocess.run(["python", "scripts/pypi_query.py", "list", pkg_name, "--json"],
capture_output=True, text=True, timeout=10)
pypi_versions = json.loads(result.stdout) if result.returncode == 0 and result.stdout.strip() else []
except (json.JSONDecodeError, subprocess.TimeoutExpired):
pypi_versions = []

local_exists_pypi = local_version in pypi_versions
local_exists_testpypi = local_version in testpypi_versions

status = ""
if local_exists_pypi:
status = " [PUBLISHED on PyPI]"
elif local_exists_testpypi:
status = " [PUBLISHED on Test PyPI]"
else:
status = " [NOT PUBLISHED]"

pypi_latest = pypi_versions[0] if pypi_versions else "-"
testpypi_latest = testpypi_versions[0] if testpypi_versions else "-"

print(f"{pkg_name}:")
print(f" Local: {local_version}{status}")
print(f" PyPI: {pypi_latest}")
print(f" Test PyPI: {testpypi_latest}")
print()
'
Loading
Loading