Skip to content

.github/workflows/pypi.yaml #186

.github/workflows/pypi.yaml

.github/workflows/pypi.yaml #186

Workflow file for this run

on:
workflow_dispatch:
release:
types:
- published
env:
DEFAULT_PYTHON: "3.12"
jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Poetry
run: pipx install poetry
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache: "poetry"
- name: Install workflow dependencies
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: Install dependencies
run: poetry install --no-interaction
- name: Run pytest
run: poetry run pytest --cov pylamarzocco tests
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Set package version
run: |
version="${{ github.event.release.tag_name }}"
version="${version,,}"
version="${version#v}"
poetry version --no-interaction "${version}"
- name: Build package
run: poetry build --no-interaction
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1