1.0.1 #1
Workflow file for this run
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.6)' | |
| required: true | |
| type: string | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write # для Trusted Publishing (рекомендуется) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Update version in setup.py (manual trigger) | |
| if: github.event_name == 'workflow_dispatch' && inputs.version != '' | |
| run: | | |
| sed -i "s/version='[^']*'/version='${{ inputs.version }}'/" setup.py | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| run: | | |
| python -m build | |
| - name: Check package | |
| run: | | |
| twine check dist/* | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| print-hash: true | |
| # Альтернативный вариант с API токеном (если Trusted Publishing не настроен): | |
| # env: | |
| # TWINE_USERNAME: __token__ | |
| # TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| # run: twine upload dist/* | |