Update VERSION #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow builds and publishes the SuperQwen package to PyPI and TestPyPI. | ||
| # 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!" | ||