Publish to PyPI #3
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 to PyPI | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.8' | |
- name: Upgrade pip and setuptools | |
run: | | |
python -m pip install --upgrade pip setuptools | |
- name: Install pipx | |
run: | | |
python -m pip install --upgrade pipx | |
- name: Install Poetry using pipx | |
run: | | |
pipx install poetry | |
- name: Configure Poetry | |
run: | | |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} | |
- name: Regenerate lock file if needed | |
run: | | |
set -e | |
if poetry check; then | |
echo "Dependencies are consistent" | |
else | |
echo "Regenerating lock file..." | |
poetry lock | |
fi | |
- name: Install dependencies | |
run: poetry install --only main | |
- name: Install dependencies (including dev) | |
run: poetry install --with dev | |
- name: Run tests | |
run: poetry run pytest | |
- name: Build and publish | |
env: | |
POETRY_HTTP_BASIC_PYPI_USERNAME: __token__ | |
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
poetry build | |
poetry publish |