Skip to content

Commit 5d8b23b

Browse files
nicknick
authored andcommitted
updated python-publish workflow for multi envs
1 parent 6d645c6 commit 5d8b23b

File tree

1 file changed

+51
-35
lines changed

1 file changed

+51
-35
lines changed

.github/workflows/python-publish.yml

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
# This workflow will upload a Python Package to PyPI when a release is created
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3-
4-
# This workflow uses actions that are not certified by GitHub.
5-
# They are provided by a third-party and are governed by
6-
# separate terms of service, privacy policy, and support
7-
# documentation.
1+
# Builds platform wheels for Linux (manylinux), Windows, and macOS, then
2+
# publishes everything to PyPI via OIDC Trusted Publishing (no API token).
3+
# Triggered when a GitHub Release is published.
84

95
name: Upload Python Package
106

@@ -16,7 +12,39 @@ permissions:
1612
contents: read
1713

1814
jobs:
19-
release-build:
15+
# ── Build binary wheels (one runner per platform) ───────────────────────────
16+
build-wheels:
17+
name: Build wheels on ${{ matrix.os }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
os: [ubuntu-latest, windows-latest, macos-latest]
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Build wheels
27+
uses: pypa/cibuildwheel@v2.22.0
28+
env:
29+
# CPython 3.8 – 3.14 only; skip PyPy (not tested with this extension)
30+
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* cp314-*
31+
# Skip musl/Alpine — system zlib may not be present in all musl images
32+
CIBW_SKIP: "*-musllinux_*"
33+
# macOS: build both Intel and Apple-Silicon wheels
34+
CIBW_ARCHS_MACOS: x86_64 arm64
35+
# Linux: x86_64 only (add aarch64 later via QEMU if needed)
36+
CIBW_ARCHS_LINUX: x86_64
37+
# Windows: 64-bit only
38+
CIBW_ARCHS_WINDOWS: AMD64
39+
40+
- uses: actions/upload-artifact@v4
41+
with:
42+
name: cibw-wheels-${{ matrix.os }}
43+
path: ./wheelhouse/*.whl
44+
45+
# ── Build source distribution ────────────────────────────────────────────────
46+
build-sdist:
47+
name: Build source distribution
2048
runs-on: ubuntu-latest
2149

2250
steps:
@@ -25,50 +53,38 @@ jobs:
2553
- uses: actions/setup-python@v5
2654
with:
2755
python-version: "3.x"
28-
29-
- name: Install Dependencies
30-
run: |
31-
python -m pip install pybind11
3256

33-
- name: Build release distributions
57+
- name: Build sdist
3458
run: |
35-
# NOTE: put your own distribution build steps here.
3659
python -m pip install build
37-
python -m build
60+
python -m build --sdist
3861
39-
- name: Upload distributions
40-
uses: actions/upload-artifact@v4
62+
- uses: actions/upload-artifact@v4
4163
with:
42-
name: release-dists
43-
path: dist/
64+
name: cibw-sdist
65+
path: dist/*.tar.gz
4466

67+
# ── Publish to PyPI via OIDC Trusted Publishing ──────────────────────────────
4568
pypi-publish:
69+
name: Publish to PyPI
4670
runs-on: ubuntu-latest
47-
needs:
48-
- release-build
71+
needs: [build-wheels, build-sdist]
72+
4973
permissions:
50-
# IMPORTANT: this permission is mandatory for trusted publishing
74+
# Required for OIDC Trusted Publishing — no API token needed
5175
id-token: write
5276

53-
# Dedicated environments with protections for publishing are strongly recommended.
54-
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
5577
environment:
5678
name: pypi
57-
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
5879
url: https://pypi.org/p/docx-comment-parser
59-
#
60-
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
61-
# ALTERNATIVE: exactly, uncomment the following line instead:
62-
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
6380

6481
steps:
65-
- name: Retrieve release distributions
82+
- name: Download all artifacts
6683
uses: actions/download-artifact@v4
6784
with:
68-
name: release-dists
69-
path: dist/
85+
pattern: cibw-*
86+
path: dist
87+
merge-multiple: true
7088

71-
- name: Publish release distributions to PyPI
89+
- name: Publish to PyPI
7290
uses: pypa/gh-action-pypi-publish@release/v1
73-
with:
74-
packages-dir: dist/

0 commit comments

Comments
 (0)