Upload Python Package #6
This file contains 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: Upload Python Package | |
on: | |
# Trigger on release creation | |
release: | |
types: [created] | |
# Allow manual triggering for testing | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the repository code | |
- name: Check out code | |
uses: actions/checkout@v2 | |
# Step 2: Set up Python | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
# Step 3: Upgrade pip and install dependencies for building and publishing | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build twine | |
# Step 4: Build the package | |
- name: Build the package | |
run: python -m build | |
# Step 5: Publish to PyPI | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} # Set in repository secrets | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} # Set in repository secrets | |
run: twine upload dist/* |