ci: publish Python source distribution

This commit is contained in:
dvd233 2026-09-22 17:03:58 -07:00
parent 8cadfede70
commit 35d7647776
No known key found for this signature in database
GPG Key ID: FB6E3F753312D049
2 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,50 @@
name: Publish Python source distribution
on:
release:
types: [published]
permissions:
contents: read
jobs:
build:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: Check out the release source
uses: actions/checkout@v4
- name: Build source distribution
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --manifest-path deepseek-recipe-python/Cargo.toml --out dist
- name: Store source distribution
uses: actions/upload-artifact@v4
with:
name: python-sdist
path: dist/*.tar.gz
if-no-files-found: error
publish:
name: Publish source distribution to PyPI
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/deepseek-recipe
permissions:
id-token: write
steps:
- name: Download source distribution
uses: actions/download-artifact@v4
with:
name: python-sdist
path: dist
- name: Publish package distributions
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/

View File

@ -110,6 +110,24 @@ For an installation without editable development, use:
python3 -m pip install ./deepseek-recipe-python
```
## Source distribution
The release workflow publishes a source distribution alongside the wheels so
`pip` has an artifact to build when no wheel matches the user's platform. To
reproduce the source artifact locally:
```sh
maturin sdist \
--manifest-path deepseek-recipe-python/Cargo.toml \
--out dist-sdist
twine check dist-sdist/*
```
The command packages the workspace crates and Python sources needed to build
the extension. The PyPI publishing job uses trusted publishing and runs when a
GitHub release is published; configure the `pypi` environment and the
`deepseek-recipe` trusted publisher before the first release.
## Wheel packaging
The extension links OpenCV dynamically, so a wheel is only installable on a