Publish Python Package to PyPI #5
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 to PyPI | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Fetch Version | |
id: get_version | |
run: | | |
echo "PACKAGE_VERSION=$(python -c 'from src.DOLOST.version import __version__; print(__version__)')" >> $GITHUB_ENV | |
- name: Build package | |
run: | | |
python setup.py sdist bdist_wheel | |
- name: Print built files | |
run: | | |
ls -la dist/ | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@master | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
packages_dir: dist | |
package_version: ${{ env.PACKAGE_VERSION }} |