Skip to content

Commit c9149c2

Browse files
refactor: Remove redundant PyPI publishing jobs from ci.yml (issue #20) (#38)
The ci.yml workflow contained duplicate PyPI publishing functionality that is already handled by the dedicated release.yml workflow. This commit removes: - The 'publish' job that published to production PyPI on tag pushes - The 'test-pypi-publish' job that published to TestPyPI on main branch pushes These jobs created maintenance overhead and potential confusion about which workflow handles releases. The release.yml workflow remains the single source of truth for all release and publishing activities. Impact: - Reduced ci.yml from 763 lines to 465 lines (298 lines removed) - Eliminated duplicate build/validation/publish logic - Clarified that release.yml is the authoritative release pipeline - CI workflow now focuses solely on testing and validation All existing CI functionality (linting, testing, security scanning, building, integration tests, cross-platform tests, and performance tests) remains intact. Fixes #20 Co-authored-by: Andreas Florath <Andreas.Florath@telekom.de>
1 parent 0c1594a commit c9149c2

File tree

1 file changed

+0
-297
lines changed

1 file changed

+0
-297
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 297 deletions
Original file line numberDiff line numberDiff line change
@@ -447,303 +447,6 @@ jobs:
447447
path: benchmark.json
448448

449449

450-
test-pypi-publish:
451-
name: Test PyPI Publishing (TestPyPI)
452-
runs-on: ubuntu-latest
453-
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
454-
needs: [lint-and-type-check, test, build, integration-tests]
455-
environment: test-pypi
456-
457-
steps:
458-
- uses: actions/checkout@v4
459-
with:
460-
fetch-depth: 0 # Fetch all history for version validation
461-
462-
- name: Set up Python 3.11
463-
uses: actions/setup-python@v5
464-
with:
465-
python-version: "3.11"
466-
467-
- name: Install dependencies
468-
run: |
469-
python -m pip install --upgrade pip
470-
pip install build twine packaging
471-
472-
- name: Validate version format
473-
run: |
474-
python -c "
475-
import re
476-
import sys
477-
from pathlib import Path
478-
479-
# Read version from pyproject.toml
480-
content = Path('pyproject.toml').read_text()
481-
match = re.search(r'version = \"(.+?)\"', content)
482-
if not match:
483-
print('ERROR: Could not find version in pyproject.toml')
484-
sys.exit(1)
485-
486-
version = match.group(1)
487-
print(f'Found version: {version}')
488-
489-
# Validate version format (PEP 440)
490-
if not re.match(r'^\d+\.\d+\.\d+(?:\.(?:dev|alpha|beta|rc)\d+)?$', version):
491-
print(f'ERROR: Version {version} does not match PEP 440 format')
492-
print('Expected format: X.Y.Z or X.Y.Z.devN or X.Y.Z.alphaN, etc.')
493-
sys.exit(1)
494-
495-
print(f'✓ Version {version} is valid')
496-
"
497-
498-
- name: Build package
499-
run: |
500-
python -m build
501-
502-
- name: Check package
503-
run: |
504-
twine check dist/*
505-
506-
- name: Test installation from built package
507-
run: |
508-
# Create a temporary virtual environment
509-
python -m venv test_env
510-
source test_env/bin/activate
511-
512-
# Install the built wheel
513-
pip install dist/*.whl
514-
515-
# Test that the CLI is available
516-
aletheia-probe --help
517-
518-
# Cleanup
519-
deactivate
520-
rm -rf test_env
521-
522-
- name: Publish to TestPyPI
523-
if: success()
524-
env:
525-
TWINE_USERNAME: __token__
526-
TWINE_PASSWORD: ${{ secrets.TESTPYPI_API_TOKEN }}
527-
run: |
528-
echo "Publishing to TestPyPI..."
529-
twine upload --repository testpypi dist/* --verbose || echo "Note: Upload may fail if version already exists on TestPyPI"
530-
531-
- name: Test installation from TestPyPI
532-
if: success()
533-
run: |
534-
echo "Waiting 30 seconds for TestPyPI to process the upload..."
535-
sleep 30
536-
537-
# Create a fresh virtual environment
538-
python -m venv testpypi_env
539-
source testpypi_env/bin/activate
540-
541-
# Try to install from TestPyPI
542-
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ aletheia-probe || echo "Installation from TestPyPI may fail if package was just uploaded"
543-
544-
# Cleanup
545-
deactivate
546-
rm -rf testpypi_env
547-
548-
- name: Archive test artifacts
549-
uses: actions/upload-artifact@v4
550-
if: always()
551-
with:
552-
name: testpypi-artifacts
553-
path: dist/
554-
555-
publish:
556-
name: Publish to PyPI (Production)
557-
runs-on: ubuntu-latest
558-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
559-
needs: [lint-and-type-check, test, build, integration-tests, cross-platform-integration]
560-
environment: production
561-
562-
steps:
563-
- uses: actions/checkout@v4
564-
with:
565-
fetch-depth: 0 # Fetch all history for version validation
566-
567-
- name: Set up Python 3.11
568-
uses: actions/setup-python@v5
569-
with:
570-
python-version: "3.11"
571-
572-
- name: Install dependencies
573-
run: |
574-
python -m pip install --upgrade pip
575-
pip install build twine packaging requests
576-
577-
- name: Validate version matches git tag
578-
run: |
579-
python -c "
580-
import re
581-
import sys
582-
import os
583-
from pathlib import Path
584-
585-
# Read version from pyproject.toml
586-
content = Path('pyproject.toml').read_text()
587-
match = re.search(r'version = \"(.+?)\"', content)
588-
if not match:
589-
print('ERROR: Could not find version in pyproject.toml')
590-
sys.exit(1)
591-
592-
pyproject_version = match.group(1)
593-
print(f'Version in pyproject.toml: {pyproject_version}')
594-
595-
# Get git tag
596-
git_ref = os.environ.get('GITHUB_REF', '')
597-
if git_ref.startswith('refs/tags/'):
598-
git_tag = git_ref.replace('refs/tags/', '')
599-
# Remove 'v' prefix if present
600-
git_version = git_tag.lstrip('v')
601-
print(f'Git tag version: {git_version}')
602-
603-
if pyproject_version != git_version:
604-
print(f'ERROR: Version mismatch!')
605-
print(f' pyproject.toml: {pyproject_version}')
606-
print(f' git tag: {git_version}')
607-
sys.exit(1)
608-
609-
print(f'✓ Versions match: {pyproject_version}')
610-
else:
611-
print('WARNING: Not running from a tag, skipping tag validation')
612-
"
613-
614-
- name: Check if version exists on PyPI
615-
run: |
616-
python -c "
617-
import sys
618-
import re
619-
import requests
620-
from pathlib import Path
621-
622-
# Read version from pyproject.toml
623-
content = Path('pyproject.toml').read_text()
624-
match = re.search(r'version = \"(.+?)\"', content)
625-
version = match.group(1)
626-
627-
# Check PyPI
628-
response = requests.get(f'https://pypi.org/pypi/aletheia-probe/{version}/json')
629-
if response.status_code == 200:
630-
print(f'ERROR: Version {version} already exists on PyPI!')
631-
print(f'Please bump the version in pyproject.toml before releasing.')
632-
sys.exit(1)
633-
elif response.status_code == 404:
634-
print(f'✓ Version {version} does not exist on PyPI - safe to publish')
635-
else:
636-
print(f'WARNING: Could not verify version on PyPI (status {response.status_code})')
637-
print('Proceeding with caution...')
638-
"
639-
640-
- name: Validate package metadata
641-
run: |
642-
python -c "
643-
import sys
644-
from pathlib import Path
645-
import re
646-
647-
content = Path('pyproject.toml').read_text()
648-
649-
# Check required fields
650-
required = ['name', 'version', 'description', 'readme', 'license', 'authors']
651-
missing = []
652-
653-
for field in required:
654-
if field not in content:
655-
missing.append(field)
656-
657-
if missing:
658-
print(f'ERROR: Missing required fields in pyproject.toml: {missing}')
659-
sys.exit(1)
660-
661-
print('✓ All required metadata fields present')
662-
663-
# Validate URLs
664-
if 'Homepage' not in content:
665-
print('WARNING: Homepage URL not set')
666-
if 'Repository' not in content:
667-
print('WARNING: Repository URL not set')
668-
669-
print('✓ Package metadata validation passed')
670-
"
671-
672-
- name: Build package
673-
run: |
674-
python -m build
675-
676-
- name: Check package with twine
677-
run: |
678-
twine check dist/* --strict
679-
680-
- name: Display package contents
681-
run: |
682-
echo "📦 Package contents:"
683-
tar -tzf dist/*.tar.gz | head -30
684-
echo ""
685-
echo "📊 Package size:"
686-
du -h dist/*
687-
688-
- name: Publish to PyPI
689-
env:
690-
TWINE_USERNAME: __token__
691-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
692-
run: |
693-
echo "🚀 Publishing to PyPI..."
694-
twine upload dist/* --verbose
695-
696-
- name: Verify published package
697-
run: |
698-
python -c "
699-
import sys
700-
import time
701-
import requests
702-
from pathlib import Path
703-
import re
704-
705-
# Read version from pyproject.toml
706-
content = Path('pyproject.toml').read_text()
707-
match = re.search(r'version = \"(.+?)\"', content)
708-
version = match.group(1)
709-
710-
print(f'Waiting for PyPI to index version {version}...')
711-
712-
# Wait up to 2 minutes for the package to appear
713-
for i in range(24):
714-
response = requests.get(f'https://pypi.org/pypi/aletheia-probe/{version}/json')
715-
if response.status_code == 200:
716-
print(f'✓ Package successfully published to PyPI!')
717-
print(f'🔗 https://pypi.org/project/aletheia-probe/{version}/')
718-
sys.exit(0)
719-
time.sleep(5)
720-
721-
print('WARNING: Package not yet visible on PyPI after 2 minutes')
722-
print('This may be normal - check manually at: https://pypi.org/project/aletheia-probe/')
723-
"
724-
725-
- name: Create GitHub Release and upload packages
726-
uses: softprops/action-gh-release@v1
727-
with:
728-
files: dist/*
729-
generate_release_notes: true
730-
body: |
731-
## Installation
732-
733-
```bash
734-
pip install aletheia-probe
735-
```
736-
737-
See [CHANGELOG](https://github.com/sustainet-guardian/aletheia-probe/blob/main/docs/CHANGELOG.md) for full release notes.
738-
env:
739-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
740-
741-
- name: Archive release artifacts
742-
uses: actions/upload-artifact@v4
743-
with:
744-
name: release-packages
745-
path: dist/
746-
747450
notify:
748451
name: Notify
749452
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)