Skip to content

Commit d756080

Browse files
committed
Fix PyPI publish
1 parent fe82835 commit d756080

File tree

2 files changed

+78
-22
lines changed

2 files changed

+78
-22
lines changed

.github/workflows/publish-pypi.yml

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,36 @@ on:
44
workflow_dispatch: # Manual trigger only (publish-release.yml handles automatic releases)
55

66
jobs:
7-
build:
8-
name: Build distribution
7+
# Build source distribution (sdist) - only once, platform-independent
8+
build-sdist:
9+
name: Build Source Distribution
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: '3.11'
19+
20+
- name: Install build dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install build wheel setuptools
24+
25+
- name: Build source distribution only
26+
run: python -m build --sdist
27+
28+
- name: Upload sdist artifact
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: dist-sdist
32+
path: dist/*.tar.gz
33+
34+
# Build binary wheels for each platform/Python version
35+
build-wheels:
36+
name: Build Wheels
937
runs-on: ${{ matrix.os }}
1038
strategy:
1139
matrix:
@@ -25,23 +53,23 @@ jobs:
2553
python -m pip install --upgrade pip
2654
pip install build wheel setuptools
2755
28-
- name: Build distribution
29-
run: python -m build
56+
- name: Build wheel only
57+
run: python -m build --wheel
3058

31-
- name: Upload artifacts
59+
- name: Upload wheel artifacts
3260
uses: actions/upload-artifact@v4
3361
with:
34-
name: dist-${{ matrix.os }}-py${{ matrix.python-version }}
35-
path: dist/
62+
name: dist-wheel-${{ matrix.os }}-py${{ matrix.python-version }}
63+
path: dist/*.whl
3664

3765
publish-testpypi:
3866
name: Publish to TestPyPI
39-
needs: build
67+
needs: [build-sdist, build-wheels]
4068
runs-on: ubuntu-latest
4169
if: github.event_name == 'workflow_dispatch'
4270

4371
steps:
44-
- name: Download artifacts
72+
- name: Download all artifacts
4573
uses: actions/download-artifact@v4
4674
with:
4775
pattern: dist-*
@@ -56,15 +84,15 @@ jobs:
5684

5785
publish-pypi:
5886
name: Publish to PyPI
59-
needs: build
87+
needs: [build-sdist, build-wheels]
6088
runs-on: ubuntu-latest
6189
if: github.event_name == 'release' && github.event.action == 'published'
6290

6391
permissions:
6492
id-token: write # For trusted publishing
6593

6694
steps:
67-
- name: Download artifacts
95+
- name: Download all artifacts
6896
uses: actions/download-artifact@v4
6997
with:
7098
pattern: dist-*

.github/workflows/publish-release.yml

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,37 @@ on:
55
types: [published]
66

77
jobs:
8-
# Build PyPI distributions
9-
build-pypi:
10-
name: Build PyPI Package
8+
# Build source distribution (sdist) - only once, platform-independent
9+
build-sdist:
10+
name: Build Source Distribution
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.11'
20+
21+
- name: Install build dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install build wheel setuptools
25+
26+
- name: Build source distribution only
27+
run: python -m build --sdist
28+
29+
- name: Upload sdist artifact
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: pypi-sdist
33+
path: dist/*.tar.gz
34+
retention-days: 7
35+
36+
# Build binary wheels for each platform/Python version
37+
build-wheels:
38+
name: Build Wheels
1139
runs-on: ${{ matrix.os }}
1240
strategy:
1341
matrix:
@@ -27,14 +55,14 @@ jobs:
2755
python -m pip install --upgrade pip
2856
pip install build wheel setuptools
2957
30-
- name: Build distribution
31-
run: python -m build
58+
- name: Build wheel only
59+
run: python -m build --wheel
3260

33-
- name: Upload PyPI artifacts
61+
- name: Upload wheel artifacts
3462
uses: actions/upload-artifact@v4
3563
with:
36-
name: pypi-dist-${{ matrix.os }}-py${{ matrix.python-version }}
37-
path: dist/
64+
name: pypi-wheel-${{ matrix.os }}-py${{ matrix.python-version }}
65+
path: dist/*.whl
3866
retention-days: 7
3967

4068
# Build Conda packages
@@ -77,16 +105,16 @@ jobs:
77105
# Publish to PyPI
78106
publish-pypi:
79107
name: Publish to PyPI
80-
needs: build-pypi
108+
needs: [build-sdist, build-wheels]
81109
runs-on: ubuntu-latest
82110
permissions:
83111
id-token: write
84112

85113
steps:
86-
- name: Download PyPI artifacts
114+
- name: Download all PyPI artifacts
87115
uses: actions/download-artifact@v4
88116
with:
89-
pattern: pypi-dist-*
117+
pattern: pypi-*
90118
merge-multiple: true
91119
path: dist/
92120

0 commit comments

Comments
 (0)