Skip to content

Publish Python Package #2

Publish Python Package

Publish Python Package #2

Workflow file for this run

# adapted from:
# https://til.simonwillison.net/pypi/pypi-releases-from-github
# https://github.com/snok/install-poetry
# https://jacobian.org/til/github-actions-poetry/
# https://github.com/orgs/community/discussions/25305#discussioncomment-8256560
name: Publish Python Package
on:
release:
types: [created]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Install the latest version of uv and set the python version
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Install test dependencies
run: |
uv sync --group test
- name: Test with python ${{ matrix.python-version }}
run: uv run --frozen pytest
deploy:
runs-on: ubuntu-latest
needs: [test]
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Install the latest version of uv and set the python version
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Build
run: |
uv build
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1