Update python-publish.yml #3
Workflow file for this run
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 | |
# Trigger the workflow on push to any tag that starts with "v" | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
publish: | |
runs-on: ubuntu-latest # Use the latest Ubuntu environment | |
steps: | |
# Step 1: Check out the repository code | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step 2: Set up Python environment | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' # Specify the Python version | |
# Step 3: Install dependencies for building and uploading the package | |
- name: Install build dependencies | |
run: | | |
python -m pip install --upgrade pip # Upgrade pip | |
pip install build twine # Install build and twine | |
# Step 4: Build the package | |
- name: Build the package | |
run: python -m build # Build source and wheel distributions | |
# Step 5: List files in the dist directory for debugging | |
- name: List files for debugging | |
run: ls -l dist # List the contents of the dist directory | |
# Step 6: Publish the package to PyPI | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: __token__ # Use __token__ for authentication | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} # Use the PyPI API token stored as a secret | |
run: twine upload dist/* # Upload the built distributions to PyPI |