-
Notifications
You must be signed in to change notification settings - Fork 3
152 lines (141 loc) · 5.56 KB
/
Copy pathpypi-publish.yml
File metadata and controls
152 lines (141 loc) · 5.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Publish the `docling-rs` PyPI package (the PyO3 Python bindings in
# crates/docling-py) for a chosen release. Like the npm package, the bindings are
# a compiled native extension, so it can't be a one-line `twine upload`: wheels
# are built on a matrix of runners (one abi3 wheel per OS/arch — `abi3-py39`, so
# a single wheel covers every Python ≥ 3.9), an sdist is built once, and a
# publish job uploads them all to PyPI.
#
# Trigger: manual only (workflow_dispatch), mirroring npm-publish.yml. By default
# it builds the checked-out ref at the version already declared in
# crates/docling-py/pyproject.toml; pass `version` (or a release `tag`) to
# override. Run it from the Actions tab (or `gh workflow run pypi-publish.yml`,
# optionally `-f version=0.16.0`).
#
# Requires one repository secret: PYPI_TOKEN — a PyPI API token with publish
# rights to the `docling-rs` project. (To switch to OIDC trusted publishing
# instead, drop the `password:` line and add `id-token: write` + an
# `environment:` to the publish job, as docling-core's pypi.yml does.)
#
# The ONNX Runtime is statically bundled at build time (`ort` `download-binaries`)
# and pdfium is loaded at runtime from the model cache, so the wheels are
# self-contained for the declarative path and need no extra native setup here —
# same story as the npm build.
name: pypi publish
on:
workflow_dispatch:
inputs:
tag:
description: "Release tag to build (e.g. v0.16.0). Blank = current ref."
required: false
default: ""
version:
description: "Override the PyPI version (e.g. 0.16.0). Blank = tag, or the version in pyproject.toml."
required: false
default: ""
concurrency:
group: pypi-publish-${{ inputs.tag || github.ref }}
cancel-in-progress: false
defaults:
run:
working-directory: crates/docling-py
jobs:
wheels:
name: wheel ${{ matrix.target }}
runs-on: ${{ matrix.host }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
host: ubuntu-22.04
manylinux: "2_28"
# Native ARM64 Linux runner — avoids cross-compiling the ONNX/ort build.
- target: aarch64-unknown-linux-gnu
host: ubuntu-24.04-arm
manylinux: "2_28"
- target: x86_64-pc-windows-msvc
host: windows-latest
manylinux: "auto"
# macOS wheels are omitted: GitHub-hosted macOS runners are blocked in
# this environment and darwin can't be cross-compiled on Linux (needs
# the Apple SDK). macOS users build from source with `maturin develop`.
# Re-add when runners are available:
# - { target: aarch64-apple-darwin, host: macos-14, manylinux: "auto" }
# - { target: x86_64-apple-darwin, host: macos-14, manylinux: "auto" }
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
# Version override: patch [project].version in pyproject.toml before the
# build so it lands in the wheel metadata/filename. No override → keep the
# version already declared in the file.
- name: Resolve version
shell: bash
run: |
v="${{ inputs.version }}"
if [ -z "$v" ] && [ -n "${{ inputs.tag }}" ]; then v="${{ inputs.tag }}"; v="${v#v}"; fi
if [ -n "$v" ]; then
sed -i.bak -E "0,/^version = \".*\"/s//version = \"$v\"/" pyproject.toml && rm -f pyproject.toml.bak
echo "Building docling-rs $v"
else
echo "Building docling-rs $(grep -m1 '^version = ' pyproject.toml | sed -E 's/.*"([^"]+)".*/\1/') (from pyproject.toml)"
fi
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux }}
args: --release --out dist
sccache: "true"
working-directory: crates/docling-py
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.target }}
path: crates/docling-py/dist/*.whl
if-no-files-found: error
sdist:
name: sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
- name: Resolve version
shell: bash
run: |
v="${{ inputs.version }}"
if [ -z "$v" ] && [ -n "${{ inputs.tag }}" ]; then v="${{ inputs.tag }}"; v="${v#v}"; fi
if [ -n "$v" ]; then
sed -i.bak -E "0,/^version = \".*\"/s//version = \"$v\"/" pyproject.toml && rm -f pyproject.toml.bak
fi
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
working-directory: crates/docling-py
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: crates/docling-py/dist/*.tar.gz
if-no-files-found: error
publish:
name: publish to PyPI
needs: [wheels, sdist]
runs-on: ubuntu-latest
steps:
# All wheels + the sdist → a single dist/ for the upload.
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
password: ${{ secrets.PYPI_TOKEN }}
# Idempotent re-runs: don't fail if a version is already uploaded.
skip-existing: true