11on :
22 workflow_call :
3+ inputs :
4+ publish :
5+ type : boolean
6+ description : " If true, the packages will be published."
7+ default : false
38
49env :
510 CMAKE_BUILD_TYPE : Release
611
712jobs :
13+ build_sdist :
14+ name : Build sdist artifacts
15+ runs-on : ubuntu-latest
16+
17+ steps :
18+ - name : Checkout
19+ uses : actions/checkout@v4
20+ - name : Setup Python
21+ uses : actions/setup-python@v5
22+ - name : Install poetry
23+ run : |
24+ pipx install poetry
25+ - name : Build sdit
26+ run : |
27+ poetry build -f sdist
28+ ls ./dist
29+ - name : Upload artifacts
30+ uses : actions/upload-artifact@v4
31+ with :
32+ name : python-package-distributions-sdist
33+ path : dist/
34+
835 build_wheels :
9- name : Build wheel for py${{ matrix.python-version }} ${{ matrix.os.platform_id }} ${{ matrix.os.macos_version }}
36+ name : Build wheel for py${{ matrix.python-version }} ${{ matrix.os.platform_id }}
1037 runs-on : ${{ matrix.os.name }}
1138
1239 strategy :
@@ -23,22 +50,12 @@ jobs:
2350
2451 - name : " macos-13"
2552 platform : " macos"
26- macos_version : " 13"
27- platform_id : " macosx_x86_64"
28-
29- - name : " macos-13"
30- platform : " macos"
31- macos_version : " 13"
32- platform_id : " macosx_arm64"
33-
34- - name : " macos-14"
35- platform : " macos"
36- macos_version : " 14"
53+ min_macos_version : " 13"
3754 platform_id : " macosx_x86_64"
3855
3956 - name : " macos-14"
4057 platform : " macos"
41- macos_version : " 14"
58+ min_macos_version : " 14"
4259 platform_id : " macosx_arm64"
4360
4461 - name : " windows-latest"
7996 $cp_version = "cp$($version -replace '\.', '')"
8097 Add-Content -Path $env:GITHUB_ENV -Value "python_cp_version=$cp_version"
8198
82- - name : Setup pypi for poetry [for releases only]
83- if : ${{ startsWith(github.ref, 'refs/tags/') }}
84- run : |
85- poetry config keyring.enabled false
86- poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
87-
8899 - name : Convert python version to cpXYZ
89100 if : ${{matrix.os.platform_id != 'win_amd64'}}
90101 run : |
@@ -104,7 +115,7 @@ jobs:
104115 CIBW_BUILD_VERBOSITY : 3
105116 CMAKE_OSX_ARCHITECTURES : x86_64
106117 CIBW_REPAIR_WHEEL_COMMAND_MACOS : " " # do not run delocate-wheel before the re-tag
107- CIBW_ENVIRONMENT : " MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.macos_version }}.0"
118+ CIBW_ENVIRONMENT : " MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.min_macos_version }}.0"
108119 ARCHFLAGS : -arch x86_64
109120 BUILD_THREADS : " 4"
110121 PYTORCH_MPS_HIGH_WATERMARK_RATIO : " 0.0"
@@ -121,7 +132,7 @@ jobs:
121132 poetry run python -m cibuildwheel --output-dir wheelhouse
122133 echo "step 1"
123134 ls -l wheelhouse
124- poetry run wheel tags --platform-tag macosx_${{ matrix.os.macos_version }}_0_x86_64 ./wheelhouse/*.whl
135+ poetry run wheel tags --remove -- platform-tag macosx_${{ matrix.os.min_macos_version }}_0_x86_64 ./wheelhouse/*.whl
125136 rm -f ./wheelhouse/*arm64.whl
126137 echo "step 2"
127138 ls -l wheelhouse
@@ -154,7 +165,7 @@ jobs:
154165 CIBW_BUILD_VERBOSITY : 3
155166 CMAKE_OSX_ARCHITECTURES : arm64
156167 CIBW_REPAIR_WHEEL_COMMAND_MACOS : " " # do not run delocate-wheel before the re-tag
157- CIBW_ENVIRONMENT : " MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.macos_version }}.0"
168+ CIBW_ENVIRONMENT : " MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.min_macos_version }}.0"
158169 ARCHFLAGS : -arch arm64
159170 BUILD_THREADS : " 4"
160171 PYTORCH_MPS_HIGH_WATERMARK_RATIO : " 0.0"
@@ -172,7 +183,7 @@ jobs:
172183 poetry run python -m cibuildwheel --output-dir wheelhouse
173184 echo "step 1"
174185 ls -l wheelhouse
175- poetry run wheel tags --platform-tag macosx_${{ matrix.os.macos_version }}_0_arm64 ./wheelhouse/*.whl
186+ poetry run wheel tags --remove -- platform-tag macosx_${{ matrix.os.min_macos_version }}_0_arm64 ./wheelhouse/*.whl
176187 rm -f ./wheelhouse/*x86_64.whl
177188 echo "step 2"
178189 ls -l wheelhouse
@@ -195,13 +206,6 @@ jobs:
195206 uses : docker/setup-qemu-action@v3
196207 with :
197208 platforms : all
198-
199- - name : Build sdist
200- # build only on Linux to avoid too many duplicates of the sdist
201- if : matrix.os.name == 'ubuntu-latest'
202- run : |
203- echo "Building wheel ${CIBW_BUILD}"
204- poetry build -f sdist
205209
206210 - name : Build wheels [linux]
207211 if : matrix.os.name == 'ubuntu-latest'
@@ -296,11 +300,61 @@ jobs:
296300 }
297301 Copy-Item -Path .\wheelhouse\*.whl -Destination .\dist\
298302
299- - name : publish wheels (dry run)
300- run : |
301- poetry publish --skip-existing --dry-run --no-interaction -vvv
303+ - name : Upload artifacts
304+ uses : actions/upload-artifact@v4
305+ with :
306+ name : python-package-distributions-py${{ matrix.python-version }}-${{ matrix.os.platform_id }}
307+ path : dist/
302308
303- - name : publish wheels (on publishing) [for releases only]
304- if : ${{ startsWith(github.ref, 'refs/tags/') }}
309+ publish-packages :
310+ name : >-
311+ Publish Python 🐍 distribution 📦 to PyPI
312+ if : inputs.publish && startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
313+ needs :
314+ - build_sdist
315+ - build_wheels
316+ runs-on : ubuntu-latest
317+ environment :
318+ name : pypi
319+ url : https://pypi.org/p/docling-parse
320+ permissions :
321+ id-token : write # IMPORTANT: mandatory for trusted publishing
322+ contents : write # IMPORTANT: mandatory for adding artifacts to GitHub Releases
323+ steps :
324+ - name : Download all the dists
325+ uses : actions/download-artifact@v4
326+ with :
327+ merge-multiple : true
328+ path : dist/
329+ - name : List dist/
305330 run : |
306- poetry publish --skip-existing --no-interaction -vvv
331+ ls ./dist
332+ - name : Sign the dists with Sigstore
333+ 334+ with :
335+ release-signing-artifacts : false
336+ inputs : >-
337+ ./dist/*.tar.gz
338+ ./dist/*.whl
339+ - name : List dist/
340+ run : |
341+ ls ./dist
342+ - name : Upload artifact signatures to GitHub Release
343+ env :
344+ GITHUB_TOKEN : ${{ github.token }}
345+ # Upload to GitHub Release using the `gh` CLI.
346+ # `dist/` contains the built packages, and the
347+ # sigstore-produced signatures and certificates.
348+ run : >-
349+ gh release upload
350+ '${{ github.ref_name }}' dist/**
351+ --repo '${{ github.repository }}'
352+ # PyPI does not accept .sigstore artifacts and
353+ # gh-action-pypi-publish has no option to ignore them.
354+ - name : Remove sigstore signatures before uploading to PyPI
355+ run : rm ./dist/*.sigstore.json
356+ - name : Publish distribution 📦 to PyPI
357+ uses : pypa/gh-action-pypi-publish@release/v1
358+ with :
359+ # currently not working with reusable workflows
360+ attestations : false
0 commit comments