Publish Python Package #14
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: Publish Python Package | |
# Trigger manually using workflow_dispatch | |
on: | |
workflow_dispatch: | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository | |
- 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' | |
# Step 3: Upgrade pip and install dependencies | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine | |
# Step 4: Build the package | |
- name: Build the package | |
run: | | |
python setup.py sdist bdist_wheel | |
- name: Check the package with twine | |
run: | | |
twine check dist/* | |
continue-on-error: false | |
# Step 5: Upload the package to PyPI | |
- name: Upload package to PyPI | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
python -m twine upload dist/* | |
# Step 6: Upload built package as an artifact | |
- name: Upload package as artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: python-package | |
path: dist/* |