Update main.py #22
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
# This workflow file is used to automate the packaging and publishing of a Python project to PyPI. | ||
# It is triggered on pushes to the main branch, pull requests to the main branch, and when a new release is created. | ||
# The workflow runs on multiple operating systems (Ubuntu, macOS, Windows) and multiple versions of Python. | ||
# It uses the setup-python action to set up a Python environment. | ||
# It installs necessary packages for packaging and publishing to PyPI. | ||
# It builds the package and publishes it to PyPI when a new release is created. | ||
# The TWINE_USERNAME and TWINE_PASSWORD environment variables are used for authentication with PyPI. | ||
name: Publish Python Package | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
release: | ||
types: [created] | ||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
python-version: '3.x' | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel twine | ||
- name: Build package | ||
run: python setup.py sdist bdist_wheel | ||
- name: Publish package | ||
if: github.event_name == 'release' && github.event.action == 'created' | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
run: twine upload dist/* |