sumoOCR-tiny / .github /workflows /release.yml
bikramdocsumo
Release 1.0.0: Python 3.10+, setuptools 77 floor, single-source version, release workflow
09471fb
Raw History Blame Contribute Delete
2.64 kB
name: Release
# Pushing a tag vX.Y.Z builds the package, tests the built wheel and publishes it to PyPI with
# Trusted Publishing (no stored token). One-time setup on pypi.org: the project's Publishing page,
# add a GitHub publisher for this repository, workflow "release.yml", environment "pypi".
# Run by hand (workflow_dispatch) it builds and tests only.
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
lfs: true # the .onnx models are Git LFS files: without this the wheel ships 130-byte pointers
- uses: astral-sh/setup-uv@v6
- name: Models are real files, not Git LFS pointers
run: |
for f in sumoocr/models/det.onnx sumoocr/models/rec.onnx; do
test "$(wc -c < "$f")" -gt 100000 || { echo "::error::$f is a Git LFS pointer"; exit 1; }
done
- name: Tag matches the package version
if: startsWith(github.ref, 'refs/tags/v')
run: |
version=$(sed -n 's/^__version__ = "\(.*\)"$/\1/p' sumoocr/__init__.py)
test "v$version" = "$GITHUB_REF_NAME" || { echo "::error::tag $GITHUB_REF_NAME, package $version"; exit 1; }
- run: uv build
- run: uvx twine check --strict dist/*
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
if-no-files-found: error
test:
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
include:
- { os: macos-latest, python: "3.12" }
- { os: windows-latest, python: "3.12" }
steps:
- uses: actions/checkout@v5
with:
lfs: true # examples/invoice.png, read by the tests
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Test the built wheel, not the source tree
shell: bash
run: |
rm -rf sumoocr
python -m pip install dist/*.whl pytest
python -m pytest -q tests
publish:
needs: test
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # Trusted Publishing (OIDC)
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1