Skip to content

Commit 7706471

Browse files
authored
ci: use ci build artifacts, push all together to pypi, simplify mac builds (#71)
Signed-off-by: Michele Dolfi <[email protected]> Signed-off-by: Michele Dolfi <[email protected]>
1 parent e2820a4 commit 7706471

File tree

3 files changed

+99
-37
lines changed

3 files changed

+99
-37
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ jobs:
2323
build-wheels:
2424
if: ${{ github.event_name == 'push' || (github.event.pull_request.head.repo.full_name != 'DS4SD/docling-parse' && github.event.pull_request.head.repo.full_name != 'ds4sd/docling-parse') }}
2525
uses: ./.github/workflows/wheels.yml
26+
permissions:
27+
id-token: write # needed also if not used (see publish condition)
28+
contents: write # needed also if not used (see publish condition)
2629
rhel-build:
2730
if: ${{ github.event_name == 'push' || (github.event.pull_request.head.repo.full_name != 'DS4SD/docling-parse' && github.event.pull_request.head.repo.full_name != 'ds4sd/docling-parse') }}
2831
uses: ./.github/workflows/rhel.yml

.github/workflows/release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ permissions:
1010
jobs:
1111
build-and-publish:
1212
uses: ./.github/workflows/wheels.yml
13-
secrets: inherit
13+
with:
14+
publish: true
15+
secrets: inherit
16+
permissions:
17+
id-token: write # IMPORTANT: mandatory for trusted publishing
18+
contents: write # IMPORTANT: mandatory for adding artifacts to GitHub Releases

.github/workflows/wheels.yml

Lines changed: 90 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
11
on:
22
workflow_call:
3+
inputs:
4+
publish:
5+
type: boolean
6+
description: "If true, the packages will be published."
7+
default: false
38

49
env:
510
CMAKE_BUILD_TYPE: Release
611

712
jobs:
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"
@@ -79,12 +96,6 @@ jobs:
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+
uses: sigstore/[email protected]
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

Comments
 (0)