Skip to content

Pypi feature (#2)

Pypi feature (#2) #1

Workflow file for this run

# This workflow builds and publishes the SuperQwen package to PyPI and TestPyPI.

Check failure on line 1 in .github/workflows/publish-pypi.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish-pypi.yml

Invalid workflow file

(Line: 80, Col: 5): Required property is missing: runs-on
# It is triggered on new releases or can be run manually.
name: Publish to PyPI
on:
# Trigger on new releases (e.g., when you create a release in the GitHub UI)
release:
types: [published]
# Allow manual triggering from the Actions tab
workflow_dispatch:
# Restrict permissions for security
permissions:
id-token: write # Required for trusted publishing
jobs:
build-and-publish:
name: Build and publish Python package
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Verify project structure and version
run: |
echo "πŸ“¦ Checking project structure..."
ls -l
echo "πŸ” Checking SuperQwen package contents..."
ls -l SuperQwen/
echo "πŸ“‹ Checking version..."
if ! grep -q "__version__" "SuperQwen/__init__.py"; then
echo "❌ Version not found in SuperQwen/__init__.py!"
exit 1
fi
version=$(grep "__version__" "SuperQwen/__init__.py" | cut -d'"' -f2)
echo "βœ… Found version: $version"
- name: Build package
run: |
echo "πŸ”¨ Building package..."
python -m build
echo "πŸ“¦ Built files:"
ls -l dist/
- name: Validate package
run: |
echo "πŸ” Validating package with Twine..."
python -m twine check dist/*
- name: Publish to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
# This uses trusted publishing, which is more secure than API tokens.
# Make sure you have configured this project as a trusted publisher on PyPI.
- name: Publish to TestPyPI
if: github.event_name == 'workflow_dispatch'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
# For manual TestPyPI uploads, you'll need to use a token.
# Add a secret named TEST_PYPI_API_TOKEN to your repository.
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
test-installation:
name: Test package installation from TestPyPI
needs: build-and-publish
if: github.event_name == 'workflow_dispatch' # Only run on manual triggers
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Test installation from TestPyPI
run: |
echo "πŸ§ͺ Testing installation from TestPyPI..."
# Wait a bit for the package to be available on TestPyPI
sleep 30
pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
SuperQwen
echo "🐍 Testing package import..."
python -c "import SuperQwen; print(f'βœ… Successfully imported SuperQwen v{SuperQwen.__version__}')"
echo "🎀 Testing CLI entry point..."
superqwen --help
echo "βœ… Installation test completed successfully!"