Publish to PyPI #5
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
| name: Publish to PyPI | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (e.g., 0.1.0)' | |
| required: true | |
| type: string | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| pip install poetry | |
| pip install twine | |
| - name: Build package | |
| run: | | |
| poetry build | |
| ls -la dist/ | |
| - name: Check package | |
| run: | | |
| twine check dist/* | |
| - name: Publish to Test PyPI (Optional) | |
| continue-on-error: true | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
| run: | | |
| if [ -n "$TWINE_PASSWORD" ]; then | |
| twine upload --repository testpypi dist/* --skip-existing | |
| echo "✅ Published to Test PyPI" | |
| echo "Test with: pip install -i https://test.pypi.org/simple/ claude-parser" | |
| else | |
| echo "⚠️ Skipping Test PyPI (no token configured)" | |
| fi | |
| - name: Test installation | |
| run: | | |
| # Try installing from Test PyPI first, fall back to building locally | |
| pip install -i https://test.pypi.org/simple/ claude-parser || pip install dist/*.whl | |
| python -c "import claude_parser; print(f'✅ Import successful: v{claude_parser.__version__}')" | |
| - name: Publish to PyPI | |
| if: github.event_name == 'release' || github.event.inputs.version != '' | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
| run: | | |
| twine upload dist/* --skip-existing | |
| echo "✅ Published to PyPI" | |
| echo "Install with: pip install claude-parser" |