Skip to content

Publish to PyPI

Publish to PyPI #6

Workflow file for this run

name: Publish to PyPI
permissions:
actions: write
on:
workflow_run:
workflows: [Python Tests]
types:
- completed
branches:
- main
jobs:
pypi-release:
name: PyPI Release
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
environment:
name: pypi
url: https://pypi.org/project/graphomotor/
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml
- name: Skip release if version unchanged
run: |
version_change=$(git diff -r HEAD^1 pyproject.toml | grep -E "^(\+|-)version =")
if [[ -z "$version_change" ]]; then
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install uv
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1
with:
enable-cache: true
- name: Build package
run: uv build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4